mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-14 11:03:53 +00:00
move to convert.go
This commit is contained in:
parent
d1c5671a83
commit
2bbaf48057
|
@ -371,3 +371,20 @@ func convertWithdrawStatusV2(state max.WithdrawState) types.WithdrawStatus {
|
||||||
return types.WithdrawStatus(state)
|
return types.WithdrawStatus(state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func convertDepth(symbol string, depth *v3.Depth) (snapshot types.SliceOrderBook, finalUpdateID int64, err error) {
|
||||||
|
snapshot.Symbol = symbol
|
||||||
|
snapshot.Time = time.Unix(depth.Timestamp, 0)
|
||||||
|
snapshot.LastUpdateId = depth.LastUpdateId
|
||||||
|
|
||||||
|
finalUpdateID = depth.LastUpdateId
|
||||||
|
for _, entry := range depth.Bids {
|
||||||
|
snapshot.Bids = append(snapshot.Bids, types.PriceVolume{Price: entry[0], Volume: entry[1]})
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, entry := range depth.Asks {
|
||||||
|
snapshot.Asks = append(snapshot.Asks, types.PriceVolume{Price: entry[0], Volume: entry[1]})
|
||||||
|
}
|
||||||
|
|
||||||
|
return snapshot, finalUpdateID, err
|
||||||
|
}
|
||||||
|
|
|
@ -1147,23 +1147,6 @@ func (e *Exchange) QueryDepth(ctx context.Context, symbol string, limit int) (sn
|
||||||
return convertDepth(symbol, depth)
|
return convertDepth(symbol, depth)
|
||||||
}
|
}
|
||||||
|
|
||||||
func convertDepth(symbol string, depth *v3.Depth) (snapshot types.SliceOrderBook, finalUpdateID int64, err error) {
|
|
||||||
snapshot.Symbol = symbol
|
|
||||||
snapshot.Time = time.Unix(depth.Timestamp, 0)
|
|
||||||
snapshot.LastUpdateId = depth.LastUpdateId
|
|
||||||
|
|
||||||
finalUpdateID = depth.LastUpdateId
|
|
||||||
for _, entry := range depth.Bids {
|
|
||||||
snapshot.Bids = append(snapshot.Bids, types.PriceVolume{Price: entry[0], Volume: entry[1]})
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, entry := range depth.Asks {
|
|
||||||
snapshot.Asks = append(snapshot.Asks, types.PriceVolume{Price: entry[0], Volume: entry[1]})
|
|
||||||
}
|
|
||||||
|
|
||||||
return snapshot, finalUpdateID, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var Two = fixedpoint.NewFromInt(2)
|
var Two = fixedpoint.NewFromInt(2)
|
||||||
|
|
||||||
func (e *Exchange) QueryAveragePrice(ctx context.Context, symbol string) (fixedpoint.Value, error) {
|
func (e *Exchange) QueryAveragePrice(ctx context.Context, symbol string) (fixedpoint.Value, error) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user