Skip to content
QuantReadySign In
#477easyMarket Microstructure

VPIN Toxic Flow Detection

Problem

VPIN (Volume-Synchronized Probability of Informed Trading) estimates the probability of toxic (informed) order flow. Given buy and sell volumes across multiple volume buckets, compute:

VPIN=∣Vbuy−Vsell∣Vbuy+Vsell\text{VPIN} = \frac{|V_{\text{buy}} - V_{\text{sell}}|}{V_{\text{buy}} + V_{\text{sell}}}

where Vbuy=∑ivibuyV_{\text{buy}} = \sum_i v_i^{\text{buy}} and Vsell=∑ivisellV_{\text{sell}} = \sum_i v_i^{\text{sell}} are the total buy and sell volumes across all buckets.

Input Format

A single line: buy_volumes sell_volumes where each is a comma-separated list of floats.

Output Format

A single value: VPIN, to 4 decimal places.

Examples

Example 1
Input
100,150,200,120,130 80,100,180,150,90
Output
0.0769

V_buy=100+150+200+120+130=700. V_sell=80+100+180+150+90=600. VPIN=|700-600|/(700+600)=100/1300=0.0769.

Example 2
Input
500,500,500 500,500,500
Output
0.0000

V_buy=1500, V_sell=1500. VPIN=0/3000=0.0000.

Constraints

  • •1 ≤ number of buckets ≤ 1000
  • •All volumes ≥ 0
  • •V_buy + V_sell > 0
  • •Output to 4 decimal places

Execution limits: 2s · 256MB

Loading interactive editor…