{"id":26584007,"url":"https://github.com/jialuechen/openlpa","last_synced_at":"2025-04-06T13:12:29.677Z","repository":{"id":225753067,"uuid":"766697276","full_name":"jialuechen/openlpa","owner":"jialuechen","description":"Liquidity Provision Analytics Python Library Beyond TCA ","archived":false,"fork":false,"pushed_at":"2025-03-28T01:46:09.000Z","size":2069,"stargazers_count":102,"open_issues_count":0,"forks_count":14,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-30T11:09:19.832Z","etag":null,"topics":["behavior-modeling","high-frequency-trading","liquidity-provider","market-making","smart-order-router","strategy-development","transaction-cost-analytics"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jialuechen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-04T00:07:26.000Z","updated_at":"2025-03-28T02:19:05.000Z","dependencies_parsed_at":"2024-07-16T18:46:35.945Z","dependency_job_id":"c4367c2c-9c7d-4c40-b8d9-610b5a132300","html_url":"https://github.com/jialuechen/openlpa","commit_stats":null,"previous_names":["jialuechen/llmbroker","jialuechen/statsmaker","jialuechen/thunderfix","jialuechen/openlpa"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jialuechen%2Fopenlpa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jialuechen%2Fopenlpa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jialuechen%2Fopenlpa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jialuechen%2Fopenlpa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jialuechen","download_url":"https://codeload.github.com/jialuechen/openlpa/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247485290,"owners_count":20946398,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["behavior-modeling","high-frequency-trading","liquidity-provider","market-making","smart-order-router","strategy-development","transaction-cost-analytics"],"created_at":"2025-03-23T09:10:39.713Z","updated_at":"2025-04-06T13:12:29.646Z","avatar_url":"https://github.com/jialuechen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenLPA\n\n**OpenLPA** (Open-source Liquidity Provision Analytics) is a Python library for analyzing the behavior and quality of liquidity providers (LPs) in electronic trading. Inspired by institutional solutions, this project empowers traders, quants, and researchers with tools to evaluate LP behavior, optimize routing decisions, and support transaction cost analysis (TCA).\n\n---\n\n## 🔍 Features\n\n- ⏱️ **Latency \u0026 Quote Behavior Analysis**  \n  Measure RFQ/ESP response times, quote cancellation patterns, and quote duration.\n\n- 📈 **Fill Probability and Slippage Attribution**  \n  Quantify true liquidity based on actual trade outcomes.\n\n- 🧠 **LP Scoring System**  \n  Generate LP quality scores by aggregating multiple behavioral indicators.\n\n- 📊 **Interactive Dashboard (Streamlit)**  \n  Upload quotes/trades and visualize LP performance dynamically.\n\n- 🧬 **Behavioral Modeling**  \n  Extract time-series LP features for clustering and anomaly detection.\n\n- ⚖️ **Causal Inference (DoWhy)**  \n  Estimate causal impact of LP selection on execution outcomes.\n\n- 🤖 **Adaptive LP Routing (MAB)**  \n  Use multi-armed bandit algorithms to learn and optimize LP selection.\n\n---\n\n## 🆚 OpenLPA vs Traditional TCA\n\nWhile traditional Transaction Cost Analysis (TCA) primarily focuses on post-trade outcomes such as slippage, OpenLPA goes one step further by incorporating the behavioral dynamics of liquidity providers into the analysis pipeline.\n\n| Feature | Traditional TCA | OpenLPA |\n|--------|------------------|---------|\n| Focus | Execution result | Execution process + behavior |\n| Metrics | Slippage, cost | Latency, fill ratio, quote stability |\n| Counterparty Modeling | None | LP-level behavioral scoring |\n| Causal Analysis | Rare | Integrated (DoWhy) |\n| Optimization | Static benchmarks | Adaptive LP selection (MAB) |\n| Real-Time Application | Limited | Supported via dashboard + routing logic |\n\nBy integrating microstructure behavior modeling, causal inference, and adaptive learning, OpenLPA enables smarter routing, better transparency, and a more complete picture of liquidity quality.\n\n---\n\n## 📦 Installation\n\n```bash\npip install --upgrade openlpa\n```\n\n---\n\n## 🚀 Quick Start\n\n### 1. LP Behavior Scoring\n\n```python\nfrom core.lp_evaluator import LPEvaluator\nfrom io.data_loader import load_quotes, load_trades\n\nquotes = load_quotes(\"data/quotes.csv\")\ntrades = load_trades(\"data/trades.csv\")\n\nevaluator = LPEvaluator(quotes, trades)\nscores = evaluator.score_liquidity_providers()\nprint(scores.head())\n```\n\n---\n\n### 2. Slippage Analysis\n\n```python\nfrom core.tca import calculate_slippage, aggregate_slippage_by_lp\n\ntrades_slippage = calculate_slippage(trades, benchmark_col=\"arrival_price\")\nlp_slip = aggregate_slippage_by_lp(trades_slippage)\nprint(lp_slip)\n```\n\n---\n\n### 3. LP Behavior Modeling (Time-Series)\n\n```python\nfrom core.behavior_model import extract_behavior_features\n\nbehavior_features = extract_behavior_features(quotes, trades, window=\"1h\")\nprint(behavior_features.head())\n```\n\n---\n\n### 4. Causal Inference with DoWhy\n\n```python\nfrom core.causal_analysis import estimate_treatment_effect\n\n# Merge LP usage and slippage data with controls\neffect = estimate_treatment_effect(lp_usage_df, slippage_df)\nprint(\"Estimated Causal Effect:\", effect)\n```\n\n---\n\n### 5. LP Routing via Multi-Armed Bandit\n\n```python\nfrom core.lp_router import LPRouter\n\nrouter = LPRouter(arms=[\"LP1\", \"LP2\", \"LP3\"])\nrouter.fit([\"LP1\", \"LP2\", \"LP1\"], [0.8, 0.5, 0.9])\nprint(\"Recommended LP:\", router.select_lp())\n```\n\n---\n\n### 6. Interactive Dashboard\n\n```bash\nstreamlit run streamlit_app/app.py\n# or the advanced version:\nstreamlit run streamlit_app/intelligence.py\n```\n\n---\n\n## 📘 Use Cases\n\n| Market | Applications |\n|--------|--------------|\n| FX     | RFQ/ESP latency tracking, LP ranking, quote-to-fill gap |\n| Equities | Venue performance analysis, ATS/SDP routing |\n| Crypto | CEX/DEX LP clustering, anomaly detection |\n| Fixed Income | RFQ stability, best execution validation |\n\n---\n\n## 🔮 Roadmap\n\n- [x] LP behavioral time-series modeling\n- [x] Causal inference via DoWhy\n- [x] Online learning with multi-armed bandits\n- [ ] Reinforcement learning agent for dynamic LP selection\n- [ ] Graph-based LP modeling (GNN)\n- [ ] Market simulator integration (e.g., MARS, DeepMarket)\n\n---\n\n## 🧑‍💻 Contributing\n\nWe welcome feedback, pull requests, and discussions! Please open issues or submit improvements via PR.\n\n---\n\n## 📄 License\n\nLicensed under the Apache License, Version 2.0.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjialuechen%2Fopenlpa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjialuechen%2Fopenlpa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjialuechen%2Fopenlpa/lists"}