agonyforge / arbitrader

A market neutral cryptocurrency trading bot.
MIT License
182 stars 47 forks source link

Use xchange-stream where possible #76

Closed scionaltera closed 3 years ago

scionaltera commented 5 years ago

Lately I've been noticing API rate limiting errors from a few exchanges. While there are a few optimizations to be made that can reduce the number of requests per second by caching information, a better solution would be to switch to using xchange-stream wherever possible to make use of websocket streams instead of rapidly polling.

scionaltera commented 4 years ago

According to xchange-stream's README they are in the process of merging into the main xchange project. I'm going to hold off on this work until that happens, even though I consider this to be a high priority. The rate limiting is a significant problem for the bot.

scionaltera commented 4 years ago

It looks like XChange has decided to go forward with merging the xchange-stream project. Their normal release process appears to have stalled and the version number on their develop branch has bumped to 5.0.0-SNAPSHOT. So I still think waiting is the right move at this point.

scionaltera commented 4 years ago

Kraken and Coinbase Pro now supported. Bitflyer coming next.

scionaltera commented 4 years ago

Added the "help wanted" label. I'd be grateful if anyone using exchanges that I don't use but that have streaming implementations (e.g. Poloniex, Binance, Bitfinex and others) would help test them out. It's pretty easy to switch over to the streaming version of an exchange:

First, change the dependency in build.gradle from "xchange-exchangename" to "xchange-stream-exchangename". This will pull the streaming version of the exchange into your project.

Next, change the name of the exchange class in application.yaml to the full path to the streaming version of the exchange implementation. Usually something like:

org.knowm.xchange.poloniex.PoloniexExchange <-- the old one info.bitrich.xchangestream.poloniex.PoloniexStreamingExchange <-- the new one

This will make Arbitrader load the class with the streaming functionality in it when it runs.

You'll need to look at the XChange project in GitHub, look in the subdirectory for the exchange you want (e.g. xchange-stream-poloniex) and find the class name under src/main/java/info/bitrich/xchangestream/poloniex to make sure you have the correct class name.

Once you have made these changes, recompile (see the development guide in the Wiki) and start Arbitrader. I like to let it run for a few days to make sure it gets exposed to a bunch of price data and hopefully at least one trade before I merge it.

If you do test a new streaming exchange and it works for you please open a pull request and share your work with everyone else!

scionaltera commented 3 years ago

Closing this issue in favor of issues/PRs for specific exchanges. As it stands it will basically never be possible to close this issue and call it "done".