Giter Site home page Giter Site logo

leechunhao2000 / ftx-api-wrapper-python3 Goto Github PK

View Code? Open in Web Editor NEW
34.0 2.0 11.0 49 KB

FTX Exchange API wrapper in python3

License: MIT License

Python 100.00%
bitcoin ftx cryptocurrency cryptocurrencies derivatives wrapper ftx-exchange python3 trades

ftx-api-wrapper-python3's Introduction

FTX-Trader

Warning

This is an UNOFFICIAL wrapper for FTX exchange HTTP API written in Python 3.7

The library can be used to fetch market data, make trades, place orders or create third-party clients

USE THIS WRAPPER AT YOUR OWN RISK, I WILL NOT CORRESPOND TO ANY LOSES

Features

  • Except OTC and Option, implementation of all public and private endpoints
  • Simple handling of authentication with API key and secret
  • For asset safety, WITHDRAWAL function will never be supported !

Donate

If useful, buy me a coffee?

  • ETH: 0x00000000051CBcE3fD04148CcE2c0adc7c651829 (brendanc.eth)

Installation

$ git clone https://github.com/LeeChunHao2000/ftx-api-wrapper-python3

Requirement

  1. Register an account with FTX exchange (referral link)
  2. Generate API key and secret, assign relevant permissions to it
  3. Clone this repository, and put in the key and secret
  4. Write your own trading policies

Quickstart

This is an introduction on how to get started with FTX client. First, make sure the FTX library is installed.

The next thing you need to do is import the library and get an instance of the client:

from FTX.client import Client
client = Client('PUY_MY_API_KEY_HERE', 'PUY_MY_API_SECRET_HERE')

Get ordedrbook

>>> from FTX.client import Client
>>> client = Client('PUY_MY_API_KEY_HERE', 'PUY_MY_API_SECRET_HERE')
>>> result = client.get_public_orderbook('BTC/USD', 1)
>>> result
{'asks': [[10854.5, 11.856]], 'bids': [[10854.0, 0.4315]]}
>>> result['asks']
[[10854.5, 11.856]]
>>> result['bids']
[[10854.0, 0.4315]]

Positions (DataFrame)

>>> import pandas as pd
>>> result = pd.DataFrame(client.get_private_account_positions())
>>> result = result.sort_values(by=['realizedPnl'], ascending=False)
>>> result
        collateralUsed      cost  entryPrice  ...  side     size  unrealizedPnl
0          0.00000     0.000         NaN  ...   buy     0.00            0.0
49         0.00000     0.000         NaN  ...   buy     0.00            0.0
4        535.09500  2972.750    594.5500  ...   buy     5.00            0.0
35       206.93750  2069.375     82.7750  ...   buy    25.00            0.0
3          0.00000     0.000         NaN  ...   buy     0.00            0.0
5        152.28000  1522.800      2.5380  ...   buy   600.00            0.0

Version Logs

2020-12-24

Bugfixes

  • Fixed a bug with function of cancel orders

Features

  • Add Spot Margin Support

2020-09-14

  • Birth!

ftx-api-wrapper-python3's People

Contributors

leechunhao2000 avatar panda850819 avatar zevaverbach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ftx-api-wrapper-python3's Issues

Introduce a "failsafe" flag for risky private operations

For any private operations which are "risky" -- meaning that they'll actually do something with assets when they're called, like buy/sell assets -- what do you think about an im_sure flag which defaults to False? And it could maybe raise an exception when it's set to False saying "Please set im_sure to True if you want this transaction to go through."

Unable to place order

I'm using the following line of code to place market order :

test = client.create_order(pair="DOGEBULL/USD",side="buy",_type="market",size=1,price=0)
The order is getting executed on my main account.
Please let me know how o place an order on a specific sub account.
Thanks!

include pagination

It seems like the default quantity per page is 100 with FTX's API -- might be good to be able to optionally get more than that.

make the API simpler

The method names are quite long and repetitive. How about cutting out the "public" and "private" names and maybe using the more semantically clear "create" in place of "set"?

add missing methods

all of the /staking endpoints are not implemented. The withdrawal and saved addresses endpoints are, I think, purposefully omitted.

I've verified that the other categories of endpoints are present, haven't checked through all these yet:

orders
fills
funding payments
leveraged tokens
options

include rate limiting

"30 requests per minute" at this moment according to the docs. Maybe have an option to either raise or enqueue operations when you hit that limit. I'd suggest doing this counting in a class attribute of Client

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.