tpodlaski / copra

Ansyncronous REST and WebSocket Python clients for the Coinbase Pro virtual currency trading platform.
MIT License
49 stars 15 forks source link

cant run the example code #9

Closed fahadshery closed 4 years ago

fahadshery commented 4 years ago

Description

Testing to see if it works

What I Did

import asyncio

from copra.rest import Client

loop = asyncio.get_event_loop()

client = Client(loop)

async def get_stats():
    btc_stats = await client.get_24hour_stats('BTC-USD')
    print(btc_stats)

loop.run_until_complete(get_stats())
loop.run_until_complete(client.close())

What is the output

getting the following error:

Traceback (most recent call last):
  File "/Users/Fahad/GitLab/fuse/src/copra_cbp.py", line 13, in <module>
    loop.run_until_complete(get_stats())
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/Users/Fahad/GitLab/fuse/src/copra_cbp.py", line 10, in get_stats
    btc_stats = await client.get_24hour_stats('BTC-USD')
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/copra/rest/client.py", line 665, in get_24hour_stats
    headers, body = await self.get('/products/{}/stats'.format(product_id))
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/copra/rest/client.py", line 267, in get
    resp = await self.session.get(url, headers=req_headers)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aiohttp/client.py", line 480, in _request
    conn = await self._connector.connect(
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aiohttp/connector.py", line 523, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aiohttp/connector.py", line 858, in _create_connection
    _, proto = await self._create_direct_connection(
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aiohttp/connector.py", line 1004, in _create_direct_connection
    raise last_exc
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aiohttp/connector.py", line 980, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aiohttp/connector.py", line 938, in _wrap_create_connection
    raise ClientConnectorCertificateError(
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host api.pro.coinbase.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')]
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x106369f70>

Process finished with exit code 1
fahadshery commented 4 years ago

it was a Mac issue. so resolved