def compute_volume_exposures(shares_held, volumes, percentile):
shares_held = shares_held.replace(<NUM_LIT:0>, np.nan)<EOL>shares_longed = shares_held[shares_held > <NUM_LIT:0>]<EOL>shares_shorted = -<NUM_LIT:1> * shares_held[shares_held < <NUM_LIT:0>]<EOL>shares_grossed = shares_held.abs()<EOL>longed_frac = shares_longed.divide(volumes)<EOL>shorted_frac = shares_shorted.divide(volumes)<EOL>grossed_frac = shares_grossed.divide(volumes)<EOL>longed_threshold = <NUM_LIT:100> * longed_frac.apply(<EOL>partial(np.nanpercentile, q=<NUM_LIT:100> * percentile),<EOL>axis='<STR_LIT>',<EOL>)<EOL>shorted_threshold = <NUM_LIT:100> * shorted_frac.apply(<EOL>partial(np.nanpercentile, q=<NUM_LIT:100> * percentile),<EOL>axis='<STR_LIT>',<EOL>)<EOL>grossed_threshold = <NUM_LIT:100> * grossed_frac.apply(<EOL>partial(np.nanpercentile, q=<NUM_LIT:100> * percentile),<EOL>axis='<STR_LIT>',<EOL>)<EOL>return longed_threshold, shorted_threshold, grossed_threshold<EOL>
Returns arrays of pth percentile of long, short and gross volume exposures
of an algorithm's held shares

Parameters
----------
shares_held : pd.DataFrame
    Daily number of shares held by an algorithm.
    - See full explanation in create_risk_tear_sheet

volume : pd.DataFrame
    Daily volume per asset
    - See full explanation in create_risk_tear_sheet

percentile : float
    Percentile to use when computing and plotting volume exposures
    - See full explanation in create_risk_tear_sheet