Repository navigation
Conversation
…on and VPIN RustQuant_trading::order_flow signs trades and measures order flow toxicity. TickRule and LeeReady classify individual trades as buyer or seller initiated (OrderSide::BID / OrderSide::ASK). BulkVolumeClassifier splits bar volume with Phi(dP / sigma) using the sample standard deviation of recent close changes, as in Easley, Lopez de Prado and O'Hara (2012). Vpin fills fixed-volume buckets, splitting trades that overflow a bucket, and averages |V_buy - V_sell| / V over the last n buckets. The unit tests check hand-computed values: alternating unit trades in buckets of five give 0.2 and in buckets of four give exactly 0, and the bulk-classified bar gives erf(1/2).
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds
RustQuant_trading::order_flow, which signs trades with the tick rule or Lee-Ready (asOrderSide::BID/OrderSide::ASK), splits bar volume with bulk volume classification usingGaussian::cdffromRustQuant_math, and computes VPIN from Easley, Lopez de Prado and O'Hara (2012) over fixed-volume buckets. The expected values in the 10 unit tests are worked out by hand: alternating unit trades give exactly 0.2 in 5-unit buckets and 0 in 4-unit buckets, a 25 buy then 15 sell across 10-unit buckets gives 0.75, and a bulk-classified bar with close changes +1 and -1 gives erf(1/2) = 0.5204998778.cargo test -p RustQuant_tradingpasses (19 unit tests and 3 new doctests), and clippy reports nothing in the new module. It is ported from flowtox, an MIT crate I maintain, and the only new dependencies are the workspace cratesRustQuant_errorandRustQuant_math.