Skip to content

Instantly share code, notes, and snippets.

@Skanda319
Created October 18, 2019 00:46
Show Gist options
  • Save Skanda319/05a29677fd9767c21d35a217f6b90cec to your computer and use it in GitHub Desktop.
Save Skanda319/05a29677fd9767c21d35a217f6b90cec to your computer and use it in GitHub Desktop.
x_cols = ['AdrActCnt', 'BlkCnt', 'BlkSizeByte', 'BlkSizeMeanByte', 'CapMVRVCur',
'CapMrktCurUSD', 'CapRealUSD', 'DiffMean', 'FeeMeanNtv', 'FeeMeanUSD', 'IssContNtv',
'IssContPctAnn', 'IssContUSD', 'IssTotNtv', 'IssTotUSD', 'NVTAdj',
'NVTAdj90','TxCnt', 'TxTfrCnt', 'TxTfrValAdjNtv', 'TxTfrValAdjUSD',
'TxTfrValMeanNtv', 'TxTfrValMeanUSD', 'TxTfrValMedNtv',
'TxTfrValMedUSD', 'TxTfrValNtv', 'TxTfrValUSD', 'VtyDayRet180d',
'VtyDayRet30d', 'VtyDayRet60d']
y_col = ['PriceUSD']
xvars_df = btc_df[x_cols]
xvars_df.replace([np.inf, -np.inf], np.nan)
xvars_df.dropna(inplace=True)
xvars_df = (xvars_df - xvars_df.rolling(60).mean())/xvars_df.rolling(60).std() # normalize xvars by zscore
xvars_df = xvars_df.shift(1) # lag x vars by 1
btc_px = btc_df[y_col]
btc_px.columns = ['BTC_PX']
y = btc_px.pct_change(1)
y.replace([np.inf, -np.inf], np.nan)
y.dropna(inplace=True)
y.columns = ['Y_VAR']
reg_dat = pd.concat([xvars_df,y],axis=1).dropna()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment