mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2026-01-06 07:24:19 +01:00
bfx_rest: add wallet address/withdraw endpoints
This commit is contained in:
@@ -13,5 +13,8 @@ from .funding_loan import FundingLoan
|
||||
from .funding_offer import FundingOffer
|
||||
from .funding_credit import FundingCredit
|
||||
from .notification import Notification
|
||||
from .transfer import Transfer
|
||||
from .deposit_address import DepositAddress
|
||||
from .withdraw import Withdraw
|
||||
|
||||
NAME = 'models'
|
||||
|
||||
42
bfxapi/models/deposit_address.py
Normal file
42
bfxapi/models/deposit_address.py
Normal file
@@ -0,0 +1,42 @@
|
||||
"""
|
||||
Module used to describe a DepositAddress object
|
||||
"""
|
||||
|
||||
class DepositModel:
|
||||
"""
|
||||
Enum used to index the location of each value in a raw array
|
||||
"""
|
||||
METHOD = 1
|
||||
CURRENCY = 2
|
||||
ADDRESS = 4
|
||||
|
||||
class DepositAddress:
|
||||
"""
|
||||
[None, 'BITCOIN', 'BTC', None, '38zsUkv8q2aiXK9qsZVwepXjWeh3jKvvZw']
|
||||
|
||||
METHOD string Protocol used for funds transfer
|
||||
SYMBOL string Currency symbol
|
||||
ADDRESS string Deposit address for funds transfer
|
||||
"""
|
||||
|
||||
def __init__(self, method, currency, address):
|
||||
self.method = method
|
||||
self.currency = currency
|
||||
self.address = address
|
||||
|
||||
@staticmethod
|
||||
def from_raw_deposit_address(raw_add):
|
||||
"""
|
||||
Parse a raw deposit object into a DepositAddress object
|
||||
|
||||
@return DepositAddress
|
||||
"""
|
||||
method = raw_add[DepositModel.METHOD]
|
||||
currency = raw_add[DepositModel.CURRENCY]
|
||||
address = raw_add[DepositModel.ADDRESS]
|
||||
return DepositAddress(method, currency, address)
|
||||
|
||||
def __str__(self):
|
||||
''' Allow us to print the Transfer object in a pretty format '''
|
||||
text = "DepositAddress <{} method={} currency={}>"
|
||||
return text.format(self.address, self.method, self.currency)
|
||||
@@ -4,6 +4,9 @@ Module used to describe all of the different notification data types
|
||||
|
||||
from .order import Order
|
||||
from .funding_offer import FundingOffer
|
||||
from .transfer import Transfer
|
||||
from .deposit_address import DepositAddress
|
||||
from .withdraw import Withdraw
|
||||
|
||||
class NotificationModal:
|
||||
"""
|
||||
@@ -34,8 +37,10 @@ class NotificationTypes:
|
||||
ORDER_UPDATED_REQ = "ou-req"
|
||||
FUNDING_OFFER_NEW = "fon-req"
|
||||
FUNDING_OFFER_CANCEL = "foc-req"
|
||||
ACCOUNT_TRANSFER = "acc_tf"
|
||||
ACCOUNT_DEPOSIT = "acc_dep"
|
||||
ACCOUNT_WITHDRAW_REQ = "acc_wd-req"
|
||||
# uca ?
|
||||
# acc_tf ?
|
||||
# pm-req ?
|
||||
|
||||
|
||||
@@ -70,11 +75,11 @@ class Notification:
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def from_raw_order(raw_notification):
|
||||
def from_raw_notification(raw_notification):
|
||||
"""
|
||||
Parse a raw order object into an Order object
|
||||
Parse a raw notification object into an Order object
|
||||
|
||||
@return Order
|
||||
@return Notification
|
||||
"""
|
||||
mts = raw_notification[NotificationModal.MTS]
|
||||
notify_type = raw_notification[NotificationModal.TYPE]
|
||||
@@ -100,6 +105,12 @@ class Notification:
|
||||
basic.notify_info = FundingOffer.from_raw_offer(basic.notify_info)
|
||||
elif basic.notify_type == NotificationTypes.FUNDING_OFFER_CANCEL:
|
||||
basic.notify_info = FundingOffer.from_raw_offer(basic.notify_info)
|
||||
elif basic.notify_type == NotificationTypes.ACCOUNT_TRANSFER:
|
||||
basic.notify_info = Transfer.from_raw_transfer(basic.notify_info)
|
||||
elif basic.notify_type == NotificationTypes.ACCOUNT_DEPOSIT:
|
||||
basic.notify_info = DepositAddress.from_raw_deposit_address(basic.notify_info)
|
||||
elif basic.notify_type == NotificationTypes.ACCOUNT_WITHDRAW_REQ:
|
||||
basic.notify_info = Withdraw.from_raw_withdraw(basic.notify_info)
|
||||
return basic
|
||||
|
||||
def __str__(self):
|
||||
|
||||
53
bfxapi/models/transfer.py
Normal file
53
bfxapi/models/transfer.py
Normal file
@@ -0,0 +1,53 @@
|
||||
"""
|
||||
Module used to describe a transfer object
|
||||
"""
|
||||
|
||||
class TransferModel:
|
||||
"""
|
||||
Enum used to index the location of each value in a raw array
|
||||
"""
|
||||
MTS = 0
|
||||
W_FROM = 1
|
||||
W_TO = 2
|
||||
C_FROM = 4
|
||||
C_TO = 5
|
||||
AMOUNT = 7
|
||||
|
||||
class Transfer:
|
||||
"""
|
||||
MTS int Millisecond Time Stamp of the update
|
||||
WALLET_FROM string Wallet name (exchange, margin, funding)
|
||||
WALLET_TO string Wallet name (exchange, margin, funding)
|
||||
CURRENCY_FROM string Currency (BTC, etc)
|
||||
CURRENCY_TO string Currency (BTC, etc)
|
||||
AMOUNT string Amount of funds to transfer
|
||||
"""
|
||||
|
||||
def __init__(self, mts, wallet_from, wallet_to, currency_from, currency_to, amount):
|
||||
self.mts = mts
|
||||
self.wallet_from = wallet_from
|
||||
self.wallet_to = wallet_to
|
||||
self.currency_from = currency_from
|
||||
self.currency_to = currency_to
|
||||
self.amount = amount
|
||||
|
||||
@staticmethod
|
||||
def from_raw_transfer(raw_transfer):
|
||||
"""
|
||||
Parse a raw transfer object into a Transfer object
|
||||
|
||||
@return Transfer
|
||||
"""
|
||||
mts = raw_transfer[TransferModel.MTS]
|
||||
wallet_from = raw_transfer[TransferModel.W_FROM]
|
||||
wallet_to = raw_transfer[TransferModel.W_TO]
|
||||
currency_from = raw_transfer[TransferModel.C_FROM]
|
||||
currency_to = raw_transfer[TransferModel.C_TO]
|
||||
amount = raw_transfer[TransferModel.AMOUNT]
|
||||
return Transfer(mts, wallet_from, wallet_to, currency_from, currency_to, amount)
|
||||
|
||||
def __str__(self):
|
||||
''' Allow us to print the Transfer object in a pretty format '''
|
||||
text = "Transfer <{} from {} ({}) to {} ({}) mts={}>"
|
||||
return text.format(self.amount, self.wallet_from, self.currency_from,
|
||||
self.wallet_to, self.currency_to, self.mts)
|
||||
51
bfxapi/models/withdraw.py
Normal file
51
bfxapi/models/withdraw.py
Normal file
@@ -0,0 +1,51 @@
|
||||
"""
|
||||
Module used to describe a withdraw object
|
||||
"""
|
||||
|
||||
class WithdrawModel:
|
||||
"""
|
||||
Enum used to index the location of each value in a raw array
|
||||
"""
|
||||
ID = 0
|
||||
METHOD = 2
|
||||
WALLET = 4
|
||||
AMOUNT = 5
|
||||
FEE = 7
|
||||
|
||||
class Withdraw:
|
||||
"""
|
||||
[13063236, None, 'tetheruse', None, 'exchange', 5, None, None, 0.00135]
|
||||
|
||||
MTS int Millisecond Time Stamp of the update
|
||||
WALLET_FROM string Wallet name (exchange, margin, funding)
|
||||
WALLET_TO string Wallet name (exchange, margin, funding)
|
||||
CURRENCY_FROM string Currency (BTC, etc)
|
||||
CURRENCY_TO string Currency (BTC, etc)
|
||||
AMOUNT string Amount of funds to transfer
|
||||
"""
|
||||
|
||||
def __init__(self, w_id, method, wallet, amount, fee=0):
|
||||
self.id = w_id
|
||||
self.method = method
|
||||
self.wallet = wallet
|
||||
self.amount = amount
|
||||
self.fee = fee
|
||||
|
||||
@staticmethod
|
||||
def from_raw_withdraw(raw_withdraw):
|
||||
"""
|
||||
Parse a raw withdraw object into a Withdraw object
|
||||
|
||||
@return Withdraw
|
||||
"""
|
||||
w_id = raw_withdraw[WithdrawModel.ID]
|
||||
method = raw_withdraw[WithdrawModel.METHOD]
|
||||
wallet = raw_withdraw[WithdrawModel.WALLET]
|
||||
amount = raw_withdraw[WithdrawModel.AMOUNT]
|
||||
return Withdraw(w_id, method, wallet, amount)
|
||||
|
||||
def __str__(self):
|
||||
''' Allow us to print the Transfer object in a pretty format '''
|
||||
text = "Withdraw <id={} from {} ({}) fee={}>"
|
||||
return text.format(self.id, self.wallet, self.method, self.amount,
|
||||
self.fee)
|
||||
Reference in New Issue
Block a user