-1

I am trying to make a buy limit purchase via the bittrex api and I am getting an error that my arguments are in the wrong place.

from bittrex.bittrex import API_V2_0, Bittrex
import json

my_bittrex = Bittrex("zzzzz", "zzzzz", api_version=API_V2_0)

trade = 'BTC'
currency = 'TRX'
market = '{0}-{1}'.format(trade, currency)


b = (my_bittrex.buy_limit({market, 100, float(0.00005550)}))

error:

Traceback (most recent call last):
  File "bittrex/apitest.py", line 17, in <module>
    b = (my_bittrex.buy_limit({market, 100, float(0.00005550)}))
TypeError: buy_limit() missing 2 required positional arguments: 'quantity' and 'rate'

How do I properly position my arguments for bittrex?

UPDATE: I tried

b = (my_bittrex.trade_buy({market, 100, float(0.00005550)}))

and

b = my_bittrex.trade_buy(market=market, quantity=100, rate=float(0.00005550))

and

params = {'market': market, 'quantity': 100, 'rate': float(0.00005550)}
#b = my_bittrex.trade_buy(**params)
print (b)

error output from session:

{'result': None, 'success': False, 'message': 'There was a problem processing your request.  If this problem persists, please email support@bittrex.com with this error id - 4feb00b8-fbe9-4dd3-b11f-95fd7bf5250f'}
root@raspberrypi3:/var/www/html/jango# nano -c bittrex/apitest.py
root@raspberrypi3:/var/www/html/jango# python3 bittrex/apitest.py
{'message': 'There was a problem processing your request.  If this problem persists, please email support@bittrex.com with this error id - e0396c8d-8a4c-41c5-b6c4-6842c31386e2', 'success': False, 'result': None}
root@raspberrypi3:/var/www/html/jango# nano -c bittrex/apitest.py
root@raspberrypi3:/var/www/html/jango# python3 bittrex/apitest.py
{'success': False, 'result': None, 'message': 'NO_API_RESPONSE'}
root@raspberrypi3:/var/www/html/jango# python3 bittrex/apitest.py
{'message': 'NO_API_RESPONSE', 'success': False, 'result': None}
root@raspberrypi3:/var/www/html/jango# nano -c bittrex/apitest.py

Final update: I was getting confused here

:param time_in_effect: TIMEINEFFECT_GOOD_TIL_CANCELLED = 'GOOD_TIL_CANCELLED',
                TIMEINEFFECT_IMMEDIATE_OR_CANCEL = 'IMMEDIATE_OR_CANCEL', or TIMEINEFFECT_FILL_OR_KILL = 'FILL_OR_KILL'

from https://github.com/ericsomdahl/python-bittrex/blob/master/bittrex/bittrex.py#L740

Which has the correct function call to use.

final:

b= my_bittrex.trade_buy(market='BTC-TRX', order_type='LIMIT', quantity=100, rate=float(0.00000555), time_in_effect='GOOD_TIL_CANCELLED',condition_type='None', target=float(0.0))

And my limit order was just stilling in the gui waiting for me.

NIX
  • 107
  • 3
  • 14

1 Answers1

-1

Looking at the source code from ericsomdahl/python-bittrex

For the buy_limit function it looks like you are passing values to the function incorrectly. You shouldn't be passing a dictionary, instead it should look something like this:

b = my_bittrex.buy_limit(market=market, quantity=100, rate=float(0.00005550))

Or this

params = {'market': market, 'quantity': 100, 'rate': float(0.00005550)}
b = my_bittrex.buy_limit(**params)

For the trade_buy method you can pass parameters in a similar way:

b = my_bittrex.trade_buy(
    market=market, 
    quantity=100, 
    rate=float(0.00005550))
ScottMcC
  • 4,094
  • 1
  • 27
  • 35
  • I tried both and both yield the same error -> raise Exception('method call not available under API version {}'.format(self.api_version)) Exception: method call not available under API version v2.0 – NIX Mar 28 '18 at 12:24
  • What method do you want to use? You had the buy_limit method being called in your original question but you used the trade_buy method in your update to your question. The trade_buy method has different parameters. – ScottMcC Mar 28 '18 at 14:53
  • https://github.com/ericsomdahl/python-bittrex/blob/master/bittrex/bittrex.py#L343 – NIX Mar 28 '18 at 15:04
  • specifically -> Endpoint: 1.1 /market/buylimit 2.0 NO Direct equivalent. Use trade_buy for LIMIT and MARKET buys – NIX Mar 28 '18 at 15:06
  • You've pointed to the return statement from the `buy_limit` function? I'll update my original answer to show how you can using the `trade_buy` function – ScottMcC Mar 29 '18 at 00:54
  • I tried that, I tried putting the field names as strings and tried different keywords. https://bpaste.net/show/889775836bd8 Nah-dah – NIX Mar 29 '18 at 02:29
  • The statement on line 5 looks correct. It just looks like your not defining the variable `market` before passing it to the function? – ScottMcC Mar 29 '18 at 02:37
  • its looking for a system word there. I tried market, 'market' and MarketName. If I just define market = whatever on like line2, this fixes nothing. – NIX Mar 29 '18 at 11:56
  • Looking at the error outputs provide some hints. `'market'=....` is an invalid expression in python, `Marketname` is invalid because the function isn't expecting an expression `Marketname`. Look at the input to the function at https://github.com/ericsomdahl/python-bittrex/blob/master/bittrex/bittrex.py#L740 – ScottMcC Mar 30 '18 at 02:58