Skip to content

Commit

Permalink
add orderType parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
narumiruna committed Mar 3, 2023
1 parent 45da0bd commit 94b946a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion config/marketcap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 8 additions & 3 deletions pkg/strategy/marketcap/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ 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
Expand Down Expand Up @@ -77,6 +78,10 @@ func (s *Strategy) Validate() error {
return fmt.Errorf("maxAmount shoud not less than 0")
}

if s.OrderType == "" {
s.OrderType = types.OrderTypeLimitMaker
}

return nil
}

Expand Down Expand Up @@ -178,7 +183,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,
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/strategy/rebalance/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ func (s *Strategy) Validate() error {
return fmt.Errorf("maxAmount shoud not less than 0")
}

if s.OrderType == "" {
s.OrderType = types.OrderTypeLimitMaker
}

return nil
}

Expand Down

0 comments on commit 94b946a

Please sign in to comment.