Lakshmi-1212 / TriangularArbitrageCryptos

115 stars 73 forks source link

argument of type 'float' is not iterable #4

Open yu3ufe opened 2 years ago

yu3ufe commented 2 years ago

Hi,

When I try the original code with limit orders without modification it always executes the 1st order only but the 2nd and 3rd orders won't be executed and I'm always getting Insuffecient binance balance error and the 2nd order remains open

since binance supports market orders, I modified create_limit_buy_order and create_limit_sell_order to create_market_buy_order and create_market_sell_order respectively but I keep getting this error below, any help?


Traceback (most recent call last):
  File "/home/joo/.local/lib/python3.8/site-packages/ccxt/base/exchange.py", line 617, in fetch
    response.raise_for_status()
  File "/usr/lib/python3/dist-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.binance.com/api/v3/order

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/joo/triangle_arbitrage/triangle.py", line 193, in <module>
    perform_triangular_arbitrage(s1,s2,s3,'BUY_BUY_SELL',INVESTMENT_AMOUNT_DOLLARS,
  File "/home/joo/triangle_arbitrage/triangle.py", line 173, in perform_triangular_arbitrage
    place_trade_orders(arbitrage_type, scrip1, scrip2, scrip3, initial_investment, scrip_prices)
  File "/home/joo/triangle_arbitrage/triangle.py", line 135, in place_trade_orders
    place_buy_order(scrip1, s1_quantity, scrip_prices[scrip1])
  File "/home/joo/triangle_arbitrage/triangle.py", line 124, in place_buy_order
    order = exchange.create_limit_buy_order(scrip, quantity, limit)
  File "/home/joo/.local/lib/python3.8/site-packages/ccxt/base/exchange.py", line 2979, in create_limit_buy_order
    return self.create_order(symbol, 'limit', 'buy', amount, price, params)
  File "/home/joo/.local/lib/python3.8/site-packages/ccxt/binance.py", line 2973, in create_order
    response = getattr(self, method)(self.extend(request, params))
joo@Joo:~/triangle_arbitrage$ /bin/python3 /home/joo/triangle_arbitrage/triangle.py
No. of market symbols: 2080
No. of crypto combinations: 872
PROFIT-23:21:48:BUY_BUY_SELL, BNB/BUSD,IOTA/BNB,IOTA/BUSD, Profit/Loss: 0.183 
Traceback (most recent call last):
  File "/home/joo/triangle_arbitrage/triangle.py", line 193, in <module>
    perform_triangular_arbitrage(s1,s2,s3,'BUY_BUY_SELL',INVESTMENT_AMOUNT_DOLLARS,
  File "/home/joo/triangle_arbitrage/triangle.py", line 173, in perform_triangular_arbitrage
joo@Joo:~/triangle_arbitrage$ /bin/python3 /home/joo/triangle_arbitrage/triangle.py
No. of market symbols: 2080
No. of crypto combinations: 872
PROFIT-23:23:01:BUY_BUY_SELL, BNB/BUSD,IOTA/BNB,IOTA/BUSD, Profit/Loss: 0.157 
Traceback (most recent call last):
  File "/home/joo/.local/lib/python3.8/site-packages/ccxt/base/exchange.py", line 617, in fetch
    response.raise_for_status()
  File "/usr/lib/python3/dist-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.binance.com/api/v3/order

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/joo/triangle_arbitrage/triangle.py", line 193, in <module>
    perform_triangular_arbitrage(s1,s2,s3,'BUY_BUY_SELL',INVESTMENT_AMOUNT_DOLLARS,
  File "/home/joo/triangle_arbitrage/triangle.py", line 173, in perform_triangular_arbitrage
    place_trade_orders(arbitrage_type, scrip1, scrip2, scrip3, initial_investment, scrip_prices)
  File "/home/joo/triangle_arbitrage/triangle.py", line 141, in place_trade_orders
    place_sell_order(scrip3, s3_quantity, scrip_prices[scrip3])
  File "/home/joo/triangle_arbitrage/triangle.py", line 128, in place_sell_order
    order = exchange.create_limit_sell_order(scrip, quantity, limit)
  File "/home/joo/.local/lib/python3.8/site-packages/ccxt/base/exchange.py", line 2982, in create_limit_sell_order
    return self.create_order(symbol, 'limit', 'sell', amount, price, params)
  File "/home/joo/.local/lib/python3.8/site-packages/ccxt/binance.py", line 2973, in create_order
    response = getattr(self, method)(self.extend(request, params))
joo@Joo:~/triangle_arbitrage$ /bin/python3 /home/joo/triangle_arbitrage/triangle.py
No. of market symbols: 2080
No. of crypto combinations: 872
PROFIT-23:29:10:BUY_BUY_SELL, BNB/BUSD,IOTA/BNB,IOTA/BUSD, Profit/Loss: 0.264 
Traceback (most recent call last):
  File "/home/joo/triangle_arbitrage/triangle.py", line 193, in <module>
    perform_triangular_arbitrage(s1,s2,s3,'BUY_BUY_SELL',INVESTMENT_AMOUNT_DOLLARS,
  File "/home/joo/triangle_arbitrage/triangle.py", line 173, in perform_triangular_arbitrage
    place_trade_orders(arbitrage_type, scrip1, scrip2, scrip3, initial_investment, scrip_prices)
  File "/home/joo/triangle_arbitrage/triangle.py", line 135, in place_trade_orders
    place_buy_order(scrip1, s1_quantity, scrip_prices[scrip1])
  File "/home/joo/triangle_arbitrage/triangle.py", line 124, in place_buy_order
    order = exchange.create_market_buy_order(scrip, quantity, limit)
  File "/home/joo/.local/lib/python3.8/site-packages/ccxt/base/exchange.py", line 2985, in create_market_buy_order
    return self.create_order(symbol, 'market', 'buy', amount, None, params)
  File "/home/joo/.local/lib/python3.8/site-packages/ccxt/binance.py", line 2830, in create_order
    marketType = self.safe_string(params, 'type', defaultType)
  File "/home/joo/.local/lib/python3.8/site-packages/ccxt/base/exchange.py", line 704, in safe_string
    return str(dictionary[key]) if Exchange.key_exists(dictionary, key) else default_value
  File "/home/joo/.local/lib/python3.8/site-packages/ccxt/base/exchange.py", line 688, in key_exists
    if key in dictionary:
TypeError: argument of type 'float' is not iterable```
austinekrash commented 1 year ago

I am also getting the same errors @Lakshmi-1212 would you kindly assist