
TL;DR
This paper presents an algorithm and source code for a statistical arbitrage strategy in cryptoassets, exploiting mean-reversion driven by momentum factors, with empirical validation and discussion of liquidity and trading implications.
Contribution
It introduces a novel arbitrage algorithm based on mean-reversion in cryptoassets and provides empirical evidence of its effectiveness across different assets.
Findings
Significant arbitrage alpha identified in specific cryptoasset cross-sections.
Empirical data supports the mean-reversion hypothesis in cryptoasset returns.
Discussion of liquidity considerations affecting arbitrage implementation.
Abstract
We give an algorithm and source code for a cryptoasset statistical arbitrage alpha based on a mean-reversion effect driven by the leading momentum factor in cryptoasset returns discussed in https://ssrn.com/abstract=3245641. Using empirical data, we identify the cross-section of cryptoassets for which this altcoin-Bitcoin arbitrage alpha is significant and discuss it in the context of liquidity considerations as well as its implications for cryptoasset trading.
| Quantity | Min | 1st Qu | Median | Mean | 3rd Qu | Max |
| Cap.1A | 1.19e+08 | 1.85e+08 | 5.13e+08 | 3.71e+09 | 1.86e+09 | 6.43e+10 |
| ADV.1A | 1.35e+06 | 9.90e+06 | 3.56e+07 | 5.03e+08 | 2.05e+08 | 5.18e+09 |
| Tvr.1A | 8.48e-03 | 2.92e-02 | 5.97e-02 | 1.93e-01 | 2.08e-01 | 1.93e+00 |
| Cap.1B | 3.75e+07 | 4.45e+07 | 5.77e+07 | 6.94e+07 | 9.85e+07 | 1.16e+08 |
| ADV.1B | 4.04e+04 | 6.59e+05 | 1.91e+06 | 3.76e+06 | 3.57e+06 | 2.08e+07 |
| Tvr.1B | 9.94e-04 | 9.90e-03 | 3.02e-02 | 5.15e-02 | 5.23e-02 | 3.01e-01 |
| Cap.1C | 1.66e+07 | 2.00e+07 | 2.42e+07 | 2.50e+07 | 2.81e+07 | 3.71e+07 |
| ADV.1C | 1.29e+03 | 3.22e+05 | 5.23e+05 | 1.90e+06 | 1.34e+06 | 1.75e+07 |
| Tvr.1C | 7.78e-05 | 1.20e-02 | 2.30e-02 | 6.80e-02 | 6.19e-02 | 5.85e-01 |
| Cap.1D | 4.38e+06 | 5.98e+06 | 7.62e+06 | 8.72e+06 | 1.10e+07 | 1.63e+07 |
| ADV.1D | 3.67e+02 | 4.10e+04 | 1.79e+05 | 7.94e+05 | 5.29e+05 | 3.14e+07 |
| Tvr.1D | 5.40e-05 | 6.03e-03 | 2.40e-02 | 1.12e-01 | 6.38e-02 | 4.83e+00 |
| Cap.1E | 1.02e+06 | 1.43e+06 | 2.20e+06 | 2.34e+06 | 2.96e+06 | 4.37e+06 |
| ADV.1E | 4.00e+02 | 3.60e+03 | 1.16e+04 | 1.14e+05 | 4.56e+04 | 3.04e+06 |
| Tvr.1E | 1.45e-04 | 2.00e-03 | 5.49e-03 | 4.56e-02 | 2.48e-02 | 1.02e+00 |
| Cap.1F | 8.82e+03 | 1.60e+05 | 4.22e+05 | 4.37e+05 | 7.15e+05 | 1.02e+06 |
| ADV.1F | 1.10e+01 | 4.97e+02 | 1.47e+03 | 4.50e+04 | 8.13e+03 | 3.54e+06 |
| Tvr.1F | 1.38e-04 | 1.87e-03 | 5.28e-03 | 1.09e-01 | 2.18e-02 | 9.38e+00 |
| Cap.2 | 2.44e+04 | 1.09e+06 | 4.70e+06 | 3.00e+08 | 2.49e+07 | 1.35e+10 |
| ADV.2 | 7.70e+01 | 4.30e+03 | 2.72e+04 | 3.75e+07 | 3.98e+05 | 2.75e+09 |
| Tvr.2 | 7.78e-05 | 2.34e-03 | 8.75e-03 | 3.24e-02 | 2.35e-02 | 5.03e-01 |
| Cap.3 | 6.70e+04 | 1.24e+06 | 5.07e+06 | 5.05e+08 | 2.21e+07 | 1.35e+10 |
| ADV.3 | 8.30e+01 | 7.06e+03 | 3.64e+04 | 6.14e+07 | 2.37e+05 | 2.75e+09 |
| Tvr.3 | 7.64e-04 | 2.33e-03 | 8.32e-03 | 2.67e-02 | 2.36e-02 | 2.75e-01 |
| Cap.4 | 6.70e+04 | 2.34e+06 | 8.30e+06 | 4.60e+08 | 3.62e+07 | 1.35e+10 |
| ADV.4 | 8.30e+01 | 8.88e+03 | 7.95e+04 | 2.99e+07 | 3.85e+05 | 5.27e+08 |
| Tvr.4 | 7.64e-04 | 2.25e-03 | 9.47e-03 | 2.72e-02 | 2.32e-02 | 2.75e-01 |
| Cap.5 | 1.31e+06 | 4.57e+06 | 1.27e+07 | 1.31e+09 | 8.23e+07 | 1.35e+10 |
| ADV.5 | 3.07e+03 | 1.88e+04 | 6.18e+04 | 8.67e+07 | 4.53e+06 | 5.27e+08 |
| Tvr.5 | 1.05e-03 | 2.33e-03 | 9.12e-03 | 3.64e-02 | 1.86e-02 | 2.75e-01 |
| Lookback | rank | ROC (%) | Sharpe |
|---|---|---|---|
| 1A | 2-30 | -44.25 | -1.81 |
| 1B | 31-60 | -59.29 | -1.99 |
| 1C | 61-100 | -24.78 | -0.83 |
| 1D | 101-200 | 11.26 | 0.43 |
| 1E | 201-300 | 124.43 | 4.93 |
| 1F | 301-417 | 459.08 | 14.65 |
| 2 | 2-121 | 174.7 | 4.2 |
| 3 | 2-67 | 222.75 | 4.06 |
| 4 | 2-44 | 191.43 | 4.34 |
| 5 | 2-13 | 62.27 | 1.28 |
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Altcoin-Bitcoin Arbitrage
Zura Kakushadze§*†*111 Zura Kakushadze, Ph.D., is the President of Quantigic® Solutions LLC, and a Full Professor at Free University of Tbilisi. Email: [email protected] and Willie Yu♯222 Willie Yu, Ph.D., is a Research Fellow at Duke-NUS Medical School. Email: [email protected]
§* Quantigic® Solutions LLC*
1127 High Ridge Road #135, Stamford, CT 06905 333 DISCLAIMER: This address is used by the corresponding author for no purpose other than to indicate his professional affiliation as is customary in publications. In particular, the contents of this paper are not intended as an investment, legal, tax or any other such advice, and in no way represent views of Quantigic® Solutions LLC, the website www.quantigic.com or any of their other affiliates.
†* Free University of Tbilisi, Business School & School of Physics*
240, David Agmashenebeli Alley, Tbilisi, 0159, Georgia
♯* Centre for Computational Biology, Duke-NUS Medical School*
8 College Road, Singapore 169857
(January 27, 2019)
We give an algorithm and source code for a cryptoasset statistical arbitrage alpha based on a mean-reversion effect driven by the leading momentum factor in cryptoasset returns discussed in https://ssrn.com/abstract=3245641. Using empirical data, we identify the cross-section of cryptoassets for which this altcoin-Bitcoin arbitrage alpha is significant and discuss it in the context of liquidity considerations as well as its implications for cryptoasset trading.
1 Introduction
There is a sizable proliferation of cryptoassets,444 For the purposes of this note, cryptoassets include digital cryptography-based assets such as cryptocurrencies (e.g., Bitcoin), as well various other digital “coins” and “tokens” (minable as well as non-minable), that have data on https://coinmarketcap.com. whose number according to https://coinmarketcap.com was 2,116 as of January 18, 2019. Just as with stocks (and other asset classes), there appear to be underlying common factors for cryptoasset returns, at least on shorter-horizons [Kakushadze, 2018].555 [Kakushadze, 2018] extends short-horizon equity factors [Kakushadze, 2015] to cryptoassets. Thus, the leading common factor in the daily close-to-close cryptoasset returns is the prior day’s momentum (“mom”), and on average the subsequent open-to-close return is negatively correlated with mom. So, there is a mean-reversion effect in daily cryptoasset returns.
Can we utilize this mean-reversion effect to construct a trading signal (alpha)? The mean-reversion here is cross-sectional, so such an alpha would (ideally) involve a sizable cross-section of cryptoassets. In the case of stocks one can construct a dollar-neutral mean-reversion strategy by going long a sizable number of stocks with the investment level and simultaneously shorting a sizable number of stocks with the investment level , with (so we have dollar-neutrality), which is a standard long-short statistical arbitrage strategy. Alternatively, one can go long a sizable number of stocks with the investment level and simultaneously short an index futures with the investment level (again, ), e.g., S&P 500 futures, in which case we have a dollar-neutral so-called S&P 500 outperformance strategy.
We can attempt to do something similar with cryptoassets. However, shorting a sizable number of cryptoassets is not practicable. We can short Bitcoin futures666 For a discussion on Bitcoin futures, see, e.g., [Hale et al, 2018]. instead. The long position then can be in a sizable number of cryptoassets other than Bitcoin, i.e., altcoins. We then have a Bitcoin outperformance strategy, which we refer to as altcoin-Bitcoin arbitrage.777 For some cryptoasset investment and trading related literature, see, e.g., [Alessandretti et al, 2018], [Amjad and Shah, 2017], [Baek and Elbeck, 2014], [Bariviera et al, 2017], [Bouoiyour et al, 2016], [Bouri et al, 2017], [Brandvold et al, 2015], [Brière, Oosterlinck and Szafarz, 2015], [Cheah and Fry, 2015], [Cheung, Roca and Su, 2015], [Ciaian, Rajcaniova and Kancs, 2015], [Colianni, Rosales and Signorotti, 2015], [Donier and Bouchaud, 2015], [Dyhrberg, 2015], [Eisl, Gasser and Weinmayer, 2015], [ElBahrawy et al, 2017], [Gajardo, Kristjanpoller and Minutolo, 2018], [Garcia and Schweitzer, 2015], [Georgoula et al, 2015], [Harvey, 2016], [Jiang and Liang, 2017], [Kim et al, 2016], [Kristoufek, 2015], [Lee, Guo and Wang, 2018], [Li et al, 2018], [Liew and Hewlett, 2017], [Liew, Li and Budavári, 2018], [Nakano, Takahashi and Takahashi, 2018], [Ortisi, 2016], [Shah and Zhang, 2014], [Van Alstyne, 2014], [Vo and Yost-Bremm, 2018], [Wang and Vergne, 2017]. So, the idea is simple. We maintain a short Bitcoin position with the investment level (so we do not trade Bitcoin). The long position consists of a cross-section of altcoins, which changes daily based on their mom values, so we either establish or liquidate long altcoin positions, but never short them. We discuss some simple trading rules for altcoin positions in Section 2.
The next question is whether the alpha is “tradable”. The main considerations are transaction costs and liquidity. In this note we focus on liquidity considerations. Does this alpha work across essentially all cryptoassets, or is its performance correlated with their liquidity? We address this question empirically in Section 3. We briefly conclude in Section 4. Appendix A gives R source code for building the portfolio and backtesting it.888 The source code given in Appendix A hereof is not written to be “fancy” or optimized for speed or in any other way. Its sole purpose is to illustrate the algorithms described in the main text in a simple-to-understand fashion. Some important legalese is relegated to Appendix B. Tables and figures summarize our backtesting results.
2 Alpha
2.1 Setup and Data
Cryptoassets trade continuously, 24/7.999 Assuming no special circumstances such as trading halts. Thus, “open” on any given day means the price right after midnight (UTC time), while “close” on any given day means the price right before midnight (UTC time), so the open on a given day is almost the same as the close of the previous day. All prices (open, close, high, low), volume and market cap are measured in dollars. The index labels different cryptoassets cross-sectionally, while the index labels the dates, with corresponding to the most recent date in the time series. So: (or, equivalently, ) is the close price for the cryptoasset labeled by on the day labeled by ; is the open price; is the high price; is the low price; is the daily dollar volume; is the market cap.101010 High, low and volume are measured between the open and the close of a given day. All our data was freely downloaded (see below).
We define daily open-to-close log-returns (or “continuously compounded” returns), which we use to define the mom factor as in [Kakushadze, 2018] (see below):
[TABLE]
For small values it is approximately the same as the standard (“single-period”) return defined as
[TABLE]
For computing portfolio P&L, return, Sharpe ratio [Sharpe, 1994], etc., we use .
2.2 Momentum
There are various ways to define the momentum factor (mom). For our purposes here, we will define it as in [Kakushadze, 2018]:
[TABLE]
This definition is 100% out-of-sample: we use for trading on the date labeled by , and is computed using quantities from the prior date labeled by .
2.3 Trading Signal
The trading signal (alpha) for altcoins is defined as follows:
[TABLE]
where the Heaviside function if , and if . So, we establish a new long altcoin position, or maintain an existing long altcoin position, if mom is negative. If mom is nonnegative, then we do not establish a new altcoin position, and liquidate an existing long altcoin position. All altcoin positions are long or null. Meanwhile, we continuously maintain a constant short Bitcoin position.111111 Technically, this should be short Bitcoin futures, but we assume a short Bitcoin position.
2.4 Altcoin Weights
Let us assume that the constant short Bitcoin position has the investment level . Let the total investment level of our long altcoin position be . To have a dollar-neutral portfolio, we must set . Let be the individual altcoin dollar holdings. Let us use the labels for altcoins, while will correspond to Bitcoin. We can define the altcoin weights as . Then we have ():
[TABLE]
The simplest choice for the weights is to have equal weights for all altcoins with nonzero signals:
[TABLE]
Other weighting schemes are possible, e.g., by suppressing the weights by volatility:
[TABLE]
Here is historical volatility (e.g., the standard deviation of the returns computed over previous days , or the hlv factor defined in [Kakushadze, 2018], etc.), while the normalization coefficients , are fixed via Eq. (5). In our backtests (see below) we focus on equally weighted portfolios (6).
3 Backtests
3.1 Estimation Period and Universe
We downloaded121212 R source code for data downloads is given in Appendix A of [Kakushadze, 2018]. This code still works with two minor tweaks. First, the line u <- c(x[22:28]) in the function crypto.data() now reads u <- c(x[22:27]) due to a formatting change on https://coinmarketcap.com. Second, in the function crypto.hist.prc(), right after the line shared.write.table(x, file, T), one should now include the following (or similar) line: Sys.sleep(max(rnorm(1, 10, 2), 5)) (which spaces downloads at random intervals). This is due to the apparent change at https://coinmarketcap.com, which averts “rapid-fire” (i.e., continuous serial) downloads. the data from https://coinmarketcap.com for all 2,116 cryptoassets as of January 19, 2019 (so the most recent date in the data is January 18, 2019), and 2,115 cryptoassets had downloadable data, albeit for many various fields were populated with “?”, which we converted into NAs. In our backtests (see below), we only kept cryptoassets with non-NA price (open, close, high, low), volume and market cap data, with an additional filter that no null volume was allowed either.131313 This is to avoid stale prices. Further, 2 cryptoassets had apparently “artifact” stale prices during some periods, so they were also excluded from the corresponding backtests (see below).
Cboe Bitcoin Futures (symbol XBT)141414 Which is the actual investment vehicle we implicitly assume for our short Bitcoin position. started trading on December 10, 2017. So, technically speaking, backtesting the strategy before that time might not be particularly meaningful.151515 Especially considering the effect Bitcoin futures arguably had on Bitcoin (and other cryptoassets) – see, e.g., [Hale et al, 2018]. For a nontechnical discussion, see, e.g., [Kelleher, 2018]. Still, although we primarily focus on the 1-year backtest (looking back from January 18, 2019), for comparison and completeness purposes we also run 2-, 3-, 4- and 5-year lookback backtests. For the 1-year backtest we have 417 cryptoassets with historical data, while for the 2-, 3-, 4- and 5-year backtests we have 121, 67, 44 and 13 cryptoassets, respectively.161616 These counts include Bitcoin. Also, these counts exclude the aforesaid 2 cryptoassets with apparently “artifact” stale prices during some periods. Finally, in 2-year and longer backtests the cryptoasset “Circuit of Value Coin” (symbol COVAL) is excluded as it had an extraordinarily large positive return in a short time period and including it would misleadingly “rosy-up” the results. For the 1-year backtest we further break up the universe of the 416 altcoins (which together with Bitcoin make up the aforesaid 417 cryptoassets) into market cap tiers A,B,C,D,E,F. Thus, the alpha based on tier A on any given day goes long only the altcoins whose market cap on the previous day ranks 2 to 30 among all cryptoassets. Similarly, for tiers B,C,D,E,F the corresponding market cap rank ranges are: 31-60, 61-100, 101-200, 201-300, 301-417. In fact, based on our results (see below), running a backtest for the full universe of all 416 altcoins would obscure the liquidity effect (see below).
3.2 Results
For various universes mentioned above, Table 1 summarizes the market cap, the 20-day average daily volume, and the daily “turnover” defined as the market cap divided by the 20-day average daily volume. Table 2 and Figures 1-10 summarize the backtest results. These results suggest that the altcoin-Bitcoin arbitrage alpha is a low-liquidity effect. It simply is not there for higher liquidity altcoins. However, the alpha – which hinges on the mean-reversion effect based on the prior day’s momentum (mom) – is real. Thus, if for the universe 1E (see Tables 1 and 2) we reverse the signal, we get ROC = -235.16% and Sharpe = -7.18, and if we go long all altcoins with equal weights in this universe (irrespective of mom),171717 In this case we have a quasi-static (the altcoin universe can change with market cap fluctuations) dollar-neutral portfolio, which is obtained by setting () in Eq. (6). we get ROC = -26.56% and Sharpe = -1.34. Conversely, if we reverse the signal for, say, the universe 1A, we do not get a positive return. Therefore, the altcoin-Bitcoin arbitrage alpha appears to be a real effect owing to low liquidity of the altcoins for which it is present. Put differently, the alpha exists as it cannot be arbitraged away.
4 Concluding Remarks
So, the altcoin-Bitcoin arbitrage alpha we discuss above is essentially is “a low-liquidity premium” in altcoin returns. In practice, to arbitrage it, one must account for trading costs – both transaction costs and market impact. For low-liquidity altcoins the market impact can quickly become prohibitive when attempting to execute sizable trades. In fact, for the 2-year, 3-year, 4-year and 5-year lookbacks (where the number of altcoins with historical data is smaller) the naïve pickup in the performance is due to the fact that most of the altcoins in these universes, even though they have been around for a while, are lower-cap, lower-liquidity cryptoassets (which is a telltale sign for persistence), with the notable exception of XRP (Ripple), which is what “Max” in the market cap corresponds to in Table 1 for these universes.
Can the altcoin-Bitcoin arbitrage alpha – or the momentum indicator on which it is based – be useful outside outright arbitraging it (which may be challenging due to the liquidity considerations)? Perhaps. In a sideways cryptoasset market, this indicator could be used as a guide for executing trades for lower-liquidity altcoins in other contexts. Thus, statistically, we expect that there is a mean-reversion effect, and if its yesterday’s momentum is positive, today an altcoin (on average) is expected to trade lower, and if its yesterday’s momentum is negative, today said altcoin (on average) is expected to trade higher. This can then conceivably be used as a “shorter-horizon” (daily) execution signal for longer-horizon trades. It should be mentioned, however, that the aforesaid alpha is a statistical effect, which is expected to work better for a sizable cross-section of altcoins, so using it as a “shorter-horizon” execution signal for such sizable cross-sections of altcoins would make more sense than for a single (or a few) altcoin(s). In this regard, let us mention [Liew, Li and Budavári, 2018], whose conclusion is that forecasting (using machine learning techniques) short-horizon single-cryptoasset returns (for the top 100 cryptoassets by market cap) appears to be challenging. This also bodes well with our findings here.
Appendix A R Source Code: Trading Signal
In this appendix we give R (R Project for Statistical Computing, https://www.r-project.org/) source code for computing the altcoin-Bitcoin arbitrage trading signal. The sole function crypto.arb() reads the aggregated data files cr.prc.txt (close price), cr.open.txt (open price), cr.high.txt (high price), cr.low.txt (low price), cr.vol.txt (dollar volume), cr.cap.txt (market cap), cr.name.txt (names of the cryptoassets in the same order as all the other files), and cr.mnbl.txt (1 if the name is minable, otherwise 0) generated by the function crypto.prc.files() of [Kakushadze, 2018] (also, see fn.12 hereof). Internally, crypto.arb() computes the av (average volume), size (market cap), mom (momentum), hlv (intraday volatility) factors of [Kakushadze, 2018] and the trading signal based on mom (together with the trading universe based on size). The inputs of crypto.arb() are days (the length of the selection period used in fixing the cryptoasset universe by applying the aforesaid non-NA data and non-zero volume filters, which period is further “padded” – see below), back (the length of the skip period, i.e., how many days to skip in the selection period before the lookback period),181818 In our backtests we always set back = 0. Also note that mnbl and av are not used internally. lookback (the length of the lookback period over which the backtest is run), d.r (the extra “padding” added to the selection period plus one day, so the moving averages can be computed out-of-sample; we take d.r = 20), d.v (the av moving average length; we take d.v = 20), d.i (the hlv moving average length; we take d.i = 20), ix.upper (the rank of the highest market cap (as of the previous day) altcoin to include in the trading universe), and ix.lower (the rank of the lowest market cap (as of the previous day) altcoin to include in the trading universe). The function crypto.arb() internally computes and plots/outputs the daily P&L and annualized ROC and Sharpe ratio.
crypto.arb <- function (days = 365, back = 0, lookback = days,
d.r = 20, d.v = 20, d.i = 20, ix.lower = NA, ix.upper = 2)
{
read.prc <- function(file, header = F, make.numeric = T)
{
x <- read.delim(file, header = header)
x <- as.matrix(x)
if(make.numeric)
mode(x) <- "numeric"
return(x)
}
calc.mv.avg <- function(x, days, d.r)
{
if(d.r == 1)
return(x[, 1:days])
y <- matrix(0, nrow(x), days)
for(i in 1:days)
y[, i] <- rowMeans(x[, i:(i + d.r - 1)], na.rm = T)
return(y)
}
prc <- read.prc("cr.prc.txt")
cap <- read.prc("cr.cap.txt")
high <- read.prc("cr.high.txt")
low <- read.prc("cr.low.txt")
vol <- read.prc("cr.vol.txt")
open <- read.prc("cr.open.txt")
mnbl <- read.prc("cr.mnbl.txt")
name <- read.prc("cr.name.txt", make.numeric = F)
d <- days + d.r + 1
prc <- prc[, 1:d]
cap <- cap[, 1:d]
high <- high[, 1:d]
low <- low[, 1:d]
vol <- vol[, 1:d]
open <- open[, 1:d]
take <- rowSums(is.na(prc)) == 0 & rowSums(is.na(cap)) == 0 &
rowSums(is.na(high)) == 0 & rowSums(is.na(low)) == 0 &
rowSums(is.na(vol)) == 0 & rowSums(is.na(open)) == 0 &
rowSums(vol == 0) == 0
ret <- log(prc[take, -d] / prc[take, -1])
ret.d <- prc[take, -d] / prc[take, -1] - 1
prc <- prc[take, -1]
cap <- cap[take, -1]
high <- high[take, -1]
low <- low[take, -1]
vol <- vol[take, -1]
open <- open[take, -1]
mnbl <- mnbl[take, 1]
name <- name[take, 1]
if(back > 0)
{
ret <- ret[, (back + 1):ncol(ret)]
ret.d <- ret[, (back + 1):ncol(ret)]
prc <- prc[, (back + 1):ncol(prc)]
cap <- cap[, (back + 1):ncol(cap)]
high <- high[, (back + 1):ncol(high)]
low <- low[, (back + 1):ncol(low)]
vol <- vol[, (back + 1):ncol(vol)]
open <- open[, (back + 1):ncol(open)]
}
days <- lookback
av <- log(calc.mv.avg(vol, days, d.v))
hlv <- (high - low)^2 / prc^2
hlv <- 0.5 * log(calc.mv.avg(hlv, days, d.i))
take <- rowSums(!is.finite(hlv)) == 0 ### removes stale prices
av <- av[take, ]
hlv <- hlv[take, ]
mom <- log(prc[take, 1:days] / prc[take, 1:days + 1])
size <- log(cap)[take, 1:days]
ret <- ret[take, 1:days]
ret.d <- ret.d[take, 1:days]
mnbl <- mnbl[take]
name <- name[take]
pnl <- rep(0, days)
for(i in days:1)
{
x <- -sign(mom[, i]) ### momentum based trading signal
x[] <- 1 ### no signal
x <- -x ### reverse signal
sort.size <- sort(size[, i], decreasing = T)
if(is.na(ix.lower))
ix.lower <- length(sort.size)
take <- size[, i] >= sort.size[ix.lower] &
size[, i] <= sort.size[ix.upper] ### cap tier based universe
x[!take] <- 0
x[1] <- 0
if(days > 365)
x[name == "Circuits of V..." ] <- 0 ### removes COVAL
x[x < 0] <- 0
ss <- exp(hlv[, i]) ### hlv based volatility
ss can be computed e.g. as 20-day historical return volatility
x <- x / ss ### volatility-suppressed signal
x <- x * abs(mom[, i]) / ss^2 ### alternative suppression
x <- x / sum(abs(x))
x <- x * ret.d[, i]
x <- sum(x) - ret.d[1, i]
if(!is.finite(x))
x <- 0
pnl[i] <- x
}
pnl1 <- pnl
pnl <- pnl[days:1]
pnl <- cumsum(pnl)
plot(1:days, pnl, type = "l",
col = "green", xlab = "days", ylab = "P&L")
roc <- round(mean(pnl1) * 365 / 2 * 100, 2) ### annualized ROC
sr <- round(mean(pnl1) / sd(pnl1) * sqrt(365), 2) ### annualized Sharpe
print(roc)
print(sr)
}
Appendix B DISCLAIMERS
Wherever the context so requires, the masculine gender includes the feminine and/or neuter, and the singular form includes the plural and vice versa. The author of this paper (“Author”) and his affiliates including without limitation Quantigic® Solutions LLC (“Author’s Affiliates” or “his Affiliates”) make no implied or express warranties or any other representations whatsoever, including without limitation implied warranties of merchantability and fitness for a particular purpose, in connection with or with regard to the content of this paper including without limitation any code or algorithms contained herein (“Content”).
The reader may use the Content solely at his/her/its own risk and the reader shall have no claims whatsoever against the Author or his Affiliates and the Author and his Affiliates shall have no liability whatsoever to the reader or any third party whatsoever for any loss, expense, opportunity cost, damages or any other adverse effects whatsoever relating to or arising from the use of the Content by the reader including without any limitation whatsoever: any direct, indirect, incidental, special, consequential or any other damages incurred by the reader, however caused and under any theory of liability; any loss of profit (whether incurred directly or indirectly), any loss of goodwill or reputation, any loss of data suffered, cost of procurement of substitute goods or services, or any other tangible or intangible loss; any reliance placed by the reader on the completeness, accuracy or existence of the Content or any other effect of using the Content; and any and all other adversities or negative effects the reader might encounter in using the Content irrespective of whether the Author or his Affiliates is or are or should have been aware of such adversities or negative effects.
The R code included in Appendix A hereof is part of the copyrighted R code of Quantigic® Solutions LLC and is provided herein with the express permission of Quantigic® Solutions LLC. The copyright owner retains all rights, title and interest in and to its copyrighted source code included in Appendix A hereof and any and all copyrights therefor.
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1[1]
- 2Alessandretti et al , 2018 Alessandretti, L., El Bahrawy, A., Aiello, L.M. and Baronchelli, A. (2018) Machine Learning the Cryptocurrency Market. Working Paper. Available online: https://arxiv.org/pdf/1805.08550.pdf .
- 3Amjad and Shah, 2017 Amjad, M.J. and Shah, D. (2017) Trading Bitcoin and Online Time Series Prediction. Working Paper. Available online: http://proceedings.mlr.press/v 55/amjad 16.pdf .
- 4Baek and Elbeck, 2014 Baek, C. and Elbeck, M. (2014) Bitcoins as an Investment or Speculative Vehicle? A First Look. Applied Economics Letters 22(1): 30-34.
- 5Bariviera et al , 2017 Bariviera, A.F., Basgall, M.J., Hasperué, W. and Naiouf, M. (2017) Some stylized facts of the Bitcoin market. Physica A: Statistical Mechanics and its Applications 484: 82-90.
- 6Bouoiyour et al , 2016 Bouoiyour, J., Selmi, R., Tiwari, A.K. and Olayeni, O.R. (2016) What drives Bitcoin price? Economics Bulletin 36(2): 843-850.
- 7Bouri et al , 2017 Bouri, E., Molnár, P., Azzi, G., Roubaud, D. and Hagfors, L.I. (2017) On the hedge and safe haven properties of Bitcoin: Is it really more than a diversifier? Finance Research Letters 20: 192-198.
- 8Brandvold et al , 2015 Brandvold, M., Molnár, P., Vagstad, K. and Valstad, O.C.A. (2015) Price discovery on Bitcoin exchanges. Journal of International Financial Markets, Institutions and Money 36: 18-35.
