mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
python: parse balance borrowed
This commit is contained in:
parent
1f1fcdedc4
commit
0919938d20
|
@ -14,7 +14,7 @@ class Balance:
|
|||
currency: str
|
||||
available: Decimal
|
||||
locked: Decimal
|
||||
borrowed: str
|
||||
borrowed: Decimal
|
||||
|
||||
@classmethod
|
||||
def from_pb(cls, obj: bbgo_pb2.Balance) -> Balance:
|
||||
|
@ -23,7 +23,7 @@ class Balance:
|
|||
currency=obj.currency,
|
||||
available=parse_number(obj.available),
|
||||
locked=parse_number(obj.locked),
|
||||
borrowed=obj.borrowed,
|
||||
borrowed=parse_number(obj.borrowed),
|
||||
)
|
||||
|
||||
def total(self) -> Decimal:
|
||||
|
|
|
@ -12,7 +12,7 @@ def test_balance_from_pb():
|
|||
currency = 'BTCUSDT'
|
||||
available = '3.1415926'
|
||||
locked = '2.7182818'
|
||||
borrowed = 'borrowed'
|
||||
borrowed = '0.1234567'
|
||||
|
||||
balance_pb = bbgo_pb2.Balance(
|
||||
exchange=exchange,
|
||||
|
@ -28,7 +28,7 @@ def test_balance_from_pb():
|
|||
assert balance.currency == currency
|
||||
assert balance.available == Decimal(available)
|
||||
assert balance.locked == Decimal(locked)
|
||||
assert balance.borrowed == borrowed
|
||||
assert balance.borrowed == Decimal(borrowed)
|
||||
|
||||
|
||||
def test_kline_from_pb():
|
||||
|
|
Loading…
Reference in New Issue
Block a user