quan-digital / ftx Goto Github PK
View Code? Open in Web Editor NEWLibrary for connecting to the FTX API.
License: MIT License
Library for connecting to the FTX API.
License: MIT License
Can't cancel trigger orders with the cancel_order()
Probably need to have another function with DELETE /conditional_orders/{id}
Solved
I can't seem to get the authentication to work successfully. Is anyone else having this problem? I've attached a code example below. The api_key and api_secret I've obviously changed out but they would be copied and pasted from the key generated on my profile page. I've tried generating a new key pair and have given it all permissions but still no luck.
import ftx
api_key = 'my_api_key_pasted'
api_secret = 'my_api_secret_key_pasted'
client = ftx.FtxClient(api_key=api_key, api_secret=api_secret)
acc_info = client.get_account_info()
print(acc_info)
Traceback (most recent call last):
File "lending_history.py", line 7, in <module>
acc_info = client.get_account_info()
File "/mnt/c/Users/Username/PycharmProjects/ftx_lending/src/ftx/ftx/api.py", line 73, in wrapped
return fn(self, *args, **kwargs)
File "/mnt/c/Users/Username/PycharmProjects/ftx_lending/src/ftx/ftx/api.py", line 78, in get_account_info
return self._get(f'account')
File "/mnt/c/Users/Username/PycharmProjects/ftx_lending/src/ftx/ftx/api.py", line 20, in _get
return self._request('GET', path, params=params)
File "/mnt/c/Users/Username/PycharmProjects/ftx_lending/src/ftx/ftx/api.py", line 34, in _request
return self._process_response(response)
File "/mnt/c/Users/Username/PycharmProjects/ftx_lending/src/ftx/ftx/api.py", line 59, in _process_response
raise Exception(data['error'])
Exception: Not logged in
It's all over the news, FTX will be liquidated.
https://www.fca.org.uk/news/news-stories/information-ftx-customers
When I compare the data it gives from get_trades vs the one on the platform it doesnt match. If the trades are rare then everything is fine. As soon as there are more than 2 trades in one second it skips alot of them. Is there another way how to get all trades?
I cannot login as api and secret key
In [3]: client = ftx.FtxClient("xxx", "xxx")
In [4]: client.get_balances()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-12-84f4855be095> in <module>
----> 1 client.get_balances()
~/opt/anaconda3/lib/python3.7/site-packages/ftx/api.py in wrapped(self, *args, **kwargs)
69 raise TypeError("You must be authenticated to use this method")
70 else:
---> 71 return fn(self, *args, **kwargs)
72 return wrapped
73
~/opt/anaconda3/lib/python3.7/site-packages/ftx/api.py in get_balances(self)
164 @authentication_required
165 def get_balances(self) -> List[dict]:
--> 166 return self._get(f'wallet/balances')
167
168 @authentication_required
~/opt/anaconda3/lib/python3.7/site-packages/ftx/api.py in _get(self, path, params)
18
19 def _get(self, path: str, params: Optional[Dict[str, Any]] = None) -> Any:
---> 20 return self._request('GET', path, params=params)
21
22 def _post(self, path: str, params: Optional[Dict[str, Any]] = None) -> Any:
~/opt/anaconda3/lib/python3.7/site-packages/ftx/api.py in _request(self, method, path, **kwargs)
29 request = Request(method, self._base_url + path, **kwargs)
30 if self._api_key:
---> 31 self._sign_request(request)
32 response = self._session.send(request.prepare())
33
~/opt/anaconda3/lib/python3.7/site-packages/ftx/api.py in _sign_request(self, request)
40 if prepared.body:
41 signature_payload += prepared.body
---> 42 signature = hmac.new(self._api_secret.encode(), signature_payload, 'sha256').hexdigest()
43 request.headers['FTX-KEY'] = self._api_key
44 request.headers['FTX-SIGN'] = signature
AttributeError: 'NoneType' object has no attribute 'encode'
Parameters not up to date with https://docs.ftx.com/#place-trigger-order
cancelLimitOnTrigger
is not a valid parametertrailValue
is not sent as payload despite being in the function parameterretryUntilFilled
is missingMissing parameter on rejectOnPriceBand
as seen in the documentation for POST /orders
https://docs.ftx.com/#place-order
rejectOnPriceBand | boolean | false | optional; if the order should be rejected if its price would instead be adjusted due to price bands
All is in the title : please add ciso8601 in requirements.txt !
Thanks guys, awesome package.
"""
To send a Stop Market order, set type='stop' and supply a trigger_price
To send a Stop Limit order, also supply a limit_price
To send a Take Profit Market order, set type='trailing_stop' and supply a trigger_price
To send a Trailing Stop order, set type='trailing_stop' and supply a trail_value
"""
This is commented in the api.py. Every way i try to post a take profit or trailing stop or even a stop (as a take_profit value) i receive an error, usually saying the trigger price is too high, which is not possible when putting a take profit on a long position.
Has anyone else had similar issues with placing orders?
Appreciate any suggestions. Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.