Files
bitfinex-api-py/bfxapi/examples/rest/transfer_wallet.py
2022-08-22 19:31:16 +02:00

52 lines
1.6 KiB
Python

import os
import sys
import asyncio
sys.path.append('../../../')
from bfxapi import Client, WS_HOST, REST_HOST
API_KEY=os.getenv("BFX_KEY")
API_SECRET=os.getenv("BFX_SECRET")
# Transfer wallet requires private hosts
bfx = Client(
API_KEY=API_KEY,
API_SECRET=API_SECRET,
logLevel='DEBUG',
ws_host=WS_HOST,
rest_host=REST_HOST
)
async def transfer_wallet():
response = await bfx.rest.submit_wallet_transfer("exchange", "margin", "BTC", "BTC", 0.1)
# response is in the form of a Notification object
# notify_info is in the form of a Transfer object
print ("Transfer: ", response.notify_info)
async def deposit_address():
response = await bfx.rest.get_wallet_deposit_address("exchange", "bitcoin")
# response is in the form of a Notification object
# notify_info is in the form of a DepositAddress object
print ("Address: ", response.notify_info)
async def create_new_address():
response = await bfx.rest.create_wallet_deposit_address("exchange", "bitcoin")
# response is in the form of a Notification object
# notify_info is in the form of a DepositAddress object
print ("Address: ", response.notify_info)
async def withdraw():
# tetheruse = Tether (ERC20)
response = await bfx.rest.submit_wallet_withdraw("exchange", "tetheruse", 5, "0xc5bbb852f82c24327693937d4012f496cff7eddf")
# response is in the form of a Notification object
# notify_info is in the form of a DepositAddress object
print ("Address: ", response.notify_info)
async def run():
await transfer_wallet()
await deposit_address()
await withdraw()
t = asyncio.ensure_future(run())
asyncio.get_event_loop().run_until_complete(t)