Skip to main content

Infrastructure Economics Advisor: Measure Kyle's Lambda fairness gaps using Rust-accelerated calculations. Optimize trading strategy within broker latency constraints.

Project description

🐶 PnL Watchdog: Infrastructure Economics Advisor

Measure the hidden cost of your execution. Optimize your strategy within broker constraints.

Your broker shows you filled orders. But are you getting the same prices as institutions?

No. You're paying a latency tax. Every single trade.

pnl-watchdog measures Kyle's Lambda fairness gaps between retail and institutional execution using Rust-accelerated calculations—then shows you exactly how much that gap costs you and how to trade profitably within it.

Stop fighting latency. Start optimizing around it.

🚀 Key Features

  • Kyle's Lambda Calculator: Measure price impact per signed volume (Rust-accelerated)
  • Fairness Audit: Compare retail vs institutional execution costs
  • AI Anomaly Detection: Catch unusual latency/slippage patterns
  • Smart Order Routing: Get broker recommendations based on real-time performance
  • Privacy First: No strategy exposure—only anonymous telemetry

⚡ Performance: Powered by Rust

Operation Rust Python Speedup
Kyle's Lambda (10k candles) 0.1ms 50ms 500x faster
Fairness Audit (5 samples) 100ms 1-2s 20x faster
Batch Processing (1000 symbols) 100ms 50s 500x faster

📦 Installation

pip install pnl-watchdog

🎯 Quick Start

from pnl_watchdog import PnLWatchdog

# Initialize with your broker credentials
dog = PnLWatchdog(
    broker="alpaca",
    api_key="YOUR_API_KEY",
    api_secret="YOUR_SECRET_KEY"
)

# Verify a trade
result = dog.check_order("AAPL", "buy", 10)
print(f"Trade verified in {result['latency_ms']}ms")

# Calculate Kyle's Lambda for market analysis
from pnl_watchdog import calculate_whale_metrics

opens = [100.0, 101.0, 102.0, 101.5, 100.5]
closes = [101.0, 102.0, 101.5, 100.5, 101.0]
volumes = [1000.0, 2000.0, 1500.0, 500.0, 1200.0]

amihud, kyles_lambda = calculate_whale_metrics(opens, closes, volumes)
print(f"Kyle's Lambda: {kyles_lambda}")

📊 Advanced Analytics

# Get institutional order flow metrics
from pnl_watchdog import calculate_order_flow_metrics

prices = [100.0, 101.0, 102.0, 101.5, 100.5]
volumes = [1000.0, 2000.0, 1500.0, 500.0, 1200.0]
bids = [99.9, 100.9, 101.9, 101.4, 100.4]
asks = [100.1, 101.1, 102.1, 101.6, 100.6]

vwap_dev, tox, nof, obi, vwap = calculate_order_flow_metrics(prices, volumes, bids, asks)
print(f"Toxicity Score: {tox}")
print(f"VWAP: {vwap}")

🤝 Supported Brokers

  • Alpaca
  • Interactive Brokers
  • Binance (and other CCXT-supported exchanges)
  • Zerodha
  • Angel One

📚 Documentation

📞 Support

For issues, feature requests, or questions, please open an issue on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pnl_watchdog-0.6.0-cp311-cp311-macosx_11_0_arm64.whl (222.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file pnl_watchdog-0.6.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pnl_watchdog-0.6.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2adbf8ad002d82a1830459f3ef5ba93abd731025d1593ffb4f7f18a811a96db2
MD5 a6c182dc02387ac8797378be2831fd8a
BLAKE2b-256 e4b50dd8741797ad38c1ff725e699df44ed400e421dfc792ad1232c5a82d7b5f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page