move to convert.go

This commit is contained in:
kbearXD 2024-10-01 17:16:28 +08:00
parent d1c5671a83
commit 2bbaf48057
2 changed files with 17 additions and 17 deletions

View File

@ -371,3 +371,20 @@ func convertWithdrawStatusV2(state max.WithdrawState) types.WithdrawStatus {
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
}

View File

@ -1147,23 +1147,6 @@ func (e *Exchange) QueryDepth(ctx context.Context, symbol string, limit int) (sn
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)
func (e *Exchange) QueryAveragePrice(ctx context.Context, symbol string) (fixedpoint.Value, error) {