mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +00:00
Merge pull request #1080 from c9s/narumi/marketcap/order-type
strategy: marketcap: add orderType parameter
This commit is contained in:
commit
f064f5fbe1
|
@ -22,5 +22,6 @@ exchangeStrategies:
|
|||
threshold: 1%
|
||||
# max amount to buy or sell per order
|
||||
maxAmount: 1_000
|
||||
dryRun: true
|
||||
queryInterval: 1h
|
||||
orderType: LIMIT_MAKER # LIMIT_MAKER, LIMIT, MARKET
|
||||
dryRun: true
|
||||
|
|
|
@ -31,17 +31,25 @@ type Strategy struct {
|
|||
QuoteCurrencyWeight fixedpoint.Value `json:"quoteCurrencyWeight"`
|
||||
BaseCurrencies []string `json:"baseCurrencies"`
|
||||
Threshold fixedpoint.Value `json:"threshold"`
|
||||
DryRun bool `json:"dryRun"`
|
||||
// max amount to buy or sell per order
|
||||
MaxAmount fixedpoint.Value `json:"maxAmount"`
|
||||
// interval to query marketcap data from coinmarketcap
|
||||
QueryInterval types.Interval `json:"queryInterval"`
|
||||
QueryInterval types.Interval `json:"queryInterval"`
|
||||
OrderType types.OrderType `json:"orderType"`
|
||||
DryRun bool `json:"dryRun"`
|
||||
|
||||
subscribeSymbol string
|
||||
activeOrderBook *bbgo.ActiveOrderBook
|
||||
targetWeights types.ValueMap
|
||||
}
|
||||
|
||||
func (s *Strategy) Defaults() error {
|
||||
if s.OrderType == "" {
|
||||
s.OrderType = types.OrderTypeLimitMaker
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Strategy) Initialize() error {
|
||||
apiKey := os.Getenv("COINMARKETCAP_API_KEY")
|
||||
s.datasource = coinmarketcap.New(apiKey)
|
||||
|
@ -76,7 +84,6 @@ func (s *Strategy) Validate() error {
|
|||
if s.MaxAmount.Sign() < 0 {
|
||||
return fmt.Errorf("maxAmount shoud not less than 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -178,7 +185,7 @@ func (s *Strategy) generateSubmitOrders(ctx context.Context, session *bbgo.Excha
|
|||
order := types.SubmitOrder{
|
||||
Symbol: symbol,
|
||||
Side: side,
|
||||
Type: types.OrderTypeLimit,
|
||||
Type: s.OrderType,
|
||||
Quantity: quantity,
|
||||
Price: currentPrice,
|
||||
}
|
||||
|
|
|
@ -31,6 +31,13 @@ type Strategy struct {
|
|||
activeOrderBook *bbgo.ActiveOrderBook
|
||||
}
|
||||
|
||||
func (s *Strategy) Defaults() error {
|
||||
if s.OrderType == "" {
|
||||
s.OrderType = types.OrderTypeLimitMaker
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Strategy) Initialize() error {
|
||||
return nil
|
||||
}
|
||||
|
@ -61,7 +68,6 @@ func (s *Strategy) Validate() error {
|
|||
if s.MaxAmount.Sign() < 0 {
|
||||
return fmt.Errorf("maxAmount shoud not less than 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user