Skip to main content

This is a library that works as a connector to Apifiny Futures OPEN API.

Project description

Apifiny Futures OPEN API Connector Python

GitHub issues GitHub forks GitHub stars GitHub license contributors PyPI PyPI - Python Version Downloads

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

apifiny_futures-1.0.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file apifiny_futures-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for apifiny_futures-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec0fd363361cc3042ea022c99dd87b5420dfd6591200e08074b44d60d325dc83
MD5 539ae9ef3771ba243d8d8fa2342aa30b
BLAKE2b-256 fbd4ebc57b971256d52f5113dc0543f1fcd4fa5f8a7db3ea21f2aa0d89a8c9e0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page