Algo Library for Order Flow Inference and TCA
Last updated Jun 29, 2026
138
Stars
10
Forks
4
Issues
0
Stars/day
Attention Score
50
Topics
Language breakdown
No language data available.
▸ Files
click to expand
README
FlowPylib: Python Library for Order Flow Inference and Transaction Cost Analytics
FlowPylib is a Python package for transaction cost analysis in financial markets, supporting both stock and forex data at the tick level. The library assists traders and market makers by enabling detailed analysis of market data, reconstruction of metaorders, and simulation of order flows. It also provides various visualization tools and a RESTful API to integrate the analytics into your systems.
Features
- Tick Data Processing:
- MetaOrder Reconstruction:
- Bayesian Change-Point Detection:
- Buy-Side Order Flow Simulation:
- Rich Visualizations & Reporting:
- RESTful API Integration:
- Multi-Source Data Loading:
Installation and Quick Start
pip install -U flowpylib
import flowpylib
Load tick data (supports stocks, forex, etc.)
tickdata = flowpylib.loadtickdata('path/to/tickdata.csv', data_type='stock')
Analyze the tick data
analysisresults = flowpylib.analyzetickdata(tickdata)
print("Tick Data Analysis Results:", analysis_results)
Visualize tick data with a summary dashboard
summaryfig = flowpylib.plottickdata(tickdata, plot_type='summary')
summaryfig.writehtml('summary_dashboard.html')
More Examples
Loading Data from Different Sources
import flowpylib
From CSV
csvdata = flowpylib.loadtickdata('path/to/tickdata.csv', data_type='stock')
From Excel
exceldata = flowpylib.readexcel('path/to/tickdata.xlsx', sheetname='Tick Data')
Using KDBHandler for KDB+ source
kdb_handler = flowpylib.KDBHandler(host='localhost', port=5000)
kdbdata = kdbhandler.loadtickdata('tickdata', '2023.07.15T09:30:00.000', '2023.07.15T16:00:00.000')
Performing Analysis
import flowpylib
Load data for stocks and forex
stockdata = flowpylib.loadtickdata('path/to/stockdata.csv', data_type='stock')
forexdata = flowpylib.loadtickdata('path/to/forexdata.csv', data_type='forex')
Analyze stock data
stockanalysis = flowpylib.analyzestocktrade(stockdata, benchmark_data)
print("Stock Analysis Results:", stock_analysis)
Analyze forex data
forexanalysis = flowpylib.analyzeforextrade(forexdata, benchmark_data)
print("Forex Analysis Results:", forex_analysis)
Calculate slippage and VWAP as examples
slippage = flowpylib.calculateslippage(executedprice=100.05, benchmark_price=100.00)
print("Slippage:", slippage)
vwap = flowpylib.calculate_vwap(prices=[100.00, 100.05, 100.10], volumes=[1000, 2000, 1500]) print("VWAP:", vwap)
Generating Visualizations
import flowpylib
Load tick data
tickdata = flowpylib.loadtickdata('path/to/tickdata.csv', data_type='stock')
Create a basic plot
basicfig = flowpylib.plottickdata(tickdata, plot_type='basic')
basicfig.savefig('basicplot.png')
Create a candlestick chart
candlestickfig = flowpylib.plottickdata(tickdata, plot_type='candlestick', interval='5min')
candlestickfig.writehtml('candlestick.html')
Create an order book depth chart
depthfig = flowpylib.plottickdata(tickdata, plot_type='depth')
depthfig.writehtml('depth_chart.html')
Create a trade flow chart
tradeflowfig = flowpylib.plottickdata(tickdata, plottype='trade_flow', window='5min')
tradeflowfig.writehtml('tradeflow.html')
Create a summary dashboard
summaryfig = flowpylib.plottickdata(tickdata, plot_type='summary')
summaryfig.writehtml('summary_dashboard.html')
Using the RESTful API
import flowpylib
Start the API server
flowpylib.run_api(host='localhost', port=5000)
Now you can make HTTP requests to the API endpoints, for example:
POST http://localhost:5000/analyzetickdata
with JSON body: {"tablename": "tickdata", "starttime": "2023.07.15T09:30:00.000", "end_time": "2023.07.15T16:00:00.000", "symbols": ["AAPL", "GOOGL"]}
Roadmap
- Q3 2025:
- Q4 2025:
Contributing
We welcome contributions! Please see our Contributing Guide for more details.
License
This project is licensed under the BSD-2-Clause License - see the LICENSE file for details.
🔗 More in this category