Code Monkey home page Code Monkey logo

triangulararbitragecryptos's Introduction

TriangularArbitrageCryptos

Triangular arbitrage is a technique that tries to exploit the price discrepancy across three different assets at the same time.
For example, we can exchange BTC for USDT, BTC for ETH and ETH back to USDT.
If the net worth in doing these three trades simultaneously is profitable then the 3 trades are executed simultaneously.

Here we implement the triangular arbitrage in 4 steps.
Step 1: Get all the valid crypto combinations. Step 2: Perform triangular arbitrage
Step 3: Place the trade orders
Step 4: Bundle it together

Refer to this blog to understand more on triangular arbitrage implemented in this repo:
https://lakshmi1212.medium.com/automated-triangular-arbitrage-of-cryptos-in-4-steps-a678f7b01ce7

triangulararbitragecryptos's People

Contributors

lakshmi-1212 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

triangulararbitragecryptos's Issues

Advice/Help required

Hi @Lakshmi-1212 , This program is superb and I earn some money as well and lose as well, but totally It's a nice and good way t earn. But there is something that needs to fix for intermediate pairs. 1st pair and 3 pairs order execution are fine because they have good enough volume with USDT pairs but when it comes to intermediate pairs like for Example AAVE/BTC, AAVE/BNB, AAVE/ETH, due to no moments and volumes deal gets stuck for a long time. Is there any solution to that? because once an order has been executed with intermediate pairs it's very hard to complete due to no volumes/moments in that pair. Do you have any solution for that? Please if this can be resolved, I am 100% sure there will be BOOOOOOMMMMMMMM.... for example, I have attached the image for NEAR/BNB coin as below in this coin no moment and volumes

Capture

use market order

how do I use market order rather than limit order, so to make every order deal immediatly.

Code doesn't work

I'm getting the error message "NameError: name 'arbitrage_type' is not defined" when running the code. Do you know how to solve this? It says the error is here "place_trade_orders(arbitrage_type, scrip1, scrip2, scrip3, initial_investment, scrip_prices)". How do I fix the error so I can place real trades?

HTTPError: 400 Client Error

Hi, I have encountered these 2 errors, in the execution of the code.

The balance cannot be insufficient in the account because I use $ 100 as proof


HTTPError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/ccxt/base/exchange.py in fetch(self, url, method, headers, body)
616 self.logger.debug("%s %s, Response: %s %s %s", method, url, http_status_code, headers, http_response)
--> 617 response.raise_for_status()
618

12 frames
HTTPError: 400 Client Error: Bad Request for url: https://api.binance.com/api/v3/order

During handling of the above exception, another exception occurred:

InsufficientFunds Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/ccxt/base/exchange.py in throw_exactly_matched_exception(self, exact, string, message)
2793 def throw_exactly_matched_exception(self, exact, string, message):
2794 if string in exact:
-> 2795 raise exactstring
2796
2797 def throw_broadly_matched_exception(self, broad, string, message):

InsufficientFunds: binance Account has insufficient balance for requested action.

Invalid market pair

I tested you code on binance and brought out YFII/USDT, YFII/BTC, BTC/USDT as a profit on triangular arbitrage but there's actually no YFII/BTC market pair on binance.

argument of type 'float' is not iterable

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```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.