Hi, At https://bitbank.nz we are a cryptocurrency forecasting dashboard providing live forecasts for pro trader across 70+ cryptocurrency markets using machine learning.
In addition to testing our forecast accuracy we also test on a few other levels too, including sporadic experiments with live trading based on our forecasted recomended buy/sell points.
Here we tested out purely spread based trading for following the predictions as is on a btc/sc market pair.
Over roughly 1 day 8 hours we put in ~ .01 BTC and ended up with a P&L of ~ --0.00011783 ending up with roughly 0.00988217 BTC afterwards, roughly 1.2% loss whereas holding the coin from 60 to 55 would have been around a 9.5% loss with trading fees
This was executed as the price of Siacoin ranged from at first 0.00000060 to 62 to 48 and then 55, for a fairly dramatic crash in the market while we where trading, the algorithm held up without major losses.
After executing 757 trades and paying
0.00047354 BTC in fees given to poloniex making up the majority of the losses another 871.8223067 of siacoin was taken in poloniex fees which brings the fees to 0.0009537222687 a steep .95% fee
poloniex fees are only on the selling side, in this case we where sending postOnly=1 which as described in the API only allows your orders to be placed if none of it fills straight away meaning you wont pay higher taker fees, but as you can see poloniex does not always respect that flag and sometimes we end up paying a .25% fee :/
The tests where ran in what was a bull market for bitcoin and a bear market for altcoins as bitcoin soared much of the value came out of the altcoin markets into bitcoin.
This was an exercise in market making, by picking a coin like siacoin with a low value like siacoin you can guarantee that there is a large spread because of the limited accuracy in poloniex, this means the sells may be at 61 and buys at 60 (no 60.5) so the spread would be 1.6% and executing a buy and quickly selling would mean making 1.6 - .15=1.45% profit also has a high trading volume which gave us the ability to execute so many trades in this relatively small time period that should utilise this spread (trading roughly every 2.5 minutes)
Why are trades not happening enough?
To give an algorithm more power it would be able to trade across coins too, you can exclude certain pairs/markets that trades aren't happening under if they are too illiquid or weight markets by trade volume.
If the best ask/buy prices aren't causing trades to happen then you can tweak a percentage to move towards the middle of the orderbook for pairs with less spread like eth btc and ltc
Charts of recommended buy/sell prices over time
keep in mind that when looking at our live charts, with an automated trading system the orders are left open for some discrete period of time after placed and there is variation in the pricing not shown in our graphs of orderbook snapshots over time, sometimes the orderbook will move with a bit of variance and return in the 5-20 seconds between we snapshot the best ask/bid, that is sometimes there are flash crashes/rises that mean your trade unexpectadly goes through.
Volatility in High Spread Markets
An interesting observation is that sometimes coins with more spread can move more and have more uncertainty, youll notice in a fairly illiquid pair with more spread like Bitcoin/Omni that the trades will be farther away from the orderbook midpoint, their are points in the graph where there is not enough trades happening for us to make a forecast. Perhaps this uncertainty is coming from low volumes in this case but in general high spread enecourages trades to be farther apart and that's why our graphs of weighted trade averages show now more volatility (volatility in profits is really there even if the price isn't moving anywhere the value is).
Instead of thinking about volatility in terms of price think about volatility in terms of where value is moving, spread is another dimension to consider aswell as just price movements.
We use The BitBank.nz soon to be released live prediction API for python allowing us to subscribe to updates from Firebase and we simply apply orders based on the given recommended buy and sell points every 10 seconds, we keep building up orders until when the predictions change when we cancel all our old orders, This file is ran in a loop in bash with the
watch python follower_bot.py command in case it randomly crashes for any unknown reason (seemed to be okay).
We didn't bother checking if the forecasts where anomalous or out of date here which should be done in a production system.
We will put this up on Github soon :)
import time import firebase_admin import google as google from firebase_admin import credentials from firebase_admin import firestore from config import poloniex # Use a service account cred = credentials.Certificate('webapp/bitbank-nz-04b5c59a29d0.json') firebase_admin.initialize_app(cred) db = firestore.client() prev_price_cache = (0,0) while True: PAIR = "BTC_BCN" doc_ref = db.collection("featuresets").document(PAIR) try: doc = doc_ref.get() doc = doc.to_dict() except google.cloud.exceptions.NotFound: print(u'No such document!') btc_amount_we_have_to_trade = 0.002 curr_prices = (doc['recommended_buy'], doc['recommended_sell']) buy_amount = btc_amount_we_have_to_trade / float(doc['recommended_buy']) if prev_price_cache != curr_prices: poloniex.cancellAllOrders() prev_price_cache = curr_prices poloniex.buy(PAIR, float(doc['recommended_buy']), buy_amount) poloniex.sell(PAIR, float(doc['recommended_sell']), 1000) time.sleep(10)
We would like to to start doing more spread based high frequency trading as we believe there's still room to improve on our algorithms and this simple test has shown there's profitability to be made doing simple spread based automated trading especially if markets are trending up.
A more production ready system would also weight the trades by a probability of getting accepted which we currently don't do, this could take into account how liquid specific pairs are and how close the bid/ask is to the midpoint, then the expected profit would be multiplied by the probability of getting accepted on the current markets to give a better idea of the value of a trade, once you have the value of a trade you'd want to ensure you only place the trade(s) with maximum value and if you have multiple trades operations e.g. if your holding both btc and eth then order the trades by expected value and send the ones that will make the most profit to the exchange first.
Production trading systems also need contingency measures for when systems are down and contain fallbacks for what to do if either bitbanks forecasts or the exchanges experienced outages/degraded performance.
We consider the experiment in automated trading a success despite the loss and will try other various markets and more sophisticated algorithms and share the results in our effort to bring you the most accurate altcoin predictions and charts.
A sheet containing all the poloniex trades exported and an extra column to calculate the fees can be seen here https://docs.google.com/spreadsheets/d/189H4OQLEPlkPErV8pphi0Lv5rqlctQ1Axd4YvAPtszM/edit?usp=sharing
Our algorithm was disadvantaged in that it wasn't trading in a balanced margin lending style where it would have been able to sell and make money on the crash, its only option to start out with was to move money to sia rather than shorting siacoin, whether it would have capitalised on that opportunity is yet to be proved.
Keep in mind trading algorithms are often sensitive to noise, outliers and unforeseeable market conditions yet can be profitable in the long run.
Also checkout our referral program to earn .003 BTC every paying user referred.