From bf73def701c76f4d183a6899843ce8a92979d250 Mon Sep 17 00:00:00 2001 From: c9s Date: Sun, 30 May 2021 23:32:01 +0800 Subject: [PATCH] binance: embed fixedpoint.Value into binance Balance struct --- pkg/exchange/binance/parse.go | 6 +++--- pkg/exchange/binance/stream.go | 7 ++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/pkg/exchange/binance/parse.go b/pkg/exchange/binance/parse.go index e9b0a0bda..f77ec55e5 100644 --- a/pkg/exchange/binance/parse.go +++ b/pkg/exchange/binance/parse.go @@ -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 { diff --git a/pkg/exchange/binance/stream.go b/pkg/exchange/binance/stream.go index d55675594..4ebba023c 100644 --- a/pkg/exchange/binance/stream.go +++ b/pkg/exchange/binance/stream.go @@ -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)