mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
Merge pull request #1447 from c9s/edwin/bitget/fix-price
FIX: [bitget] fix price is zero when order not executed
This commit is contained in:
commit
a6d9b6661d
|
@ -430,6 +430,11 @@ func (o *Order) toGlobalOrder() (types.Order, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
price := o.Price
|
||||||
|
if orderType == types.OrderTypeMarket {
|
||||||
|
price = o.PriceAvg
|
||||||
|
}
|
||||||
|
|
||||||
return types.Order{
|
return types.Order{
|
||||||
SubmitOrder: types.SubmitOrder{
|
SubmitOrder: types.SubmitOrder{
|
||||||
ClientOrderID: o.ClientOrderId,
|
ClientOrderID: o.ClientOrderId,
|
||||||
|
@ -437,7 +442,7 @@ func (o *Order) toGlobalOrder() (types.Order, error) {
|
||||||
Side: side,
|
Side: side,
|
||||||
Type: orderType,
|
Type: orderType,
|
||||||
Quantity: qty,
|
Quantity: qty,
|
||||||
Price: o.PriceAvg,
|
Price: price,
|
||||||
TimeInForce: timeInForce,
|
TimeInForce: timeInForce,
|
||||||
},
|
},
|
||||||
Exchange: types.ExchangeBitget,
|
Exchange: types.ExchangeBitget,
|
||||||
|
|
|
@ -924,6 +924,7 @@ func TestOrder_toGlobalOrder(t *testing.T) {
|
||||||
// }
|
// }
|
||||||
t.Run("limit buy", func(t *testing.T) {
|
t.Run("limit buy", func(t *testing.T) {
|
||||||
newO := o
|
newO := o
|
||||||
|
newO.Price = fixedpoint.NewFromFloat(0.49998)
|
||||||
newO.OrderType = v2.OrderTypeLimit
|
newO.OrderType = v2.OrderTypeLimit
|
||||||
|
|
||||||
res, err := newO.toGlobalOrder()
|
res, err := newO.toGlobalOrder()
|
||||||
|
@ -935,7 +936,7 @@ func TestOrder_toGlobalOrder(t *testing.T) {
|
||||||
Side: types.SideTypeBuy,
|
Side: types.SideTypeBuy,
|
||||||
Type: types.OrderTypeLimit,
|
Type: types.OrderTypeLimit,
|
||||||
Quantity: newO.Size,
|
Quantity: newO.Size,
|
||||||
Price: newO.PriceAvg,
|
Price: newO.Price,
|
||||||
TimeInForce: types.TimeInForceGTC,
|
TimeInForce: types.TimeInForceGTC,
|
||||||
},
|
},
|
||||||
Exchange: types.ExchangeBitget,
|
Exchange: types.ExchangeBitget,
|
||||||
|
@ -983,6 +984,7 @@ func TestOrder_toGlobalOrder(t *testing.T) {
|
||||||
newO := o
|
newO := o
|
||||||
newO.OrderType = v2.OrderTypeLimit
|
newO.OrderType = v2.OrderTypeLimit
|
||||||
newO.Side = v2.SideTypeSell
|
newO.Side = v2.SideTypeSell
|
||||||
|
newO.Price = fixedpoint.NewFromFloat(0.48710)
|
||||||
|
|
||||||
res, err := newO.toGlobalOrder()
|
res, err := newO.toGlobalOrder()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
@ -993,7 +995,7 @@ func TestOrder_toGlobalOrder(t *testing.T) {
|
||||||
Side: types.SideTypeSell,
|
Side: types.SideTypeSell,
|
||||||
Type: types.OrderTypeLimit,
|
Type: types.OrderTypeLimit,
|
||||||
Quantity: newO.Size,
|
Quantity: newO.Size,
|
||||||
Price: newO.PriceAvg,
|
Price: newO.Price,
|
||||||
TimeInForce: types.TimeInForceGTC,
|
TimeInForce: types.TimeInForceGTC,
|
||||||
},
|
},
|
||||||
Exchange: types.ExchangeBitget,
|
Exchange: types.ExchangeBitget,
|
||||||
|
|
|
@ -125,6 +125,7 @@ func TestStream(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("private test", func(t *testing.T) {
|
t.Run("private test", func(t *testing.T) {
|
||||||
|
s.SetPrivateChannelSymbols([]string{"BTCUSDT"})
|
||||||
err := s.Connect(context.Background())
|
err := s.Connect(context.Background())
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
|
|
@ -494,6 +494,8 @@ type Order struct {
|
||||||
Side v2.SideType `json:"side"`
|
Side v2.SideType `json:"side"`
|
||||||
AccBaseVolume fixedpoint.Value `json:"accBaseVolume"`
|
AccBaseVolume fixedpoint.Value `json:"accBaseVolume"`
|
||||||
PriceAvg fixedpoint.Value `json:"priceAvg"`
|
PriceAvg fixedpoint.Value `json:"priceAvg"`
|
||||||
|
// The Price field is only applicable to limit orders.
|
||||||
|
Price fixedpoint.Value `json:"price"`
|
||||||
Status v2.OrderStatus `json:"status"`
|
Status v2.OrderStatus `json:"status"`
|
||||||
CreatedTime types.MillisecondTimestamp `json:"cTime"`
|
CreatedTime types.MillisecondTimestamp `json:"cTime"`
|
||||||
UpdatedTime types.MillisecondTimestamp `json:"uTime"`
|
UpdatedTime types.MillisecondTimestamp `json:"uTime"`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user