Faray Traders - IMC Trading Bot
Inspiration
The IMC trading competition presented a unique challenge: trading financial derivatives whose values depend on real-world events like flight traffic at Munich Airport and water levels in the Isar River. We were inspired to build a sophisticated algorithmic trading system that could:
- Leverage real-time external data to gain an edge over pure market-making strategies
- Combine multiple data sources (flight data, water levels) to calculate fair values
The opportunity to integrate live flight data from Munich Airport with market-making strategies excited us, as it represented a real-world application of quantitative trading principles.
What it does
Our system is a hybrid algorithmic trading bot that combines market-making with fundamental valuation to trade financial derivatives. Here's what it does:
Valuation Engine (Value Box):
- Scrapes real-time water level and flow rate data from the HND Bayern website (95 data points)
- Fetches flight data from Munich Airport via Aerodatabox API
- Calculates fair values for different products:
- Product 1:
flow_rate × water_level(real-time) - Product 2: Range-based calculation using max/min water dynamics
- Flight Products: Settlement =
3 × (Total Arrivals + Total Departures)
- Product 1:
Flight Data Fetcher (Flight Catcher):
- Retrieves and processes flight arrivals/departures from Munich Airport
- Groups flights into 30-minute time slots for analysis
- Automatically handles API limitations (splits requests > 12 hours)
- Provides real-time settlement estimates for trading decisions
Trading Strategy:
- Market Making: Quotes both bid and ask prices simultaneously with configurable spreads
- Position-Based Skewing: Adjusts prices based on inventory (skews down when long, up when short)
- Settlement-Based Trading: Blends expected settlement (70% weight) with market price (30%) to determine fair value
- Risk Management: Position limits (±50) prevent losses
Settlement Price Estimation:
- Integrates flight data over market periods (typically 24 hours)
- Calculates settlement using the formula:
3 × (Arrivals + Departures) - Updates every 5 minutes to reflect new flight data
- Falls back gracefully when API is unavailable
How we built it
Architecture: We built a modular Python system with clear separation of concerns:
ValuationEngine (
valuation_engine.py): Central valuation system that aggregates data from multiple sources- Web scraping for water level data using BeautifulSoup
- API integration for flight data via Aerodatabox
FlightDataFetcher (
flight_data_fetcher.py): Specialized component for flight data processing- Handles complex API response parsing with multiple fallback strategies
- Automatic time range splitting for periods exceeding API limits
- Robust datetime parsing supporting multiple formats
Trading Bots:
- FairValueBot (
fair_value_bot.py): Pure market-making with position skewing - FlightDataBot (
flight_data_bot.py): Market-making + settlement-based trading with background data refresh
- FairValueBot (
Base Infrastructure (
imcity_template.py): Provided trading framework with SSE streaming for real-time market data
Technical Implementation:
- Real-time Data Streaming: Server-Sent Events (SSE) for live orderbook updates
- Concurrent Processing: Thread-based architecture for simultaneous data fetching and trading
- Fair Value Calculation:
fair_value = (0.7 × settlement) + (0.3 × market_price) - (position × skew_factor) - Order Management: Cancels existing orders before placing new ones to avoid duplicates
- Error Handling: Graceful degradation when APIs are unavailable
Log in or sign up for Devpost to join the conversation.