mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
Merge pull request #874 from ankion/fix_binance_futures
Fix binance futures
This commit is contained in:
commit
dad562db97
|
@ -41,7 +41,12 @@ func toGlobalFuturesPositions(futuresPositions []*futures.AccountPosition) types
|
|||
retFuturesPositions := make(types.FuturesPositionMap)
|
||||
for _, futuresPosition := range futuresPositions {
|
||||
retFuturesPositions[futuresPosition.Symbol] = types.FuturesPosition{ // TODO: types.FuturesPosition
|
||||
Isolated: futuresPosition.Isolated,
|
||||
Isolated: futuresPosition.Isolated,
|
||||
AverageCost: fixedpoint.MustNewFromString(futuresPosition.EntryPrice),
|
||||
ApproximateAverageCost: fixedpoint.MustNewFromString(futuresPosition.EntryPrice),
|
||||
Base: fixedpoint.MustNewFromString(futuresPosition.PositionAmt),
|
||||
Quote: fixedpoint.MustNewFromString(futuresPosition.Notional),
|
||||
|
||||
PositionRisk: &types.PositionRisk{
|
||||
Leverage: fixedpoint.MustNewFromString(futuresPosition.Leverage),
|
||||
},
|
||||
|
|
|
@ -1041,7 +1041,7 @@ func (e *Exchange) submitFuturesOrder(ctx context.Context, order types.SubmitOrd
|
|||
req.TimeInForce(futures.TimeInForceType(order.TimeInForce))
|
||||
} else {
|
||||
switch order.Type {
|
||||
case types.OrderTypeLimit, types.OrderTypeStopLimit:
|
||||
case types.OrderTypeLimit, types.OrderTypeLimitMaker, types.OrderTypeStopLimit:
|
||||
req.TimeInForce(futures.TimeInForceTypeGTC)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -268,6 +268,17 @@ func (s *Stream) handleOrderTradeUpdateEvent(e *OrderTradeUpdateEvent) {
|
|||
|
||||
s.EmitTradeUpdate(*trade)
|
||||
|
||||
order, err := e.OrderFutures()
|
||||
if err != nil {
|
||||
log.WithError(err).Error("futures order convert error")
|
||||
return
|
||||
}
|
||||
|
||||
// Update Order with FILLED event
|
||||
if order.Status == types.OrderStatusFilled {
|
||||
s.EmitOrderUpdate(*order)
|
||||
}
|
||||
|
||||
case "CALCULATED - Liquidation Execution":
|
||||
log.Infof("CALCULATED - Liquidation Execution not support yet.")
|
||||
}
|
||||
|
|
|
@ -257,8 +257,6 @@ type FuturesPosition struct {
|
|||
Isolated bool `json:"isolated"`
|
||||
UpdateTime int64 `json:"updateTime"`
|
||||
PositionRisk *PositionRisk
|
||||
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
func NewPositionFromMarket(market Market) *Position {
|
||||
|
|
Loading…
Reference in New Issue
Block a user