GithubHelp home page GithubHelp logo

coinbase / coinbase-advanced-py Goto Github PK

View Code? Open in Web Editor NEW
66.0 66.0 19.0 3.12 MB

The Advanced API Python SDK is a Python package that makes it easy to interact with the Coinbase Advanced API. The SDK handles authentication, HTTP connections, and provides helpful methods for interacting with the API.

Home Page: https://docs.cloud.coinbase.com/advanced-trade-api

License: Apache License 2.0

Makefile 0.06% Python 99.94%

coinbase-advanced-py's People

Contributors

davidmkcb avatar dependabot[bot] avatar urischwartz-cb 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

coinbase-advanced-py's Issues

Test Issue

Opening a test issue to test workflow actions

Potential issue with shipped requirements.txt

Console history is as follows

 1030  python3 -m venv coinbase_rest_testing
 1031  source coinbase_rest_testing/bin/activate
 1032  python3 -m pip install -r requirements.txt
 1033  pip install .
 1034  ipython
 1035  vi requirements.txt
 1036  pip install jwt
 1037  ipython

In [2]: from coinbase.rest import RESTClient
   ...: 
   ...: client = RESTClient(api_key=privkey, api_secret=secret)
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[2], line 1
----> 1 from coinbase.rest import RESTClient
      3 client = RESTClient(api_key=privkey, api_secret=secret)

File ~/dev/coinbase-advanced-py/coinbase/rest/__init__.py:1
----> 1 from .rest_base import RESTBase
      4 class RESTClient(RESTBase):
      5     from .accounts import get_account, get_accounts

File ~/dev/coinbase-advanced-py/coinbase/rest/rest_base.py:8
      5 import requests
      6 from requests.exceptions import HTTPError
----> 8 from coinbase import jwt_generator
      9 from coinbase.__version__ import __version__
     10 from coinbase.constants import API_ENV_KEY, API_SECRET_ENV_KEY, BASE_URL

File ~/dev/coinbase-advanced-py/coinbase/jwt_generator.py:3
      1 import time
----> 3 import jwt
      4 from cryptography.hazmat.primitives import serialization
      6 from coinbase.constants import BASE_URL, REST_SERVICE, WS_SERVICE

ModuleNotFoundError: No module named 'jwt'

Same output both times in my ipython console. The pip installations were successful. There is a problem with the jwt import on a fresh install and virtual environment.

Output from pip freeze:

(coinbase_rest_testing) llinsky@localhost coinbase-advanced-py % pip freeze
black==23.11.0
certifi==2023.11.17
cffi==1.16.0
charset-normalizer==3.3.2
click==8.1.7
coinbase-advanced-py @ file:///Users/<>/coinbase-advanced-py
cryptography==41.0.7
idna==3.6
isort==5.12.0
jwt==1.3.1
mypy-extensions==1.0.0
packaging==23.2
pathspec==0.11.2
platformdirs==4.1.0
pycparser==2.21
PyJWT==2.8.0
requests==2.31.0
urllib3==2.1.0

Advanced Trade Sandbox

Hi @urischwartz-cb - I know this isn't an issue on this project, but I've had a really hard time finding information about this. Is there a sandbox in development for the advanced trade API? I know there are some preview methods, but it would be great to have a place to actually play with this (outside of production). Thanks!

Frequent 401 Unauthorized Client Errors

When attempting to use the SDK by calling any of the rest functions ("get_products" for example), sometimes the correct response will be returned, but usually a HTTPError exception occurs with the following: "401 Client Error: Unauthorized Unauthorized". I'm using the proper API keys and the issue seems to be server side with the inconsistent responses.

Unreviewed commit on master!

Unreviewed commit(s) COMPARE was merged to master by urischwartz-cb.

Comment with appropriate number of ๐Ÿ‘ to approve.


Reviewed requirements satisfied? No
Ancestors reviewed? Yes

Is max_floor still supported?

I'm seeing an error from the backend. The max_floor parameter was recently added to the Coinbase Pro API, and it still exists in the documentation, so I'm surprised it doesn't seem to be supported in this library or on the back-end.

I get this error:

client.limit_order_gtc_buy(client_order_id="my_order_id_1000001", product_id="SOL-USD", base_size="6000", limit_price="114", post_only=True, max_floor="650")
raise HTTPError(http_error_msg, response=response)
requests.exceptions.HTTPError: 400 Client Error: Bad Request {"error":"unknown","error_details":"proto: (line 1:294): unknown field \"max_floor\"","message":"proto: (line 1:294): unknown field \"max_floor\""}

Also, does client_order_id really need to be a mandatory field?

Documentation Issue

It's not an issue with the repo, but I don't see another place to report it.

The official documentation has the on message function structured like this in a number of places on the linked page:

from coinbase.rest import WSClient

api_key = "organizations/{org_id}/apiKeys/{key_id}"
api_secret = "-----BEGIN EC PRIVATE KEY-----\nYOUR PRIVATE KEY\n-----END EC PRIVATE KEY-----\n"

def on_message(ws, message):
    print(message)

ws_client = WSClient(api_key=api_key, api_secret=api_secret, on_message=on_message, verbose=True)

The readme in this repo has the following correct code:

from coinbase.websocket import WSClient

api_key = "organizations/{org_id}/apiKeys/{key_id}"
api_secret = "-----BEGIN EC PRIVATE KEY-----\nYOUR PRIVATE KEY\n-----END EC PRIVATE KEY-----\n"

def on_message(msg):
    print(msg)

client = WSClient(api_key=api_key, api_secret=api_secret, on_message=on_message)

Missing MyPy compatible type annotations

Hello. It seems like there are no MyPy compatible type annotations provided by this package. Is that correct? IMO this is really important to support. If I run mypy on my code, it shows error: Skipping analyzing "coinbase": module is installed, but missing library stubs or py.typed marker [import-untyped] as well as note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports. If types are provided, and I'm just not using them right I will seek help elsewhere, I just wanted to get clarity on if they are provided or not and request that this be added if they are not.

I also believe it is important not just to provide a best guess of type stubs but to actually use types internally in the project and have them automatically statically validated to help keep them as accurate as possible.

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.