add order type to config

This commit is contained in:
narumi 2024-08-21 13:38:54 +08:00
parent 731fa9af7e
commit b820fccce1

View File

@ -31,6 +31,7 @@ type Strategy struct {
Symbol string `json:"symbol"` Symbol string `json:"symbol"`
Schedule string `json:"schedule"` Schedule string `json:"schedule"`
MinBaseBalance fixedpoint.Value `json:"minBaseBalance"` MinBaseBalance fixedpoint.Value `json:"minBaseBalance"`
OrderType types.OrderType `json:"orderType"`
PriceType types.PriceType `json:"priceType"` PriceType types.PriceType `json:"priceType"`
Bollinger *types.BollingerSetting `json:"bollinger"` Bollinger *types.BollingerSetting `json:"bollinger"`
DryRun bool `json:"dryRun"` DryRun bool `json:"dryRun"`
@ -81,6 +82,10 @@ func (s *Strategy) Validate() error {
} }
func (s *Strategy) Defaults() error { func (s *Strategy) Defaults() error {
if s.OrderType == "" {
s.OrderType = types.OrderTypeLimit
}
if s.PriceType == "" { if s.PriceType == "" {
s.PriceType = types.PriceTypeMaker s.PriceType = types.PriceTypeMaker
} }
@ -159,7 +164,7 @@ func (s *Strategy) autobuy(ctx context.Context) {
submitOrder := types.SubmitOrder{ submitOrder := types.SubmitOrder{
Symbol: s.Symbol, Symbol: s.Symbol,
Side: side, Side: side,
Type: types.OrderTypeLimitMaker, Type: s.OrderType,
Quantity: quantity, Quantity: quantity,
Price: price, Price: price,
} }