max: fix order symbol convertion

This commit is contained in:
c9s 2020-11-07 12:19:57 +08:00
parent 573a082391
commit 94bb7f5dac
3 changed files with 4 additions and 12 deletions

View File

@ -191,7 +191,6 @@ func (e *Exchange) SubmitOrders(ctx context.Context, orders ...types.SubmitOrder
return createdOrders, errors.New("returned nil order")
}
logger.Infof("order created: %+v", retOrder)
createdOrder, err := toGlobalOrder(*retOrder)
if err != nil {
return createdOrders, err

View File

@ -191,7 +191,7 @@ func toGlobalOrderUpdate(u max.OrderUpdate) (*types.Order, error) {
return &types.Order{
SubmitOrder: types.SubmitOrder{
ClientOrderID: u.ClientOID,
Symbol: u.Market,
Symbol: toGlobalSymbol(u.Market),
Side: toGlobalSideType(u.Side),
Type: toGlobalOrderType(u.OrderType),
Quantity: util.MustParseFloat(u.Volume),
@ -199,6 +199,7 @@ func toGlobalOrderUpdate(u max.OrderUpdate) (*types.Order, error) {
StopPrice: util.MustParseFloat(u.StopPrice),
TimeInForce: "GTC", // MAX only supports GTC
},
Exchange: "max",
OrderID: u.ID,
Status: toGlobalOrderStatus(u.State, executedVolume, remainingVolume),
ExecutedQuantity: executedVolume.Float64(),

View File

@ -50,7 +50,6 @@ type Strategy struct {
ewma *indicator.EWMA
}
func (s *Strategy) updateOrders(orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) {
if err := session.Exchange.CancelOrders(context.Background(), s.activeOrders.Bids.Orders()...); err != nil {
log.WithError(err).Errorf("cancel order error")
@ -65,18 +64,14 @@ func (s *Strategy) updateBidOrders(orderExecutor bbgo.OrderExecutor, session *bb
balance, ok := balances[quoteCurrency]
if !ok || balance.Available <= 0.0 {
return
}
var numOrders = s.GridNum - s.activeOrders.NumOfBids()
if numOrders <= 0 {
log.Infof("insufficient balance of %s: %f", quoteCurrency, balance)
return
}
var startPrice = s.ewma.Last() * s.Percentage
var submitOrders []types.SubmitOrder
for i := 0; i < numOrders; i++ {
for i := 0; i < s.GridNum; i++ {
submitOrders = append(submitOrders, types.SubmitOrder{
Symbol: s.Symbol,
Side: types.SideTypeBuy,
@ -116,9 +111,6 @@ func (s *Strategy) orderUpdateHandler(order types.Order) {
case types.OrderStatusPartiallyFilled:
s.activeOrders.Add(order)
default:
s.activeOrders.Add(order)
}
}