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