peshay / btcde Goto Github PK
View Code? Open in Web Editor NEWA Python Module for Bitcoin.de Trading API
License: MIT License
A Python Module for Bitcoin.de Trading API
License: MIT License
As there are differences between float and decimal calculation, a test should be added which would have an incorrect calculation only for floats.
All functions as described by bitcoin.de API documentation should be tested
Debug logging should not be enabled by default for a library.
Hi,
if i try to retrieve the trades i made, the function "showMyTrades" just returns an empty response. There are many trades in my account and all other functions work fine. So it is not a problem with my account or API keys.
My code:
import btcde
api_key_BTCDE = '[my key]'
api_secret_BTCDE = '[my secret]'
conn = btcde.Connection(api_key_BTCDE, api_secret_BTCDE)
trades = conn.showMyTrades()
print(trades)
The response:
{'trades': [], 'page': {'current': 0, 'last': 0}, 'errors': [], 'credits': 57}
Any help will be greatly appreciated, thanks!
Best regards
Jan
According to your example I tried to sell something with this codesnippet
import btcde
create a object for the connection settings
api_key = "my_key"
api_secret = "my_secret"
conn = btcde.Connection(api_key, api_secret)
orderbook = conn.showOrderbook('sell', 'btceur')
print('API Credits Left: ' + str(orderbook.get('credits')))
orders = orderbook.get('orders')
for order in orders:
print('Order ID: ' + str(order.get('order_id')) + " Min_Amount: " + str(order.get('min_amount')) + '\tPrice: ' + str(order.get('price')) + ' EUR')
conn.executeTrade('NRRHV9','sell','btceur',0.0021)`
Unfortunally it doesn't work for me. I get this output.
WARNING:btcde:API Error Code: 5
WARNING:btcde:API Error Message: Invalid signature
WARNING:btcde:API Error URL: https://api.bitcoin.de/v2/trades/NRRHV9?order_id=NRRHV9&type=sell&trading_pair=btceur&amount=0.0021
Would be great if you could fix this?
At the moment the code handels with bitcoin.de api version 2, bitcoin.de upgraded the api version to 4. It would be nice if you could enhance your code in order to deal with version 4.
add logging to catch error messages etc.
The documentation link in readme is broken: https://www.bitcoin.de/de/api/tapi/v2/docu
More info on how to fix Insecure Network Communication in Python.
According to the bitcoin.de API documentation, the valid states for orders are [-2, -1, 0], however the btcde interface only accepts the states [-1, 0, 1], which is only correct for showMyTrades, not showMyOrders! Please fix this, thanks.
Following functions do not work, as in the bitcoin.de API documentation describe:
Further investigation is needed and to fix them. Currently they fail in #15
Hi,
thank for creating this library.
I found an issue with executeTrade()
A normal trade execution works perfectly.
But a python error will be raised if there is a problem like 'order id does not exist' or 'order not possible'.
The reason is that the API also responds with http status codes 403, 404, 422
I have added these codes to HandleAPIErrors(), this works for me.
But i am not sure if this is the correct solution.
Frank
Currently API errors (such as insufficient credits) are catched internally and the response is simply empty. It would be nice if the SDK could also have an option to throw the api errors instead, such that the superscript can handle them accordingly eg by limiting the rate.
The call
btcde.executeTrade(conn, order, "btceur", "buy", amount)
fails with the following output:
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.bitcoin.de
DEBUG:urllib3.connectionpool:https://api.bitcoin.de:443 "POST /v2/trades/F96DZZ?amount=0.02&order_id=F96DZZ&trading_pair=buy&type=btceur HTTP/1.1" 400 None
Code: 28
Message: Forbidden value for POST-Parameter: type
With URL: https://api.bitcoin.de/v2/trades/F96DZZ?amount=0.02&order_id=F96DZZ&trading_pair=buy&type=btceur
{}
Suspecting that it has to do with the decimal dot in the float, I tried to pass in the amount as a string (with decimal comma). Didn't help, but the error is a different one:
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.bitcoin.de
DEBUG:urllib3.connectionpool:https://api.bitcoin.de:443 "POST /v2/trades/F96DZZ?amount=0,02&order_id=F96DZZ&trading_pair=buy&type=btceur HTTP/1.1" 400 None
Code: 5
Message: Invalid signature
With URL: https://api.bitcoin.de/v2/trades/F96DZZ?amount=0,02&order_id=F96DZZ&trading_pair=buy&type=btceur
{}
Didn't try with integer amount (too expensive ;-)
Thanks for looking into this. Andreas
How can the tradingpair xrpeur be added?
Hello, can you give me same example for the **args ?
showOrderbook(OrderType, trading_pair, **args)
how i had to write only_express_orders in a **args ?
Please more samples :-)
After a call to executeTrade(...) where order had already expired, I get the following output:
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.bitcoin.de
DEBUG:urllib3.connectionpool:https://api.bitcoin.de:443 "POST /v2/trades/F96DZZ?amount=0.02&order_id=F96DZZ&trading_pair=btceur&type=buy HTTP/1.1" 403 None
Traceback (most recent call last):
File "buy.py", line 50, in <module>
pprint(btcde.executeTrade(conn, order, "buy", "btceur", amount))
File "/home/andreas/python/btcde/btcde.py", line 174, in executeTrade
return APIConnect(conn, 'POST', params, newuri)
File "/home/andreas/python/btcde/btcde.py", line 121, in APIConnect
if HandleAPIErrors(r):
File "/home/andreas/python/btcde/btcde.py", line 61, in HandleAPIErrors
content = json.load(reader(r.raw))
File "/usr/lib/python2.7/json/__init__.py", line 287, in load
return loads(fp.read(),
File "/usr/lib/python2.7/codecs.py", line 492, in read
newchars, decodedbytes = self.decode(data, self.errors)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x8b in position 1: invalid start byte
Don't understand this, it doesn't look helpful.
Vielen Dank & liebe Grüße, Andreas
line 94 of btcde.py: 'X-API-NONCE': nonce,
must be: 'X-API-NONCE': str(nonce),
It doesn't matter if i pass a date argument (date_start / date_end) or not, the function always returns the default, which is the account ledger for the last 10 days.
Example code:
ledger = conn.showAccountLedger(currency="eth", date_start="2018-01-01T01:00:00+01:00", date_end="2018-01-07T01:00:00+01:00")
nose got deprecated: https://nose.readthedocs.io/en/latest/
There is no compatible version for python 3.10 and later.
Either we switch to nose2 https://docs.nose2.io/en/latest/ or https://docs.pytest.org/en/stable/
Hallo Zusammen,
damit werden schon einige Probleme gehabt haben aber trotz diskussion im Forum hat wohl keine hier was zum Code geändert. Die Parameter mit dem ":" sind so nicht richtig angegeben.
Bei delete sollte das richtig so aussehen:
def deleteOrder(conn, order_id):
"""Delete an Order."""
#newuri = orderuri + ":" + order_id KEIN DOPPELPUNKT ABER SLASH
newuri = orderuri + "/" + order_id
params = {'order_id': order_id}
return APIConnect(conn, 'DELETE', params, newuri)
Bei my order Details so:
def showMyOrderDetails(conn, order_id):
"""Details to an own Order."""
#newuri = orderuri + '/:' + order_id KEIN DOPPELPUNKT!
newuri = orderuri + '/' + order_id
params = {'order_id': order_id}
return APIConnect(conn, 'GET', params, newuri)
=> Die anderen calls müsste man dann paralell ändern. Bei den beiden kann ich es aber mit Sicherheit bestätigen, da ich die so getestet haben.
Viele Grüße und Danke für die Sourcen :)
So that dates are correct and integers used where required etc.
Dear all,
I was very happy to discover this module, which I am quite eager to try out.
Thanks a lot for writing and making it available!
But my first attempt failed. I followed the steps in the README.md up to this point:
>>> orderbook = btcde.showOrderbook(conn, 'buy')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "btcde.py", line 137, in showOrderbook
return APIConnect(conn, 'GET', params, orderuri)
File "btcde.py", line 115, in APIConnect
header = set_header(url)
File "btcde.py", line 84, in set_header
if method == 'POST':
NameError: global name 'method' is not defined
Looks manageable, but I thought you might want to know about this.
Best regards from Luxembourg,
Andreas
createOrder always throws 'invalid signature'. I am not sure if its me or there is a bug but most of the other methods just work, so does createOrder in an older Version.
Hi,
the code in btcede.py line 17,18 need to differ between python 2.7 and 3.
Doc of httplib says "The httplib module has been renamed to http.client in Python 3".
In case of version < 3 the lib is called httplib else http.client
Rgds
jammcc
If API send maintenance information, it should be saved and queries paused, during maintenance period.
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.