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 hashes)

Uploaded Python 3

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