add orderType parameter

This commit is contained in:
narumi 2023-03-03 23:14:30 +08:00
parent 45da0bd4c7
commit 94b946a993
3 changed files with 14 additions and 4 deletions

View File

@ -22,5 +22,6 @@ exchangeStrategies:
threshold: 1% threshold: 1%
# max amount to buy or sell per order # max amount to buy or sell per order
maxAmount: 1_000 maxAmount: 1_000
dryRun: true
queryInterval: 1h queryInterval: 1h
orderType: LIMIT_MAKER # LIMIT_MAKER, LIMIT, MARKET
dryRun: true

View File

@ -31,11 +31,12 @@ type Strategy struct {
QuoteCurrencyWeight fixedpoint.Value `json:"quoteCurrencyWeight"` QuoteCurrencyWeight fixedpoint.Value `json:"quoteCurrencyWeight"`
BaseCurrencies []string `json:"baseCurrencies"` BaseCurrencies []string `json:"baseCurrencies"`
Threshold fixedpoint.Value `json:"threshold"` Threshold fixedpoint.Value `json:"threshold"`
DryRun bool `json:"dryRun"`
// max amount to buy or sell per order // max amount to buy or sell per order
MaxAmount fixedpoint.Value `json:"maxAmount"` MaxAmount fixedpoint.Value `json:"maxAmount"`
// interval to query marketcap data from coinmarketcap // 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 subscribeSymbol string
activeOrderBook *bbgo.ActiveOrderBook activeOrderBook *bbgo.ActiveOrderBook
@ -77,6 +78,10 @@ func (s *Strategy) Validate() error {
return fmt.Errorf("maxAmount shoud not less than 0") return fmt.Errorf("maxAmount shoud not less than 0")
} }
if s.OrderType == "" {
s.OrderType = types.OrderTypeLimitMaker
}
return nil return nil
} }
@ -178,7 +183,7 @@ func (s *Strategy) generateSubmitOrders(ctx context.Context, session *bbgo.Excha
order := types.SubmitOrder{ order := types.SubmitOrder{
Symbol: symbol, Symbol: symbol,
Side: side, Side: side,
Type: types.OrderTypeLimit, Type: s.OrderType,
Quantity: quantity, Quantity: quantity,
Price: currentPrice, Price: currentPrice,
} }

View File

@ -62,6 +62,10 @@ func (s *Strategy) Validate() error {
return fmt.Errorf("maxAmount shoud not less than 0") return fmt.Errorf("maxAmount shoud not less than 0")
} }
if s.OrderType == "" {
s.OrderType = types.OrderTypeLimitMaker
}
return nil return nil
} }