Market trades analytics with Jupyter/Pandas
Import data from csv files with market trade data and execution time. Parse data and analyze market trades quality based on a price after 5 seconds. Calculate correlation between trade quality estimation and trade execution time delta.
Python source code: github.com
(397802, 3)
mLog: market trd at 1622505601191796236 with side -1 price 1108.9 traded volume 36 then book became 6@1108.7x1108.8@104
side | price | bid_price | ask_price | mid_price | |
---|---|---|---|---|---|
ts | |||||
1622505601191796236 | -1 | 1108.9 | 1108.7 | 1108.8 | 1108.75 |
1622505601222248272 | -1 | 1108.7 | 1108.5 | 1108.6 | 1108.55 |
1622505601364445668 | -1 | 1108.5 | 1108.3 | 1108.6 | 1108.45 |
1622505601405325968 | 1 | 1108.6 | 1108.3 | 1108.6 | 1108.45 |
1622505601406994624 | -1 | 1108.3 | 1108.2 | 1108.3 | 1108.25 |
... | ... | ... | ... | ... | ... |
1627626542759155628 | 1 | 1150.5 | 1150.4 | 1150.5 | 1150.45 |
1627626543983252140 | 1 | 1150.5 | 1150.4 | 1150.5 | 1150.45 |
1627626549091604988 | 1 | 1150.5 | 1150.5 | 1150.6 | 1150.55 |
1627626549092524892 | -1 | 1150.5 | 1150.4 | 1150.6 | 1150.50 |
1627626549492660420 | -1 | 1150.5 | 1150.4 | 1150.6 | 1150.50 |
397802 rows × 5 columns
ts | side | price | delta | |
---|---|---|---|---|
0 | 1622505601222248272 | 1 | 1108.6 | 30451968 |
1 | 1622505601424113404 | -1 | 1108.4 | 17118720 |
2 | 1622505601604667896 | 1 | 1108.3 | 153866496 |
3 | 1622505602982200992 | -1 | 1108.4 | 153371136 |
4 | 1622505603600579508 | 1 | 1108.3 | 618378496 |
... | ... | ... | ... | ... |
8677 | 1627626326117581668 | 1 | 1149.9 | 2381312 |
8678 | 1627626397873668620 | -1 | 1150.2 | 1296281088 |
8679 | 1627626412584847188 | 1 | 1150.1 | 14703859968 |
8680 | 1627626473991536064 | -1 | 1150.4 | 12134184704 |
8681 | 1627626512859773452 | 1 | 1150.6 | 14734981632 |
8682 rows × 4 columns
ts | side | price | delta | plus_5s | market5s | mid_price | dmid5 | |
---|---|---|---|---|---|---|---|---|
0 | 1622505601222248272 | 1 | 1108.6 | 30451968 | 1622505606222248272 | 1622505606366905152 | 1108.65 | 0.05 |
1 | 1622505601424113404 | -1 | 1108.4 | 17118720 | 1622505606424113404 | 1622505606673089976 | 1108.45 | -0.05 |
2 | 1622505601604667896 | 1 | 1108.3 | 153866496 | 1622505606604667896 | 1622505606673089976 | 1108.45 | 0.15 |
3 | 1622505602982200992 | -1 | 1108.4 | 153371136 | 1622505607982200992 | 1622505608138958112 | 1108.55 | -0.15 |
4 | 1622505603600579508 | 1 | 1108.3 | 618378496 | 1622505608600579508 | 1622505608664219320 | 1108.35 | 0.05 |
... | ... | ... | ... | ... | ... | ... | ... | ... |
8677 | 1627626326117581668 | 1 | 1149.9 | 2381312 | 1627626331117581668 | 1627626333578804336 | 1149.85 | -0.05 |
8678 | 1627626397873668620 | -1 | 1150.2 | 1296281088 | 1627626402873668620 | 1627626406112129348 | 1150.15 | 0.05 |
8679 | 1627626412584847188 | 1 | 1150.1 | 14703859968 | 1627626417584847188 | 1627626419313019568 | 1150.15 | 0.05 |
8680 | 1627626473991536064 | -1 | 1150.4 | 12134184704 | 1627626478991536064 | 1627626480273596688 | 1150.45 | -0.05 |
8681 | 1627626512859773452 | 1 | 1150.6 | 14734981632 | 1627626517859773452 | 1627626518063036448 | 1150.55 | -0.05 |
8682 rows × 8 columns
-70.54999999999313
count 8682.000000 mean -0.008126 std 0.265246 min -15.650000 25% -0.050000 50% 0.000000 75% 0.050000 max 3.750000 Name: dmid5, dtype: float64
[<matplotlib.lines.Line2D at 0x1fd02101c10>]
count 8.682000e+03 mean 2.954101e+10 std 5.537083e+10 min 6.451200e+04 25% 2.091328e+06 50% 7.287985e+09 75% 3.679348e+10 max 9.150647e+11 Name: delta, dtype: float64
[<matplotlib.lines.Line2D at 0x1fd02531b50>]
<matplotlib.collections.PathCollection at 0x1fd0291f520>
Correlation: 0.022883958081705544
Comments
Post a Comment