This commit is contained in:
chiahung.lin 2023-12-07 11:29:42 +08:00
parent 2982be1cbc
commit 6857734282
2 changed files with 2 additions and 3 deletions

View File

@ -45,7 +45,6 @@ func getBestPriceUntilSuccess(ctx context.Context, ex types.Exchange, symbol str
} }
func (s *Strategy) generateOpenPositionOrders(short bool, budget, price, priceDeviation fixedpoint.Value, maxOrderNum int64) ([]types.SubmitOrder, error) { func (s *Strategy) generateOpenPositionOrders(short bool, budget, price, priceDeviation fixedpoint.Value, maxOrderNum int64) ([]types.SubmitOrder, error) {
// TODO: not implement short part yet
factor := fixedpoint.One.Sub(priceDeviation) factor := fixedpoint.One.Sub(priceDeviation)
if short { if short {
factor = fixedpoint.One.Add(priceDeviation) factor = fixedpoint.One.Add(priceDeviation)
@ -67,7 +66,7 @@ func (s *Strategy) generateOpenPositionOrders(short bool, budget, price, priceDe
notional, orderNum := calculateNotionalAndNum(s.Market, short, budget, prices) notional, orderNum := calculateNotionalAndNum(s.Market, short, budget, prices)
if orderNum == 0 { if orderNum == 0 {
return nil, fmt.Errorf("failed to calculate DCA maker order notional and num, price: %s, budget: %s", price, budget) return nil, fmt.Errorf("failed to calculate notional and num of open position orders, price: %s, budget: %s", price, budget)
} }
var submitOrders []types.SubmitOrder var submitOrders []types.SubmitOrder

View File

@ -39,7 +39,7 @@ func newTestStrategy(va ...string) *Strategy {
return s return s
} }
func TestGenerateMakerOrder(t *testing.T) { func TestGenerateOpenPositionOrders(t *testing.T) {
assert := assert.New(t) assert := assert.New(t)
strategy := newTestStrategy() strategy := newTestStrategy()