Pairs Trading with CryptocurrenciesThe article describes a brief introduction in pair trading including concept, basic math, strategy algorithm, trading robot development, backtesting and forwarding tests evaluation, and future problems discussion..As a practical example, the robot will trade on cryptocurrencies.ConceptPairs trading is a market-neutral trading strategy that employs a long position with a short position in a pair of highly co-moved assets.The strategy’s profit is derived from the difference in price change between the two instruments, rather than from the direction each moves..Therefore, a profit can be realized if the long position goes up more than the short, or the short position goes down more than the long (in a perfect situation, the long position rises and the short position falls, but that’s not a requirement for making a profit)..Finally, carry out the cointegration test for all pairs of assets.The performance of cryptocurrencies isPerformance of cryptocurrencies (from 2018–01–01 to 2018–05–31)The null-hypothesis is that there is no cointegration, the alternative hypothesis is that there is cointegrating relationship..If the p-value is small, below a critical size, then we can reject the hypothesis that there is no cointegrating relationship.Cointegration test resultWe can conclude that some of these pairs are cointegrated and could be selected for the next research.Trading strategyThere is no single approach in pairs trading how to calculate the spread and trade this..This step should be performed periodically for getting a pair (or several pairs) that will be used in the next steps.Get the price history of assets by length N..Check enter position rule:Open the long position for A (50% of capital) and the short position for B (50% of capital) if this condition is trueOpen the short position for A and the long position for B if this condition is true6..Let’s run this script using XMR/USD and NEO/USD pair and disabling commission costs and turn off slippage model.XMR/USD and NEO/USD with no commissionAs we see, the algorithm return curve is pretty good..It will allow to get more significant statistics, because the number of transactions will be greater.Experiment with cross currency pairs to reduce transactions costs (e.g. XMR/NEO instead of XMR/USD and NEO/USD).Adapt the following steps cointegration test — backtesting — forwarding for each pair in a portfolio to get more reliable performance in production mode..Parameters for tuning: length of history, p-value threshold, and algorithm’s parameters.ConclusionsDescribed the approach and created the algorithmic trading strategy.The algorithm has a positive result on the backtesting and forwarding tests.. More details