Merge pull request #1325 from zenixls2/fix/listenkeyexpired

This commit is contained in:
c9s 2023-09-27 22:46:44 +08:00 committed by GitHub
commit 2058ce808b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 8 deletions

View File

@ -18,7 +18,7 @@ import (
type EventBase struct {
Event string `json:"e"` // event name
Time int64 `json:"E"` // event time
Time types.MillisecondTimestamp `json:"E"` // event time
}
/*
@ -461,7 +461,7 @@ func (e *DepthEvent) String() (o string) {
func (e *DepthEvent) OrderBook() (book types.SliceOrderBook, err error) {
book.Symbol = e.Symbol
book.Time = types.NewMillisecondTimestampFromInt(e.EventBase.Time).Time()
book.Time = e.EventBase.Time.Time()
// already in descending order
book.Bids = e.Bids
@ -500,7 +500,7 @@ func parseDepthEvent(val *fastjson.Value) (*DepthEvent, error) {
var depth = &DepthEvent{
EventBase: EventBase{
Event: string(val.GetStringBytes("e")),
Time: val.GetInt64("E"),
Time: types.NewMillisecondTimestampFromInt(val.GetInt64("E")),
},
Symbol: string(val.GetStringBytes("s")),
FirstUpdateID: val.GetInt64("U"),

View File

@ -397,7 +397,7 @@ func TestParseOrderFuturesUpdate(t *testing.T) {
assert.Equal(t, "SELL", orderTradeEvent.OrderTrade.Side)
assert.Equal(t, "x-NSUYEBKMe60cf610-f5c7-49a4-9c1", orderTradeEvent.OrderTrade.ClientOrderID)
assert.Equal(t, "MARKET", orderTradeEvent.OrderTrade.OrderType)
assert.Equal(t, int64(1639933384763), orderTradeEvent.Time)
assert.Equal(t, types.NewMillisecondTimestampFromInt(1639933384763), orderTradeEvent.Time)
assert.Equal(t, types.MillisecondTimestamp(time.UnixMilli(1639933384755)), orderTradeEvent.OrderTrade.OrderTradeTime)
assert.Equal(t, fixedpoint.MustNewFromString("0.001"), orderTradeEvent.OrderTrade.OriginalQuantity)
assert.Equal(t, fixedpoint.MustNewFromString("0.001"), orderTradeEvent.OrderTrade.OrderLastFilledQuantity)

View File

@ -88,7 +88,7 @@ func NewStream(ex *Exchange, client *binance.Client, futuresClient *futures.Clie
if ok {
err := f.AddUpdate(types.SliceOrderBook{
Symbol: e.Symbol,
Time: types.NewMillisecondTimestampFromInt(e.EventBase.Time).Time(),
Time: e.EventBase.Time.Time(),
Bids: e.Bids,
Asks: e.Asks,
}, e.FirstUpdateID, e.FinalUpdateID)

View File

@ -527,8 +527,7 @@ func (s *Strategy) handleAccountUpdate(ctx context.Context, e *binance.AccountUp
if b.Asset != s.ProfitStats.FundingFeeCurrency {
continue
}
txnTime := time.UnixMilli(e.Time)
txnTime := e.EventBase.Time.Time()
fee := FundingFee{
Asset: b.Asset,
Amount: b.BalanceChange,