hanxixuana / flowrisk

A Python Implementation of Measures for Order Flow Risk, e.g. VPIN
MIT License
81 stars 32 forks source link

online example #4

Closed flamby closed 3 years ago

flamby commented 3 years ago

Hello,

In order_flow_risk_analysis_of_ten_us_stocks.ipynb notebook, you mention that BulkVPIN is suitable for online VPIN estimation.

While I'm able to generate VPINs from a dataframe and use them with an sklearn compatible model, once I try to pass new data for online generation of VPIN feature to the estimator, it does not seem to be able to handle it.:

lib/python3.8/site-packages/pandas/core/indexes/range.py in __getitem__(self, key)
    695                 return self._range[new_key]
    696             except IndexError:
--> 697                 raise IndexError(
    698                     f"index {key} is out of bounds for axis 0 with size {len(self)}"
    699                 )

IndexError: index 50 is out of bounds for axis 0 with size 50

I pass usually just a couple of rows when doing inference.

Can you provide an online example? I guess I missed something.

Also, having a scikit-learn API like interface (fit, predict, predict_proba) of the estimator would be great.

Thanks and keep the good work!

flamby commented 3 years ago

I forgot the N_TIME_BAR_FOR_INITIALIZATION in the equation. Silly me.