csko / gdax-python-api Goto Github PK
View Code? Open in Web Editor NEWGDAX API written in Python3 using async/await
License: MIT License
GDAX API written in Python3 using async/await
License: MIT License
I'm writing a script to subscribe to the authenticated "user" channel using the code below (which used orderbook.py as its basis) and I'm passing the api_key/api_secret and passphrase through (I've redacted them in this code example)
The error I get back is:
{'message': 'Sorry, you could not be authenticated: Bad Request', 'reason': 'invalid signature', 'type': 'error'}
Any ideas ?
import asyncio
import pprint
from gdax.websocket_feed_listener import WebSocketFeedListener
class User(WebSocketFeedListener):
def __init__(self, product_ids='ETH-USD', api_key=None, api_secret=None,
passphrase=None, use_heartbeat=False,
trade_log_file_path=None):
super().__init__(product_ids=product_ids,
channels='user',
api_key=api_key,
api_secret=api_secret,
passphrase=passphrase,
use_heartbeat=use_heartbeat
)
if not isinstance(product_ids, list):
product_ids = [product_ids]
async def __aenter__(self):
await super().__aenter__()
return self
async def handle_message(self):
try:
message = await self._recv()
except aiohttp.ServerDisconnectedError as exc:
logging.error(
f'Error: Exception: f{exc}. Re-initializing websocket.')
await self.__aexit__(None, None, None)
await self.__aenter__()
return
return message
async def run_user(): # pragma: no cover
async with User(
['ETH-USD'],
api_key="XXXXXXXX",
api_secret="XXXXXXXX",
passphrase="XXXXXXXX"
) as user:
while True:
message = await user.handle_message()
if message is None:
continue
pprint.pprint(message)
if __name__ == "__main__": # pragma: no cover
loop = asyncio.get_event_loop()
loop.run_until_complete(run_user())
TypeError: object MagicMock can't be used in 'await' expression
Hi ๐
This is my first visit to this fine repo, but it seems you have been working hard to keep all dependencies updated so far.
Once you have closed this issue, I'll create separate pull requests for every update as soon as I find one.
That's it for now!
Happy merging! ๐ค
How do I get a list of open positions via the API? That is, suppose I BUY two BTC-USD at (say) $9500 and $9600, with sizes of 0.6 and 1.2 respectively. How would I a list of these open positions? The fill method gets me the full history, but it doesn't tell me which positions are still open. I need a quick way of making sure my app is in sync with the exchange... Thanks
The examples for the module show how to subscribe to a websocket for the Orderbook, and it shows you how to use the REST API interface to place an order.
However, there is no information or instructions on how to subscribe to a websocket to see the status of those orders or to receive live updates for those orders or your account. Yes, one could use the REST interface, but that doesn't inform you as and when things happen.
Hi,
I installed the API and tried to run the example code, but I keep getting the same error:
aiohttp.client_exceptions.ClientConnectorError: [Errno 1] Cannot connect to host ws-feed.gdax.com:443 ssl:True [Can not connect to ws-feed.gdax.com:443 [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)]]
Does anyone know how to fix this issue?
There is a namespace conflict between gdax-python-api
and gdax-python
. Both packages install their code under the gdax
namespace. This makes it impossible to use them in parallel
AFAIK there is no rule for handling such namespace conflicts so the resolution, if any, is completely up to you. Nevertheless IMHO it would be nice to be able to use both packages and your package is the newer one. That's why I am opening the issue here.
https://github.com/danpaquin/gdax-python
https://www.python.org/dev/peps/pep-0541/
https://www.python.org/dev/peps/pep-0423/
The buy / post functions are missing the optional post_only flag. e.g:
{ "id": "d0c5340b-6d6c-49d9-b567-48c4bfca13d2", "price": "0.10000000", "size": "0.01000000", "product_id": "BTC-USD", "side": "buy", "stp": "dc", "type": "limit", "time_in_force": "GTC", "post_only": false, "created_at": "2016-12-08T20:02:28.53864Z", "fill_fees": "0.0000000000000000", "filled_size": "0.00000000", "executed_value": "0.0000000000000000", "status": "pending", "settled": false }
As per the GDAX API docs:
'Post Only' will ensure that the order is only executed if the entire order can be posted to the order book.
If any part of the order crosses the spread to fill an existing order, an error will be displayed and the order will not be executed. This is useful for guaranteeing that the entire order is subject to a 0% maker order fee rate.
If you try to cancel an order through this API you get a 400 Bad Request error
I managed to track it down to the payload that is being used to authenticate the request. This is used to generate headers for the request.
headers = self._auth_headers(path, method='DELETE', body=json_data)
In a delete request the variable json_data is empty. I believe this is why the headers fail. By setting the json_data value to "{}" (empty json) then it works
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.