Giter VIP home page Giter VIP logo

shrimpy-dev / shrimpy-python Goto Github PK

View Code? Open in Web Editor NEW
122.0 12.0 33.0 36 KB

Shrimpy’s Developer Trading API is a unified way to integrating trading functionality across every major exchange. Collect historical market data, access real-time websockets, execute advanced trading strategies, and manage an unlimited number of users.

Home Page: https://developers.shrimpy.io

License: MIT License

Python 100.00%
python-trading-bot crypto-python cryptocurrency-market-data binance-trading-bots live-crypto-charts crypto-trading

shrimpy-python's People

Contributors

nishant-shrimpy avatar nnayudu avatar shrimpy-dev 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  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  avatar  avatar  avatar  avatar  avatar  avatar

shrimpy-python's Issues

Trouble getting Users users: {'error': 'Invalid IP address, API Key, or signature'}

I am using this code:

import shrimpy
public_key = 'xxxxxx'
secret_key = 'xxxxxxxx'
client = shrimpy.ShrimpyApiClient(public_key, secret_key)
users = client.list_users()
print("\n users: " + str(users))

Getting this error:

users: {'error': 'Invalid IP address, API Key, or signature'}

I just generated ne API keys. What am I missing?

Buy side output does not make sense

Hello. So I set my code up to execute orders on Binance US and whenever I submit an order to buy ETH for USDT the trade_status response does not make sense to me.

smart_order_response = api_client.create_trade(
            user_id,    # user_id
            account_id, # account_id
           'USDT',            # from_symbol
           'ETH',           # to_symbol
           150.27,         # amount of from_symbol
            True              # enable smart_routing
        )

I would assume that usdValue in 'fills' should sum up close to 150.27. I don not understand why it would not. And when I check my balance after the trade completed the actual amount transfered is 142.87 and I dont see that number in the trade_status response and even nativeValue is wayoff from what I expected.

{'trade': {'amount': '150.2700000000000000',
  'errorCode': 0,
  'errorMessage': '',
  'fromSymbol': 'USDT',
  'id': 'd8e18bd7-60df-49a9-94f7-6d3b7eac457b',
  'status': 'started',
  'success': False,
  'toSymbol': 'ETH',
  'exchangeApiErrors': [],
  'maxSpreadPercent': '10',
  'maxSlippagePercent': '10',
  'smartRouting': True,
  'triggeredMaxSlippage': False,
  'triggeredMaxSpread': False},
 'changes': [{'symbol': 'ETH',
   'nativeValue': '0.01719',
   'btcValue': 0.0006986328338995042,
   'usdValue': 23.8248243},
  {'symbol': 'USDT',
   'nativeValue': '-23.8212144',
   'btcValue': -0.0006986328338995042,
   'usdValue': -23.8248243}],
 'fills': [{'side': 'BUY',
   'baseSymbol': 'ETH',
   'quoteSymbol': 'USDT',
   'baseAmount': '0.0086',
   'quoteAmount': '11.917536',
   'price': '1386.61',
   'usdValue': 11.919342,
   'btcValue': 0.00034951962603465593},
  {'side': 'BUY',
   'baseSymbol': 'ETH',
   'quoteSymbol': 'USDT',
   'baseAmount': '0.00859',
   'quoteAmount': '11.9036784',
   'price': '1386.61',
   'usdValue': 11.905482300000001,
   'btcValue': 0.00034911320786484823}]}

I would like to avoid hitting the balance endpoint after every trade to see what was the actual amount transfered from coin to coin. I am sure there is detail I missing. Looking forward to any help.

asyncio.Task.all_tasks() => asyncio.all_tasks()

Hi - I am having an error when I try using the websocket functionality. Below is the code I am running (used in your readme), and am getting an asyncio error, one that has been solved for other products. Looks like you have a depreciated method call asyncio.Task.all_tasks() which should be asyncio.all_tasks(). Should be an easy update to the shrimpy_ws_client.py file, line 92.

client = shrimpy.ShrimpyApiClient(public_key, private_key)


# This is a sample handler, it simply prints the incoming message to the console
def error_handler(err):
    print(err)


# This is a sample handler, it simply prints the incoming message to the console
def handler(msg):
    print(msg)

raw_token = client.get_token()
ws_client = shrimpy.ShrimpyWsClient(error_handler, raw_token['token'])

subscribe_data = {
    "type": "subscribe",
    "exchange": "coinbasepro",
    "pair": "ltc-btc",
    "channel": "orderbook"
}

# Start processing the Shrimpy websocket stream!
ws_client.connect()
ws_client.subscribe(subscribe_data, handler)

Python 3.9 support

Currently Shrimpy doesn't support Python 3.9. I am running v3.9.6 and I am getting this error
AttributeError: type object '_asyncio.Task' has no attribute 'all_tasks'
That's because asyncio.Task.all_tasks() is fully moved to asyncio.all_tasks() starting with 3.9
This has already reported at #16 , #10 and #4

