mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-18 22:34:21 +01:00
Rename .notify_info to .data in Notification (bfxapi.notifications).
This commit is contained in:
@@ -9,13 +9,13 @@ class Notification(_Type, Generic[T]):
|
||||
mts: int
|
||||
type: str
|
||||
message_id: Optional[int]
|
||||
notify_info: T
|
||||
data: T
|
||||
code: Optional[int]
|
||||
status: str
|
||||
text: str
|
||||
|
||||
class _Notification(_Serializer, Generic[T]):
|
||||
__LABELS = [ "mts", "type", "message_id", "_PLACEHOLDER", "notify_info", "code", "status", "text" ]
|
||||
__LABELS = [ "mts", "type", "message_id", "_PLACEHOLDER", "data", "code", "status", "text" ]
|
||||
|
||||
def __init__(self, serializer: Optional[_Serializer] = None, is_iterable: bool = False):
|
||||
super().__init__("Notification", Notification, _Notification.__LABELS, IGNORE = [ "_PLACEHOLDER" ])
|
||||
@@ -26,13 +26,13 @@ class _Notification(_Serializer, Generic[T]):
|
||||
notification = cast(Notification[T], Notification(**dict(self._serialize(*values))))
|
||||
|
||||
if isinstance(self.serializer, _Serializer):
|
||||
NOTIFY_INFO = cast(List[Any], notification.notify_info)
|
||||
data = cast(List[Any], notification.data)
|
||||
|
||||
if self.is_iterable == False:
|
||||
if len(NOTIFY_INFO) == 1 and isinstance(NOTIFY_INFO[0], list):
|
||||
NOTIFY_INFO = NOTIFY_INFO[0]
|
||||
if len(data) == 1 and isinstance(data[0], list):
|
||||
data = data[0]
|
||||
|
||||
notification.notify_info = cast(T, self.serializer.klass(**dict(self.serializer._serialize(*NOTIFY_INFO, skip=skip))))
|
||||
else: notification.notify_info = cast(T, [ self.serializer.klass(**dict(self.serializer._serialize(*data, skip=skip))) for data in NOTIFY_INFO ])
|
||||
notification.data = cast(T, self.serializer.klass(**dict(self.serializer._serialize(*data, skip=skip))))
|
||||
else: notification.data = cast(T, [ self.serializer.klass(**dict(self.serializer._serialize(*sub_data, skip=skip))) for sub_data in data ])
|
||||
|
||||
return notification
|
||||
@@ -15,5 +15,5 @@ bfx = Client(
|
||||
# Claims all active positions
|
||||
for position in bfx.rest.auth.get_positions():
|
||||
notification: Notification[PositionClaim] = bfx.rest.auth.claim_position(position.position_id)
|
||||
claim: PositionClaim = notification.notify_info
|
||||
claim: PositionClaim = notification.data
|
||||
print(f"Position: {position} | PositionClaim: {claim}")
|
||||
@@ -22,23 +22,23 @@ A: Notification[Transfer] = bfx.rest.auth.transfer_between_wallets(
|
||||
from_wallet="exchange", to_wallet="funding", from_currency="ETH",
|
||||
to_currency="ETH", amount=0.001)
|
||||
|
||||
print("Transfer:", A.notify_info)
|
||||
print("Transfer:", A.data)
|
||||
|
||||
# Retrieves the deposit address for bitcoin currency in exchange wallet.
|
||||
B: Notification[DepositAddress] = bfx.rest.auth.get_deposit_address(
|
||||
wallet="exchange", method="bitcoin", renew=False)
|
||||
|
||||
print("Deposit address:", B.notify_info)
|
||||
print("Deposit address:", B.data)
|
||||
|
||||
# Generates a lightning network deposit invoice
|
||||
C: Notification[LightningNetworkInvoice] = bfx.rest.auth.generate_deposit_invoice(
|
||||
wallet="funding", currency="LNX", amount=0.001)
|
||||
|
||||
print("Lightning network invoice:", C.notify_info)
|
||||
print("Lightning network invoice:", C.data)
|
||||
|
||||
# Withdraws 1.0 UST from user's exchange wallet to address 0x742d35Cc6634C0532925a3b844Bc454e4438f44e
|
||||
D: Notification[Withdrawal] = bfx.rest.auth.submit_wallet_withdrawal(
|
||||
wallet="exchange", method="tetheruse", address="0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
|
||||
amount=1.0)
|
||||
|
||||
print("Withdrawal:", D.notify_info)
|
||||
print("Withdrawal:", D.data)
|
||||
@@ -20,7 +20,7 @@ submit_order_notification = bfx.rest.auth.submit_order(
|
||||
lev=10
|
||||
)
|
||||
|
||||
print("New Order:", submit_order_notification.notify_info)
|
||||
print("New Order:", submit_order_notification.data)
|
||||
|
||||
# Update the amount of collateral for tBTCF0:USTF0 derivative position
|
||||
derivative_position_collateral: DerivativePositionCollateral = \
|
||||
|
||||
@@ -23,7 +23,7 @@ submit_order_notification: Notification[Order] = bfx.rest.auth.submit_order(
|
||||
|
||||
print("Submit order notification:", submit_order_notification)
|
||||
|
||||
order: Order = submit_order_notification.notify_info
|
||||
order: Order = submit_order_notification.data
|
||||
|
||||
# Update its amount and its price
|
||||
update_order_notification: Notification[Order] = bfx.rest.auth.update_order(
|
||||
|
||||
Reference in New Issue
Block a user