Algorithmic Trading & Indicators
Advanced
Intraday Tick-Level Time & Sales Aggregator & Large Block Trade Detector in Python
Process raw tick trade logs in Python Pandas to aggregate volume bursts, aggressive buy/sell sweeps, and institutional block trade anomalies.
#pandas#numpy
Problem Statement
Institutional iceberg and block orders leave footprints in tick-level Time & Sales data. This script flags trades exceeding 5x average tick size.
Formula / Core Logic
Block Trade Flag = Trade_Volume > (Mean_Tick_Volume + 5 * Std_Tick_Volume)
Installation
pip install pandas numpy
intraday-time-and-sales-tape-reader-python.py
import pandas as pd
import numpy as np
\.def detect_block_trades(tick_df, threshold_mult=5.0):
df = tick_df.copy()
mean_vol = df['Size'].mean()
std_vol = df['Size'].std()
cutoff = mean_vol + (threshold_mult * std_vol)
df['Aggressive_Buy'] = df['Price'] >= df['Ask']
df['Block_Trade'] = df['Size'] >= cutoff
return df[df['Block_Trade']]
Get the Complete 100+ Python Quant & Automation Bundle
Instant lifetime access to all production-ready scripts, valuation models, and trading bots ($19).
Buy Full Bundle on Gumroad ($19) →Frequently Asked Questions
Q: What is an institutional iceberg order?
A large parent order sliced into small visible chunks to hide execution intent; tape readers detect them via repeated volume clusters at identical price levels.