mirror of
https://github.com/c9s/bbgo.git
synced 2024-09-20 08:11:08 +00:00
max: fix order symbol convertion
This commit is contained in:
parent
573a082391
commit
94bb7f5dac
|
@ -191,7 +191,6 @@ func (e *Exchange) SubmitOrders(ctx context.Context, orders ...types.SubmitOrder
|
||||||
return createdOrders, errors.New("returned nil order")
|
return createdOrders, errors.New("returned nil order")
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Infof("order created: %+v", retOrder)
|
|
||||||
createdOrder, err := toGlobalOrder(*retOrder)
|
createdOrder, err := toGlobalOrder(*retOrder)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return createdOrders, err
|
return createdOrders, err
|
||||||
|
|
|
@ -191,7 +191,7 @@ func toGlobalOrderUpdate(u max.OrderUpdate) (*types.Order, error) {
|
||||||
return &types.Order{
|
return &types.Order{
|
||||||
SubmitOrder: types.SubmitOrder{
|
SubmitOrder: types.SubmitOrder{
|
||||||
ClientOrderID: u.ClientOID,
|
ClientOrderID: u.ClientOID,
|
||||||
Symbol: u.Market,
|
Symbol: toGlobalSymbol(u.Market),
|
||||||
Side: toGlobalSideType(u.Side),
|
Side: toGlobalSideType(u.Side),
|
||||||
Type: toGlobalOrderType(u.OrderType),
|
Type: toGlobalOrderType(u.OrderType),
|
||||||
Quantity: util.MustParseFloat(u.Volume),
|
Quantity: util.MustParseFloat(u.Volume),
|
||||||
|
@ -199,6 +199,7 @@ func toGlobalOrderUpdate(u max.OrderUpdate) (*types.Order, error) {
|
||||||
StopPrice: util.MustParseFloat(u.StopPrice),
|
StopPrice: util.MustParseFloat(u.StopPrice),
|
||||||
TimeInForce: "GTC", // MAX only supports GTC
|
TimeInForce: "GTC", // MAX only supports GTC
|
||||||
},
|
},
|
||||||
|
Exchange: "max",
|
||||||
OrderID: u.ID,
|
OrderID: u.ID,
|
||||||
Status: toGlobalOrderStatus(u.State, executedVolume, remainingVolume),
|
Status: toGlobalOrderStatus(u.State, executedVolume, remainingVolume),
|
||||||
ExecutedQuantity: executedVolume.Float64(),
|
ExecutedQuantity: executedVolume.Float64(),
|
||||||
|
|
|
@ -50,7 +50,6 @@ type Strategy struct {
|
||||||
ewma *indicator.EWMA
|
ewma *indicator.EWMA
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (s *Strategy) updateOrders(orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) {
|
func (s *Strategy) updateOrders(orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) {
|
||||||
if err := session.Exchange.CancelOrders(context.Background(), s.activeOrders.Bids.Orders()...); err != nil {
|
if err := session.Exchange.CancelOrders(context.Background(), s.activeOrders.Bids.Orders()...); err != nil {
|
||||||
log.WithError(err).Errorf("cancel order error")
|
log.WithError(err).Errorf("cancel order error")
|
||||||
|
@ -65,18 +64,14 @@ func (s *Strategy) updateBidOrders(orderExecutor bbgo.OrderExecutor, session *bb
|
||||||
|
|
||||||
balance, ok := balances[quoteCurrency]
|
balance, ok := balances[quoteCurrency]
|
||||||
if !ok || balance.Available <= 0.0 {
|
if !ok || balance.Available <= 0.0 {
|
||||||
return
|
log.Infof("insufficient balance of %s: %f", quoteCurrency, balance)
|
||||||
}
|
|
||||||
|
|
||||||
var numOrders = s.GridNum - s.activeOrders.NumOfBids()
|
|
||||||
if numOrders <= 0 {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var startPrice = s.ewma.Last() * s.Percentage
|
var startPrice = s.ewma.Last() * s.Percentage
|
||||||
|
|
||||||
var submitOrders []types.SubmitOrder
|
var submitOrders []types.SubmitOrder
|
||||||
for i := 0; i < numOrders; i++ {
|
for i := 0; i < s.GridNum; i++ {
|
||||||
submitOrders = append(submitOrders, types.SubmitOrder{
|
submitOrders = append(submitOrders, types.SubmitOrder{
|
||||||
Symbol: s.Symbol,
|
Symbol: s.Symbol,
|
||||||
Side: types.SideTypeBuy,
|
Side: types.SideTypeBuy,
|
||||||
|
@ -116,9 +111,6 @@ func (s *Strategy) orderUpdateHandler(order types.Order) {
|
||||||
|
|
||||||
case types.OrderStatusPartiallyFilled:
|
case types.OrderStatusPartiallyFilled:
|
||||||
s.activeOrders.Add(order)
|
s.activeOrders.Add(order)
|
||||||
|
|
||||||
default:
|
|
||||||
s.activeOrders.Add(order)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user