This is a library that works as a connector to Apifiny Futures OPEN API.
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file apifiny_futures-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: apifiny_futures-1.0.0-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec0fd363361cc3042ea022c99dd87b5420dfd6591200e08074b44d60d325dc83 |
|
MD5 | 539ae9ef3771ba243d8d8fa2342aa30b |
|
BLAKE2b-256 | fbd4ebc57b971256d52f5113dc0543f1fcd4fa5f8a7db3ea21f2aa0d89a8c9e0 |