python: parse balance borrowed

This commit is contained in:
なるみ 2022-05-16 12:23:31 +08:00
parent 1f1fcdedc4
commit 0919938d20
2 changed files with 4 additions and 4 deletions

View File

@ -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:

View File

@ -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():