Open derzaicheg opened 7 years ago
I've been having this same exact issue when using buy/sell in BTC markets
@derzaicheg Since this feature is not working you can use api_version=API_V1_1
in conjunction with buy_limit
and sell_limit
{'message': 'NO_API_RESPONSE', 'result': None, 'success': False}
is what I get when I try to use API 2.0 trade_sell and trade_buy functions. This occurs for all markets.
If you inspect the request when you do a conditional sell on bittrex. it hits this endpoint https://www.bittrex.com/api/v2.0/auth/market/TradeSell
however this is a post request and takes form data. The form arguments are below
MarketName:BTC-ADA
OrderType:LIMIT
Quantity:83.32568866
Rate:0.00005000
TimeInEffect:GOOD_TIL_CANCELLED
ConditionType:GREATER_THAN
Target:0.00005
__RequestVerificationToken:6WTA2RhHrDnWwGi8h51qc5pnkB3cmS-m8zqglsbmMzqx6U0IsEtOUTL4Jp_6u8OHXenEG7kmkmkmk
the request verification token is generated from clicking the confirm button.
They must have changed the endpoints.
it's a huge shame they don't have documentation on their v2.0 API at all anywhere because the trade sell endpoint is extremely important
Where can I see the API 2.0 docs? I've never found it :(
We are stuck with an undocumented and constantly changing API right now for 2.0.
Ok ... bittrex apis return always NO_API_RESPONSE, no matter what. Both versions. Are you experiencing the same or is it just me guys?
Yeah, I also get a NO_API_RESPONSE message when running trade_sell (2.0 ofc)
@mejmo trade_buy
and trade_sell
are not available in 1.1. buy_limit
and sell_limit
work for me.
Feel frustrated as well. v2.0 sucks
I have come across the same issue. I am trying to initiate a market order.
V1.1: For buy_limit(), documentation states 'rate' param not required for market orders. However, when neglecting 'rate', I get the following response: buy_limit() missing 1 required positional argument: 'rate'
V2: I have the same issue as anakratis, commented on Nov 21.
So am I right - the trade_buy does not work in 1.1 and in 2 as well right? So I have to either conenct to web interface or I have to implement my own 'market-buy' logic?
Yep, there are some issues with urls. Look into https://github.com/thebotguys/golang-bittrex-api/wiki/Bittrex-API-Reference-(Unofficial), they know something :) Guys described that for trade_buy
has to be used /auth/market/TradeBuy
. Also this url can be found in bittrex js https://bittrex.com/bundles/userMarketViewModel but our lovely python-bittrex lib uses /key/market/tradebuy
. At the moment I have no free BTC to test right urls (everything is in alts 🤦♂️ ) but I'll test it later and will try to do my first py-PR :) (I'm js dev in general) At the moment I'm using v1.1 too without market-op features
I changed line 757 of the bittrex.py file from API_V2_0: '/key/market/tradebuy'
to API_V2_0: '/auth/market/TradeBuy'
but I still got the response {'success': False, 'result': None, 'message': 'NO_API_RESPONSE'}
):
... cause what? (see #L73). yep. we try to do everything with GET-requests... but v2.0 (actually v2.11 at the moment) waits for POSTs :) some alts were sold at night. it's time for some risky operation! :)
Let me know the results you get. I may be troubleshooting wrong here, but I tried changing line 73 from get
to post
, and still got {'success': False, 'result': None, 'message': 'NO_API_RESPONSE'}
there is not only evaluated method has to be changed. parameters are included to url in the _api_query(...)
, but they has to be sent as data
parameter of requests.post(...)
. also token
(apisign
?) has to be sent as __RequestVerificationToken
POST-parameter... I'll check it
well, I played a bit but 've got no luck too. I rewrote signing of request but server answers 500 every time. Client-side API usage is built around __RequestVerificationToken
which is sent by server on the html page inside hidden input. But we have another process of identification and signing and it has no description for POST-requests. (and it's not working like for GETs). I have to give up for a while cause there are a few tasks with a bit higher priority. Sorry. I'll be back in a few days 😺
May you guys disponibilizate an example using this "POST" method? Plz, completely confused.... To buy, "https://bittrex.com/api/v2.0/key/market/TradeBuy?marketName=BTC-LTC&orderType=LIMIT&quantity=5000&rate=.00000012&timeInEffect=GOOD_TIL_CANCELLED&conditionType=NONE&target=0" works very fine. But to sell, changing "TradeBuy" for "TradeSell" just doesnt work... Losing my mind. Somebody can help?
@valvesss You got the buy working with post request? Would you mind pasting how?
@toddis , I'm using the url quoted above to buy. Exactly how it is, but in the end using "&apikey=YOUR_API_KEY"... I'm having this issue to sell, all the calcs are right but when I order sell, they are cancelleds :(
@valvesss Sorry I keep bugging you about your workaround for buying, but how do you specify the API secret? When I try, I keep getting {"success":false,"message":"INVALID_SIGNATURE","result":null}
@toddis , which language are you using? I'm using PHP bro... To me is just:
$apikey = 'YOUR_API_KEY'; $apisecret = 'YOUR_API_SECRET'; $uri = 'https://bittrex.com/api/v2.0/key/market/TradeBuy?marketName=BTC-'.$mkt_name.'&orderType=LIMIT&quantity='.$quantity_value.'&rate='.$rate_value.'&timeInEffect=IMMEDIATE_OR_CANCEL&conditionType=NONE&target=0&apikey='.$apikey; $nonce=time(); $newuri= $uri.'&nonce='.$nonce;
$sign=hash_hmac('sha512',$newuri,$apisecret);
$ch = curl_init($newuri); curl_setopt($ch, CURLOPT_HTTPHEADER, array('apisign:'.$sign)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $execResult = curl_exec($ch);
$obj = json_decode($execResult);
Good luck, all the response stuff will be inside the object and the buy action will be already done. Anything else just ask, If I could answer, I'll.
Note: as you asked, the API Secret wont go inside the url - who goes its the API Key -, but in the hash_hmac.
Edit: Hahahah just now I saw that is a python-bittrex issue, sorry. But this is how I use.
“The mind that opens to a new idea never returns to its original size.” — Albert Einstein
It seems that as soon as I try timeInEffect = FILL_OR_KILL I get the error message: There was a problem processing your request. If this problem persists, please email support@bittrex.com with this error id - 974c7c6b-8aae-4638-b083-c48b9cdafccb.
@koppentc As we know, the 2.0 API's are in BETA version, some functions appears to doesnt work properly... Seems that the function "FILL_OR_KILL" is unavailable yet. You should try the "IMMEDIATE_OR_CANCEL" instead, its 100% functional.
@valvesss I tried using the trade_buy function with 'IMMEDIATE_OR_CANCEL' and i still get the following response:
{'message': 'NO_API_RESPONSE', 'result': None, 'success': False}
How did you get it working?
@fresaelens 'NO_API_RESPONSE' is the default error message when an exception is thrown. You should check what error is thrown in the try statement. Hope this helps.
@fresaelens You could post this part of your code? Your apikey and apisecret are configured to play TRADE LIMIT and TRADE MARKET?
It starts at line 146 of bittrex.py: https://github.com/ericsomdahl/python-bittrex/blob/e5ebaef46974829e107a105320d2a7adb628507e/bittrex/bittrex.py#L146
You should debug here to see what exception is thrown
@valvesss My API key and secret are configured (correctly). I have a working script using v1.1 of the API and I can use the other methods of v2 without problems.
I changed the code around a bit and saw I got the following message:
"No JSON object could be decoded".
Then I went ahead and printed out the status code of the request being sent and I get a 404 error.
You can see the complete output in the attached file.
@fresaelens can you use other private methods (i.e. one that require the key/secret)?
@fresaelens Houston we have a problem, honestly, sorry, I dont speak python, learning yet. I've started play this 1 month ago. I'm afraid I can't help you with this. But I'll try.
Try to create your link (url) full and paste it on navigator (yes, this is very poor. And dont be afraid of your data beeing "read" by the navigators, this is done with post and get methods, everywhere, everytime), and see if it works. Its the same process, but rudimentary. You'll just have problems with the nonce. Create a new py program, just with the URL, add the nonce and try to execute. Eliminating one problem each time is the best way, this is called 'canary' (http://whatis.techtarget.com/definition/canary-canary-testing).
@koppentc I can indeed use other private methods (I'm successfully requesting my wallet balance for example).
I just realised I did change the following in the cloned github file
I changed the API call in the trade_buy method from:
To the following: API_V2_0: '/auth/market/TradeBuy'
Because I read somewhere it should be the last.
I've changed it back to the original line and now I get a different error:
200 True {"success":false,"message":"INVALID_ORDER_LIMIT_NOT_NULL","result":null}
@fresaelens Weird. I use with "API_V2_0: '/key/market/tradebuy'" and works. But good for you
Yeah it should be /key/market/tradebuy.
@fresaelens: that looks like a good response. Your order probably wasn't correct
@valvesss
I might have misexplained myself.
I changed the line back to "#API_V2_0: '/key/market/tradebuy'" and now it is 'working', that is I get a different error.
I'll try troubleshooting like u said in the navigator tomorrow.
@koppentc
I think you're right but my mind is too tired to think straight now. I'll look back into it tomorrow.
@fresaelens 1 time to rest is better than 2 times of work bro... This stuffs (MONEY) drives us crazy.
I did one final test and got it working.
I think the order was failing on the variable 'ORDERTYPE_MARKET'.
As soon as I changed this to 'ORDERTYPE_LIMIT' my order went through.
The condition 'GOOD_TIL_CANCELLED' was working too.
I immediately placed a stop-loss sell order using the conditional 'CONDITIONTYPE_STOP_LOSS_FIXED' variable and the sell order was succesful. I just want to verify that the condition was passed along as well but I can't seem to find it in Bittrex. Does anyone know how I can verify on Bittrex if my sell order was placed with a condition (stop-loss)? (sorry for the noob question)
Never mind, I found it, stupid me.
(For the ones wondering, just press the 'plus' sign next to your order).
No problem, glad its working!
Does anyone able to successfully create trade sell with condition less than? I used the below request. I got success response, but in the response 'IsConditional' is False instead of True.
Request: self.bittrex.trade_sell(market="BTC-LTC", order_type="LIMIT", quantity=10, rate=0.01450, time_in_effect='GOOD_TIL_CANCELLED', condition_type='LESS_THAN', target=0.01450)
Response: {'success': True, 'message': '', 'result': [{'QuantityRemaining': 10.0, 'ImmediateOrCancel': False, 'Uuid': None, 'OrderUuid': 'XXXX-XXXX-XXXX-XXXX-XXXXXXXXX', 'Price': 0.0, 'PricePerUnit': None, 'CommissionPaid': 0.0, 'Closed': None, 'Exchange': 'BTC-LTC', 'Condition': 'LESS_THAN', 'Limit': 1.45e-02, 'ConditionTarget': 1.45e-02 'OrderType': 'LIMIT_SELL', 'Quantity': 10.0, 'IsConditional': False, 'CancelInitiated': False, 'Opened': '2018-01-03T07:01:07.91'}]}
Could someone please let me know how to fix this?
I'm getting:
File "C:\Program Files (x86)\Python36\lib\site-packages\bittrex\bittrex.py", line 766, in trade_buy
}, protection=PROTECTION_PRV)
File "C:\Program Files (x86)\Python36\lib\site-packages\bittrex\bittrex.py", line 153, in _api_query
return self.dispatch(request_url, apisign)
File "C:\Program Files (x86)\Python36\lib\site-packages\bittrex\bittrex.py", line 75, in using_requests
headers={"apisign": apisign}
File "C:\Program Files (x86)\Python36\lib\site-packages\requests\models.py", line 819, in json
return json.loads(self.text, **kwargs)
File "C:\Program Files (x86)\Python36\lib\json\__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "C:\Program Files (x86)\Python36\lib\json\decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Program Files (x86)\Python36\lib\json\decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
when using:
self.exchangeV2.trade_buy(market="BTC-SC, order_type=ORDERTYPE_MARKET, quantity=1000,=TIMEINEFFECT_IMMEDIATE_OR_CANCEL)
I've tried troubleshooting myself, but sadly I'm getting nowhere myself
Well if the command you provided was what you copied above you have a lot of errors in your call. You should probably read up on some python coding :)
My best guess would be self.exchangeV2.trade_buy(market="BTC-SC", order_type=bittrex.ORDERTYPE_MARKET, quantity=1000, time_in_effect=bittrex.TIMEINEFFECT_IMMEDIATE_OR_CANCEL)
I found out the issue. Apparently it didn't like me not specifying the rate. After I added that (and changed ORDERTYPE_MARKET to ORDERTYPE_LIMIT), it worked
Any news on FILL_OR_KILL time option? I have tried to reach the support, but no answer so far.
I manage to send orders fine using API 2.0 - however, sometimes I would send a limit order, but not receive an API response (I get a timeout). The order request still goes through and the order is open, but I am not aware of it and I can't check because I don't have an order ID I can query (which would normally come in the API response).
Has anybody had this problem? Is it because I send too many requests to Bittrex and they give a temporary ban? Is there a way I can choose the order ID when I create an order, so that I can send a get_order query afterwards to verify whether my new order request was completed or not?
@Crimees As a workaround when there is no ID returned, you can use getorders
. You can remember quantity and/or rate and/or market name as a key. Usually new orders are at the beginning of the orders array.
Guys you do not need to have MARKET order available I think - in UI if I create order with higher value, it will buy it from the nearest offer from order book. So this is kind of market order.
@milosjovac thanks that works @mejmo I agree, If you want to make sure the order gets executed you place it at a worse price (lower for SELL and higher for BUY) and it will pick the best bid/ask from the book
@mejmo @Crimees There is a problem with this approach.
It is that for a LIMIT trade you have to specify both attributes - quantity and a rate. So selling will be identical to market sell, but buying will not be possible since you cannot make an order by specifying how much of a base currency you want to spend.
To visualize you cannot do the following (from CEX.IO market trading):
Hi guy!
Maybe problem not in this lib (or even I am sure it works properly) but maybe you face the same issue.
When I am sending request to tradesell or tradebuy endpoints using this lib:
buy_limit(market=USDT-ZEC, quantity=0.01, rate=216)
I get error message from bittrex:
{u'message': u'There was a problem processing your request. If this problem persists, please email support@bittrex.com with this error id - d70a2af0-1281-4320-b3d9-f2070f5e79de', u'result': None, u'success': False}
Maybe somebody could confirm that this API does not work from their side or it works? Thanks Sergii