26 lines
1.1 KiB
Python
26 lines
1.1 KiB
Python
import pandas as pd, numpy as np, glob
|
|
|
|
files = sorted(glob.glob('/mnt/d/PaperTrader/research/hl_data/minutes/202603*/*.parquet'))
|
|
dfs = [pd.read_parquet(f) for f in files]
|
|
df = pd.concat(dfs, ignore_index=True)
|
|
btc = df[df.coin=='BTC'].sort_values('minute').reset_index(drop=True)
|
|
print('rows:', len(btc), ' cols:', list(btc.columns))
|
|
for h in [60, 240, 720, 1440, 2880]:
|
|
btc[f'fwd_{h}'] = (btc['mid_price'].shift(-h)/btc['mid_price']-1).abs()*10000
|
|
print()
|
|
print('CORRELATION WITH abs forward return:')
|
|
print(f'{'var':<22} h=60 h=240 h=720 h=1440 h=2880')
|
|
for col in ['signed_flow_usd','taker_buy_usd','taker_sell_usd','trade_count','large_print_cnt','wallet_entropy','vwap_drift']:
|
|
if col in ['taker_buy_usd','taker_sell_usd','trade_count']:
|
|
x = np.log1p(btc[col].abs())
|
|
elif col == 'large_print_cnt':
|
|
x = np.log1p(btc[col])
|
|
else:
|
|
x = btc[col]
|
|
row = f'{col:<22}'
|
|
for h in [60,240,720,1440,2880]:
|
|
m = btc[f'fwd_{h}'].notna() & x.notna()
|
|
r = np.corrcoef(x[m], btc[f'fwd_{h}'][m])[0,1]
|
|
row += f' {r:+.3f}'
|
|
print(row)
|