Skip to main content

Api of hft

Project description

Exchanges

A small library for apis of huobi and ftx.

Installation

pip install 

Get started

There are ony 2 apis available right now Huobi, Ftx

how to work with Huobi

from huobi import Huobis

huobi = Huobi('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')

# Get all accounts list
accounts = huobi.get_accounts()

if accounts.get('status') == 'ok':
    spot_account = list(filter(lambda i: i['type'] == 'spot', accounts.get('data')))[0]

    huobi.change_account_id(spot_account.get('id'))

# Get open orders
open_orders = huobi.get_open_orders()

# Cancel order by id
cancel_response = huobi.cancel_order('596827573398451')

# Get symbols list
symbols = huobi.get_symbols()

# Get klines list
klines = huobi.get_klines('btcusdt')

# Get balances
balances = huobi.get_balances()

# Place limit order
limit_order_response = huobi.place_order(
    amount=101,
    symbol='trxusdt',
    price=0.05,
    type='buy-limit'
)

# Place marker order
market_order_response = huobi.place_order(
    amount=1,
    symbol='trxusdt',
    type='buy-market'
)

How to work with FTX

from ftx import FTX
ftx = FTX('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')

# Get positions list
ftx.get_positions()

# Get account information
ftx.get_account_information()

# Get account balances list
ftx.get_balances()

# Get all open orders
ftx.get_open_orders()

# Get all open orders for "ETH-PERP"
ftx.get_open_orders("ETH-PERP")

# Get orders history
ftx.get_orders_history()

# Get orders history for "ETH-PERP"
ftx.get_orders_history("ETH-PERP")

# Get open trigger orders
ftx.get_trigger_orders()

# Get open trigger orders for "ETH-PERP"
ftx.get_trigger_orders("ETH-PERP")

# Get all twap orders
ftx.get_twap_orders()

# Get all twap orders for "ETH-PERP"
ftx.get_twap_orders("ETH-PERP")

# Get all active twap orders for "ETH-PERP"
ftx.get_twap_orders("ETH-PERP", "running")

# Place limit order
ftx.place_order(
    market="ETH/USDT",
    side='buy',
    type='limit',
    size=1.2,
    price=1498,
    clientId="70bed756-228f-4325-8af4-3a75559cdf30"
)

# Place market order
ftx.place_order(
    market="ETH/USDT",
    side='buy',
    type='market',
    size=1.2,
    clientId="1fcf03f1-b110-46ef-9a07-be4c7c0e3a77"
)

# Place stop loss order:
ftx.place_trigger_order(
    market="ETH/USDT",
    side='sell',
    size=1.2,
    type='stop',
    triggerPrice=100,
)

# Place trailing stop order:
ftx.place_trigger_order(
    market="ETH/USDT",
    side='sell',
    size=1.2,
    type='trailingStop',
    trailValue=-0.05
)

# Place take profit order:
ftx.place_trigger_order(
    market="ETH/USDT",
    side='sell',
    size=1.2,
    type='takeProfit',
    triggerPrice=10000,
)

# Place twap order
ftx.place_twap_order(
    market="ETH/USDT",
    durationSeconds=600,
    size=1,
    side="buy"
)

Project details


Download files

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

Source Distribution

hft_api-0.1.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hft_api-0.1.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file hft_api-0.1.0.tar.gz.

File metadata

  • Download URL: hft_api-0.1.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for hft_api-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f60bd9d2359262fb6b8a2b31d4a615e84c7d9eb18a4a5f5d40b76fc2d1ebe797
MD5 7593e1eaa735aa33452c24f83c26fa14
BLAKE2b-256 40f6999f0e6afd2bc8d5792283adda697f4225fa73db1b704007020954074cc9

See more details on using hashes here.

File details

Details for the file hft_api-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hft_api-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for hft_api-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 229ad09a0ddf97e9c312ad02d34369e7bf6fa137738d5f89c9b2fdcae1760980
MD5 0e536e8b3d6df8fc4c1d78711c5fe5e8
BLAKE2b-256 2cd26f81e6c0efaa09febb4f3c20631243458487299f30e3ff01d79d5244bd5f

See more details on using hashes here.

Supported by

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