Even after changing asyncio.Task.all_tasks(): to asyncio.all_tasks(): in line 92 in "shrimpy_ws_client.py" I am getting this error
RuntimeError: no running event loop

I will debug and will hopefully raise a backward compatible PR like jupyterhub/jupyterhub#3298

Only BTC/ETH pair available for trading?

Hello,

I followed this blog post to build a crypto trading bot in python leveraging shrimpy-python api. I connect to Binance US for executing trades.

I tried to trade BTC/USDT or ETH/USDT and every time the trade ends being BTC/ETH. I tried trading BTC and ETH for other coins like USDC, UNI, etc and always would get the response below. I tried enabling smart routing, but that made no difference.

In shrimpy tutorials and in all python code examples I only seen BTC/ETH pair being traded. So I wonder if that has to do with Binance US or is it actually related to Shrimpy API?

Also, It says the trade size is too small which is strange because below I tried to trade $120 ETH for USDC. The API then is changing my trade to make it $4 and instead of USDC or any other coin I get BTC. Would really appreciate any pointers that will allow my bot to trade different coins. Thank you!

(I have bought the Shrimpy subscription for 1 year)

{
   "trade":{
      "amount":"0.0038358700000000",
      "errorCode":1101,
      "errorMessage":"Trade Size Too Small",
      "fromSymbol":"ETH",
      "id":"83fb0a84-ce95-4531-aef6-b0133a95ac9b",
      "status":"completed",
      "success":false,
      "toSymbol":"USDC",
      "exchangeApiErrors":[
         
      ],
      "maxSpreadPercent":"10",
      "maxSlippagePercent":"10",
      "smartRouting":false,
      "triggeredMaxSlippage":false,
      "triggeredMaxSpread":false
   },
   "changes":[
      {
         "symbol":"ETH",
         "nativeValue":"-0.003",
         "btcValue":-0.00012272280111725532,
         "usdValue":-3.8210100000000002
      },
      {
         "symbol":"BTC",
         "nativeValue":"0.00012278",
         "btcValue":0.00012272280111725532,
         "usdValue":3.8210100000000002
      }
   ],
   "fills":[
      {
         "side":"SELL",
         "baseSymbol":"ETH",
         "quoteSymbol":"BTC",
         "baseAmount":"0.003",
         "quoteAmount":"0.00012278",
         "price":"0.040929",
         "usdValue":3.8210100000000002,
         "btcValue":0.00012272280111725532
      }
   ]
}

timezone problem

while using get_candles function noticed that i can't specify timezone which is GMT by default. Is there way to set a custom timezone?

get token part cost credits ?

Hi, in the documentation, it said get token costs credits.

Using WebSocket needs to pay some money?

and sometimes streaming doesn't work and suddenly works again. Do you know the reason for this?

Error on first run, my keys inserted for the demo values

sorry if I am doing this wrong, it's my first time reporting an issue with github.

After substituting my own keys for what the demo provided, and running the script, I get this output:

python3.8 "/home/.../shrimpy.py"
Traceback (most recent call last):
File "/home/...y/shrimpy.py", line 1, in
import shrimpy
File "/home/.../shrimpy.py", line 7, in
client = shrimpy.ShrimpyApiClient(public_key, secret_key)
AttributeError: partially initialized module 'shrimpy' has no attribute 'ShrimpyApiClient' (most likely due to a circular import)

Searching for the error did not give me anything I could understand. My intention here is to practice and expand my newly acquired noob skill using python for data science with data that interests my son, who is a noob cryptocoin investor. (I have just begun my 3rd semester at BYU-I online seeking Applied Science degree)

Thanks in advance for any help!

-Doris

AttributeError: type object '_asyncio.Task' has no attribute 'all_tasks'

I've been trying to get it working but no luck.. I'm not sure what the problem is. Can you guys check it out?

import shrimpy

shrimpy_public_key = 'aaa'
shrimpy_secret_key = 'bbb'


# This is a sample handler, it simply prints the incoming message to the console
def error_handler(err):
    print(err)


# This is a sample handler, it simply prints the incoming message to the console
def handler(msg):
    print(msg['content'][0]['price'])


api_client = shrimpy.ShrimpyApiClient(shrimpy_public_key, shrimpy_secret_key)
raw_token = api_client.get_token()
client = shrimpy.ShrimpyWsClient(error_handler, raw_token['token'])

subscribe_data = {
    "type": "subscribe",
    "exchange": "binance",
    "pair": "ltc-btc",
    "channel": "trade"
}

# Start processing the Shrimpy websocket stream!
client.connect()
client.subscribe(subscribe_data, handler)

