Last updated:
0 purchases
apifinyfutures 1.0.0
Apifiny Futures OPEN API Connector Python
This is a library that works as a connector to APIFINY FUTURES OPEN API
Supported APIs:
REST trading/market API
WebSocket market API
OPEN API Documentation
https://doc.apifiny.com/futures/#introduction
Install
pip3 install -U apifiny-futures
RESTful APIs
Usage examples:
Get all supported exchanges
from apifiny_futures.rest_api import API as Client
client = Client(venue="BINANCE")
print(client.list_venue())
Get Market Data
from apifiny_futures.rest_market import MarketData as Client
client = Client()
# Get BINANCE orderbook of BTCUSDT
print(client.get_order_book("BINANCE", "BTCUSDT"))
Create Order
from apifiny_futures.rest_api import API as Client
# api key/secret are required for trade endpoints
client = Client(venue="BINANCE", key='<api_key>', secret='<api_secret>')
# Post a new order
params = {
"accountId": '<account_id>',
"venue": '<venue>',
"orderInfo":{
"symbol":"BTCUSDT",
"orderType":"TRAILING",
"timeInForce":"GTC",
"orderSide":"SELL",
"price":"100",
"qty":"0.1",
"stopPrice":"0",
"workingType":"CONTRACT_PRICE",
"positionSide":"BOTH",
"reduceOnly":"false",
"closePosition":"false",
"activationPrice":"9020",
"callbackRate":"0.1",
"priceProtect":"false"
}
}
resp = client.new_order(**params)
print(resp)
WebSocket APIs
Usage examples:
Subscribe Market Data
from apifiny_futures.fut_websocket import FutApi as Client
# Get BINANCE orderbook of BTCUSDT
msg = {"channel": "orderbook", "symbol": 'BTCUSDT', "venues": ["BINANCE"], "action": "sub"}
# Get BINANCE klines of BTCUSDT at 1m interval
# msg = {"channel": "kline_1m", "symbol": "BTCUSDT", "venues": ["BINANCE"], "action": "sub"}
client = Client()
client.connect(md=True)
client.send_msg(msg)
pushing data
from apifiny_futures.fut_websocket import FutApi as Client
# api key/secret are required for subscribe order and asset update
client = Client(venue="BINANCE")
client.connect()
client.login('<api_key_id>', '<secret_key>')
Please find examples folder to check for more endpoints.
Contributing
Contributions are welcome.
If you've found a bug within this project, please open an issue to discuss what you would like to change.
If it's an issue with the API, please report any new issues at apifiny-futures-connector-python issues
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.