codereclaimers / btce-api Goto Github PK
View Code? Open in Web Editor NEWPython wrapper around the public and trading APIs of BTC-e.com
License: MIT License
Python wrapper around the public and trading APIs of BTC-e.com
License: MIT License
From public api - https://btc-e.com/api/2/btc_usd/ticker
It is still present in the code and samples.
Thanks to EvilTosha for bringing this to my attention!
At first thank you for creating such a beautiful tool.
The issue is as follows: the order parameter of transHistory method of TradeAPI object does not do any sorting. As a workaround, I'm using a lambda function, but it may be a bit slower:
trn_history = t.transHistory(count_number=3)
trn_history.sort(key=lambda a: a.transaction_id, reverse=True)
for n in trn_history:
print "AMNT: %s\t CUR: %s\t DESC: %s\t STAT: %s\t TIM: %s\t TID: %s\t TYP: %s" % (n.amount, n.currency, n.desc, n.status, n.timestamp, n.transaction_id, n.type)
Also, I noticed, that the next TransactionHistoryItem objects aren't returned at all: currency, desc and status. transHistory always return them as None. It would be great if you'll fix this minor bug.
Hi.
When making an order for sale, for example:
tapi.trade("btc_usd", "sell", 999.99, 0.109)
order for sale 0.108 btc created. It's just me or there is a bug in common.formatCurrency?
Hello, Alan. Please add XPM-BTC pair.
trying to do this
pair = "eur_rur"
gives this error
btceapi.common.InvalidTradePairException: Unrecognized pair: 'eur_rur'
An error occurred: Unrecognized pair: 'eur_rur'
I'm not sure what's going on here, but when I scrape the main page for messages I get the same results over and over for about 4 or 5 minutes.
I suspect this is actually a bug in btc-e, related to what sometimes happens if you switch currencies just as a new message shows up, and it disappears.
Hi alan, thank you for the great work.
Is it possible to withdraw coins via API? Apparently from the flag in the permission it is.. but how?
HI Alan,
This isn't an issue with your excellent api (or at least I haven't seen it), but what's the best way to capture exceptions and retry polling when you get 403 and SSL Errors?
Right now my bot is running on a batch file (in infinite loop) so python script can restart when any exceptions are caught.
I'm new to github and haven't figured out how to email you. :(
Hello!
Excellent library, thank you very much! But I do not see a request for information about the order.
https://btc-e.com/tapi/docs#OrderInfo
Is it possible to add it?
Thanks a lot!
Example raw html:
<p id='msg10560425' class='chatmessage'>
<a title='30.12.13 21:43:11' style='color: #8da0b9; font-weight: bold;'
href='javascript:void(0)' onclick='nChatMenu(88862, "andreasjva", 10560425, event)'>
andreasjva</a>:
<span>1cryptoamin, just keep in mind, if you did 2% a day every day, at the end of the month you'll be up over 60% (compounded)</span>
</p>
as parsed by handle_data (html entity is changed to 0x0a):
1cryptoamin, just keep in mind, if you did 2% a day every day, at the end of the month you
ll be up over 60% (compounded)
After data.strip():
2013-12-30 21:43:11 andreasjva: ll be up over 60% (compounded)
BTW -- it's possible there are other html entity issues.
It will be great if it will be possible to call getTradeHistory and getDepth functions with additional parameters. For example, I need to get just single last trade and not the whole 150, because of decreased response time and BTC-e server load. For this reason the API allows to specify, for example, optional count parameter, so it would be great if you will implement this feature in the future.
what does mean the "rate" Parameter in the [Trade] method
The API returns an error message that makes it possible to correct an outdated nonce (due to an application crash without saving nonces, for example), so it would be helpful to just fix it and retry the call.
Hey, Alan. Recently BTC-e has added CNH for BTC, LTC and USD. Please add these pairs.
/btceapi/common.py line 49 is not compatible with exceptions in python-3
I think it should change to:
except Exception as e:
print("Error while attempting to parse JSON response:", e)
print ("Response:",response)
raise e
Hey there, I noticed that sometimes an automated trader I built was bombing out when trying to make trades involving the btc_eur pair with a message about not being able to use a "none type" (I suppose that's Python's version of a null reference exception). In any case, I traced it to the fact that there is no minimum trade or max digits value set for that pair in Common.py. After adding appropriate values for these, I didn't see the error again. Please merge this change into the master if you feel it appropriate.
Pair's decimal_places are really about rate. Amount, as long as it's greater than the minimum, can have up to 8 decimal places regardless the pair and currency (at least in Trade method parameter and result set, but I suspect it applies everywhere). Enforcing 8 decimal places in parameter values ARE important, 9 or more places are rejected.
I failed to find a reference to 8-digit amount precision in the documentation -- maybe some other libraries have it, as there are obviously many bots buying and selling amounts like 0.01003882 BTC.
Looking at the code, I'd suggest that format_currency should be split in format_rate and format_amount (the latter doesn't really need pair information, so it's unclear in what class should in be defined). For existing code calling format_currency, it should probably be treated like format_rate to be on the safe side. Maybe I'll have some time to prepare a complete patch.
Provide functions to validate an order before submitting it, to catch things like orders that are below the minimum size, etc., without having to make the trip to the server to find out.
It may be faster (or at least more friendly to the server) to be able to reuse connections.
I'm getting an error that is causing an unusual exception when it automatically tries to fix a nonce error. I think the error message was changed and it cannot parse this line (164) properly:
expected, actual = map(int, err_message.split()[-2:])
The error messages from btce look like this:
invalid nonce parameter; on key:xxxxx, you sent:xxxxx
You could simply build a nonce method based on time, lets say:
# This value is used in order to generate a small nonce,
# because for some reason btc-e doesn't like big nonces.
timestamp_reduce_value = 1380736931200
return int(time.time()*1e3) - timestamp_reduce_value
The order_id keeps getting returned as "0" when I buy. Selling is no problem. Is this expected?
There seems to be issues with parsing the json response received on higher/certain trade calls. It appears to be that the error occurs in the "remains" field as there's no numbers trailing the the decimal point (in this case the order was 44.000000).
Error while attempting to parse JSON response: Expecting , delimiter: line 1 column 48 (char 48)
Response: '{"success":1,"return":{"received":0,"remains":44.,"order_id":(omitted),"funds":{"usd":778.21537223,"rur":0,"eur":0,"btc":0,"ltc":0.43376503,"nmc":0,"nvc":0,"trc":0,"ppc":0}}}'
I guess it's an issue on BTC-E's part, but perhaps you can handle it accordingly in your API. Otherwise I've enjoyed working with it thus far.
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.