unwitting / bitstampy Goto Github PK
View Code? Open in Web Editor NEWBitstamp API wrapper for Python
License: MIT License
Bitstamp API wrapper for Python
License: MIT License
BUY LIMIT ORDER
At the moment cannot give the currency_pair
param. For now we can only trade BTC/USD.
Still a couple of API calls which are supported but aren't listed in the README.md documentation. I've been working in the same order as the API documentation page so it's everything after the last documented one to go.
When trying to do 'from bistampy import api' i get 'ImportError: No module named calls'
A simple fix for this was to simply change the first line in api.py from 'import calls' to 'from . import calls'
maybe it's just me but:
from bitstampy import api
c='999999'
k='xXx'
s=b'xXx'
api.account_balance(c, k, s)
and I get the error:
TypeError: Unicode-objects must be encoded before hashing
on pyhton 3.4
c = '12345'
k = 'xxxxx'
s = 'yyyyy'
api.account_balance(c, k, s)
~/.virtualenvs/bitstamp/lib/python3.6/site-packages/bitstampy/api.py in account_balance(client_id, api_key, api_secret)
38 def account_balance(client_id, api_key, api_secret):
39 return (
---> 40 calls.APIAccountBalanceCall(client_id, api_key, api_secret)
41 .call()
42 )
~/.virtualenvs/bitstamp/lib/python3.6/site-packages/bitstampy/calls.py in call(self, **params)
79 message = nonce + self.client_id + self.api_key
80 signature = hmac.new(
---> 81 self.api_secret, msg=message, digestmod=hashlib.sha256)
82 signature = signature.hexdigest().upper()
83 params.update({
~/.virtualenvs/bitstamp/lib/python3.6/hmac.py in new(key, msg, digestmod)
142 method.
143 """
--> 144 return HMAC(key, msg, digestmod)
~/.virtualenvs/bitstamp/lib/python3.6/hmac.py in __init__(self, key, msg, digestmod)
40
41 if not isinstance(key, (bytes, bytearray)):
---> 42 raise TypeError("key: expected bytes or bytearray, but got %r" % type(key).__name__)
43
44 if digestmod is None:
TypeError: key: expected bytes or bytearray, but got 'str'
Changed key to bytes :
k = b'xxxxx'
Then :
api.account_balance(c, k, s)
TypeError Traceback (most recent call last)
<ipython-input-27-35f3ae0e7115> in <module>()
----> 1 api.account_balance(c, k, s)
~/.virtualenvs/bitstamp/lib/python3.6/site-packages/bitstampy/api.py in account_balance(client_id, api_key, api_secret)
38 def account_balance(client_id, api_key, api_secret):
39 return (
---> 40 calls.APIAccountBalanceCall(client_id, api_key, api_secret)
41 .call()
42 )
~/.virtualenvs/bitstamp/lib/python3.6/site-packages/bitstampy/calls.py in call(self, **params)
77 def call(self, **params):
78 nonce = self._get_nonce()
---> 79 message = nonce + self.client_id + self.api_key
80 signature = hmac.new(
81 self.api_secret, msg=message, digestmod=hashlib.sha256)
TypeError: must be str, not bytes
I am rather confused. Could you please clarify the argument types to use for client_id, api_key, api_secret ? Thanks
Hi,
Tried to run the code on python3, and got this stacktrace. It appears to be a python3 compatability issue - the code runs perfectly on python2
Thankyou
Traceback (most recent call last):
File "tr5.py", line 158, in
bitstamp_USD_balance=bitstamp_balance(bs_c=bs_c, bs_k=bs_k, bs_s=bs_s, asset="usd_available")
File "tr5.py", line 61, in bitstamp_balance
bs_data=api.account_balance(bs_c, bs_k, bs_s)
File "/home/ubuntu/btc/installstuff/bitstampy/bitstampy/api.py", line 40, in account_balance
calls.APIAccountBalanceCall(client_id, api_key, api_secret)
File "/home/ubuntu/btc/installstuff/bitstampy/bitstampy/calls.py", line 81, in call
self.api_secret, msg=message, digestmod=hashlib.sha256)
File "/usr/lib/python3.4/hmac.py", line 144, in new
return HMAC(key, msg, digestmod)
File "/usr/lib/python3.4/hmac.py", line 42, in init
raise TypeError("key: expected bytes or bytearray, but got %r" % type(key).name)
TypeError: key: expected bytes or bytearray, but got 'str'
Does this library support python3?
Hi Jack
Thanks for the API!
I'm trying to do a buy limit order and I'm getting an error. Is this a problem with Bitstampy or just something that I'm doing wrong... sorry to post this here but I could not find your email address.
bitstamp.buy_limit_order(c, k, s, 0.01, ask * 1.10)
Traceback (most recent call last):
File "/Users/daniel/bitcoin/coinduit/bank/bank.py", line 17, in
bitstamp.buy_limit_order(c, k, s, 0.01, ask * 1.10)
File "/Library/Python/2.7/site-packages/bitstampy/api.py", line 62, in buy_limit_order
.call(amount=amount, price=price)
File "/Library/Python/2.7/site-packages/bitstampy/calls.py", line 86, in call
return super(APIPrivateCall, self).call(**params)
File "/Library/Python/2.7/site-packages/bitstampy/calls.py", line 57, in call
raise APIError(response['error'])
APIError: Invalid nonce
Is there something I need to do to set the nonce?
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.