# Once complete, stop the client
client.disconnect()
Exception in thread Thread-12:
Traceback (most recent call last):
  File "c:\users\gorke\appdata\local\programs\python\python39\lib\threading.py", line 954, in _bootstrap_inner
    self.run()
  File "c:\users\gorke\appdata\local\programs\python\python39\lib\threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\gorke\.virtualenvs\pythonProject13-jg0i1q6y\lib\site-packages\shrimpy\shrimpy_ws_client.py", line 92, in _run_socket_thread
    for task in asyncio.Task.all_tasks():
AttributeError: type object '_asyncio.Task' has no attribute 'all_tasks'

Stuck on handshake

ticker = client.get_ticker('bittrex')
stuck on.
File "/usr/lib/python3.9/ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()

AttributeError: module 'shrimpy' has no attribute 'ShrimpyApiClient'

Traceback (most recent call last):
File "C:////PycharmProjects/pythonProject/main.py", line 30, in
client = shrimpy.ShrimpyApiClient(public_key, secret_key)
AttributeError: module 'shrimpy' has no attribute 'ShrimpyApiClient'

import shrimpy
import plotly.graph_objects as go
public_key = '
secret_key =
client = shrimpy.ShrimpyApiClient(public_key, secret_key)

Encryption

It would be nice to know what encryption is done to protect the transmission of the Private key, if any. As the README.MD currently stands it is unclear if their is any protection or if the private key is being publicly being broadcasted. I didn't see any use of ssl. Is there another encryption method used? Are the Public and Private key combined so that Shrimpy decodes the Private via the Public code? Some clarity on this would would be helpful.

Invalid Nonce Error for all authenticated endpoints

Hey folks,
Just get started with shrimpy and I'm constantly getting "Invalid nonce" from all authentication end points when i use this client v0.0.15.
I'm doing nothing fancy here but just test the basic endpoints such as get_user(), list_accounts() and list_users().
Here's the screenshot. Is anyone else getting this error?
image

I'm actually getting 200 when i hit the endpoints directly from postman. Can someone comment on this?
image

bug/mismatch between documentation and output on

Hi, still me.
Just tried get_predictions('binance', 'BNB', 'BTC') and I don't get 7 objects as the documentation states but a messy 10 objects array with a few duplicates (16 twice, 17 twice, 18 twice, then the following instances just once).
See the following output.
Thanks.

{
  "predictions": [
    {
      "date": "2021-04-16T00:00:00.000Z",
      "prediction": 0.00856614,
      "updatedAt": "2021-04-15T06:48:31.000Z"
    },
    {
      "date": "2021-04-16T00:00:00.000Z",
      "prediction": 0.00926539,
      "updatedAt": "2021-04-11T06:38:25.000Z"
    },
    {
      "date": "2021-04-17T00:00:00.000Z",
      "prediction": 0.00947677,
      "updatedAt": "2021-04-11T06:38:25.000Z"
    },
    {
      "date": "2021-04-17T00:00:00.000Z",
      "prediction": 0.00856203,
      "updatedAt": "2021-04-15T06:48:31.000Z"
    },
    {
      "date": "2021-04-18T00:00:00.000Z",
      "prediction": 0.00984125,
      "updatedAt": "2021-04-11T06:38:25.000Z"
    },
    {
      "date": "2021-04-18T00:00:00.000Z",
      "prediction": 0.00856203,
      "updatedAt": "2021-04-15T06:48:31.000Z"
    },
    {
      "date": "2021-04-19T00:00:00.000Z",
      "prediction": 0.00856203,
      "updatedAt": "2021-04-15T06:48:31.000Z"
    },
    {
      "date": "2021-04-20T00:00:00.000Z",
      "prediction": 0.00856203,
      "updatedAt": "2021-04-15T06:48:31.000Z"
    },
    {
      "date": "2021-04-21T00:00:00.000Z",
      "prediction": 0.00856203,
      "updatedAt": "2021-04-15T06:48:31.000Z"
    },
    {
      "date": "2021-04-22T00:00:00.000Z",
      "prediction": 0.00856203,
      "updatedAt": "2021-04-15T06:48:31.000Z"
    }
  ]
}

client.disconnect() not closing gracefully

When client.disconnect() is called, an exception is raised:

Exception in thread Thread-1: Traceback (most recent call last): File "C:\Users\theco\AppData\Local\Programs\Python\Python39\lib\threading.py", line 950, in _bootstrap_inner self.run() File "C:\Users\theco\AppData\Local\Programs\Python\Python39\lib\threading.py", line 888, in run self._target(*self._args, **self._kwargs) File "C:\Users\theco\AppData\Local\Programs\Python\Python39\lib\site-packages\shrimpy\shrimpy_ws_client.py", line 92, in _run_socket_thread for task in asyncio.Task.all_tasks(): AttributeError: type object '_asyncio.Task' has no attribute 'all_tasks'

Any help on this?

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.