1 Introduction
Here you will assess trade flow as means of generating profit opportunities in 3 cryptotoken markets. We stress the word “opportunity” because at high data rates like these, and given the markets’ price-time priority, it is far easier to identify desirable trades in the data stream than it is to inject oneself profitably into the fray.
2 Data
We have preprocessed level 2 exchange messages from the Coinbase WebSocket API for you into a more digestible format.
2.1 Treatment
Load the 2021 data for all 3 pairs from the class website. For each one, split it into test and training sets, with your training set containing the first 20% of the data and the test set containing the remainder.
2.2 Format
The data has the following structure1 2.2.1 Trades
received utc nanoseconds
1618090137140737000 1618090137851379000 1618270615253262000 1618270616012160000
The Side is actually a
2.2.2 Book
timestamp utc nanoseconds
1618090137157544000 1618090137864544000 1618270615358639000 1618270616105583000
sum of trade sides at the same
PriceMillionths
35690 35700 35760 35760
price and time.
35690 11872084060 32957203990 35710 35680 30332423370 45284575470 1618090136378911000 1618090136388074000 35695
SizeBillionths Side
1000000 -1 29801980 2 2926932560 -1 16673940 -1
35770
35760 1255039420 24752612680 35780 35750 31011776970 41785630850 1618270617727565000 1618270617836039000 35765
Ask1PriceMillionths
Bid1PriceMillionths
Ask1SizeBillionths
Bid1SizeBillionths
Ask2PriceMillionths
Bid2PriceMillionths
Ask2SizeBillionths
Bid2SizeBillionths
received utc nanoseconds
timestamp utc nanoseconds
Mid 35695
(transposed)
35700
35690 11872084060 32957203990 35710 35680 31032423370 45284575470 1618090136351018000 1618090135799659000
35700
35770
35760 1255039420 24752612680 35780 35750 31011776970 41785630850 1618270617738680100 1618270617846283000 35765
1Note that inaccuracies in clock settings, i.e. “clock skew”, can cause timestamps to appear later than the time at which they are recorded as having been received.
1
3 Exercise
Write code to find τ-interval trade flow F(τ) just prior2 to each trade data point3 i. Compute T-second i
forward returns4 r(T). Regress them against each other in your training set, to find a coefficient β of i
regression.
For each data point in your test set you already have F(τ), so your return prediction is rˆ := β · F(τ).
Define a threshold j for rˆ and assume you might attempt to trade whenever j < |rˆ | . ii
4 Analysis
Assess the trading opportunities arising from using these return predictions in your test set. As part of this assessment, comment on the reliability of β, how you chose j, and what you might expect from using much longer training and test periods.
iii




