mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +00:00
binance: embed fixedpoint.Value into binance Balance struct
This commit is contained in:
parent
e3473572e9
commit
bf73def701
|
@ -220,9 +220,9 @@ outboundAccountInfo
|
|||
|
||||
*/
|
||||
type Balance struct {
|
||||
Asset string `json:"a"`
|
||||
Free string `json:"f"`
|
||||
Locked string `json:"l"`
|
||||
Asset string `json:"a"`
|
||||
Free fixedpoint.Value `json:"f"`
|
||||
Locked fixedpoint.Value `json:"l"`
|
||||
}
|
||||
|
||||
type OutboundAccountPositionEvent struct {
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/adshao/go-binance/v2"
|
||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||
"github.com/gorilla/websocket"
|
||||
|
||||
"github.com/c9s/bbgo/pkg/types"
|
||||
|
@ -134,12 +133,10 @@ func NewStream(client *binance.Client) *Stream {
|
|||
stream.OnOutboundAccountPositionEvent(func(e *OutboundAccountPositionEvent) {
|
||||
snapshot := types.BalanceMap{}
|
||||
for _, balance := range e.Balances {
|
||||
available := fixedpoint.Must(fixedpoint.NewFromString(balance.Free))
|
||||
locked := fixedpoint.Must(fixedpoint.NewFromString(balance.Locked))
|
||||
snapshot[balance.Asset] = types.Balance{
|
||||
Currency: balance.Asset,
|
||||
Available: available,
|
||||
Locked: locked,
|
||||
Available: balance.Free,
|
||||
Locked: balance.Locked,
|
||||
}
|
||||
}
|
||||
stream.EmitBalanceSnapshot(snapshot)
|
||||
|
|
Loading…
Reference in New Issue
Block a user