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