Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

33 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง  Synapse Street - AI Multi-Agent Financial Analysis System

Python LangGraph OpenAI Qdrant License

๐Ÿฅ‡ Best Use of AI/ML โ€” UB Hacking 2024 (OpenAI Sponsor Prize)
๐Ÿฅˆ 2nd Place Overall โ€” out of 87 teams

AI-powered multi-agent system for stock market analysis. Three specialized GPT-4 agents collaborate via a consensus engine to generate BUY/SELL/HOLD signals with confidence scores.


๐ŸŽฏ The Problem

Traditional algorithmic trading systems suffer from three core failures:

  • Single-point failure - one model making all decisions
  • Narrow context - missing broader market signals
  • Poor explainability - black-box decisions traders can't trust

Synapse Street solves this with a collaborative multi-agent architecture that mirrors how real trading desks operate.


๐Ÿ—๏ธ System Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     DATA INGESTION LAYER                         โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”             โ”‚
โ”‚  โ”‚ Market Data โ”‚  โ”‚  News API   โ”‚  โ”‚ SEC Filings โ”‚             โ”‚
โ”‚  โ”‚  (Yahoo)    โ”‚  โ”‚  (NewsAPI)  โ”‚  โ”‚  (EDGAR)    โ”‚             โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜             โ”‚
โ”‚         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                   โ”‚
โ”‚                           โ–ผ                                     โ”‚
โ”‚                  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                            โ”‚
โ”‚                  โ”‚ Spark Streaming โ”‚                            โ”‚
โ”‚                  โ”‚ (3K+ entities)  โ”‚                            โ”‚
โ”‚                  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                   VECTOR MEMORY (Qdrant)                         โ”‚
โ”‚  โ€ข Market embeddings (OpenAI Ada-002)                           โ”‚
โ”‚  โ€ข Historical pattern matching                                   โ”‚
โ”‚  โ€ข News sentiment vectors                                        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ–ผ
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ–ผ                   โ–ผ                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  DATA AGENT   โ”‚   โ”‚ANALYSIS AGENT โ”‚   โ”‚ EXECUTION     โ”‚
โ”‚   (GPT-4)     โ”‚   โ”‚   (GPT-4)     โ”‚   โ”‚   AGENT       โ”‚
โ”‚               โ”‚   โ”‚               โ”‚   โ”‚   (GPT-4)     โ”‚
โ”‚ โ€ข Ingest data โ”‚   โ”‚ โ€ข Technical   โ”‚   โ”‚               โ”‚
โ”‚ โ€ข Feature eng โ”‚   โ”‚   analysis    โ”‚   โ”‚ โ€ข Generate    โ”‚
โ”‚ โ€ข Store to    โ”‚   โ”‚ โ€ข Sentiment   โ”‚   โ”‚   signals     โ”‚
โ”‚   vector DB   โ”‚   โ”‚   scoring     โ”‚   โ”‚ โ€ข Position    โ”‚
โ”‚               โ”‚   โ”‚ โ€ข Risk assess โ”‚   โ”‚   sizing      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ–ผ
                 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                 โ”‚  CONSENSUS      โ”‚
                 โ”‚  ENGINE         โ”‚
                 โ”‚  (LangGraph)    โ”‚
                 โ”‚                 โ”‚
                 โ”‚  โ€ข Weighted     โ”‚
                 โ”‚    voting       โ”‚
                 โ”‚  โ€ข Confidence   โ”‚
                 โ”‚    thresholds   โ”‚
                 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                          โ–ผ
                 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                 โ”‚  TRADING SIGNAL โ”‚
                 โ”‚ BUY/SELL/HOLD   โ”‚
                 โ”‚  + Confidence   โ”‚
                 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“Š Performance Results

Backtest: S&P 500 (Jan 2023 โ€“ Oct 2024)

Strategy Total Return Sharpe Max Drawdown Win Rate
Buy & Hold 24.5% 1.2 -18% โ€”
Synapse Street 42.8% 1.8 -12% 64%
Improvement +18.3% +50% +33% โ€”

Agent Consensus Analysis

Consensus Level Trades Win Rate Avg Return Sharpe
High (3/3 agree) 45 78% 4.2% 2.4
Medium (2/3 agree) 120 58% 2.1% 1.6
Low (split) 85 42% -0.5% 0.8

Key Insight: High-consensus trades significantly outperform, validating the multi-agent approach.

Risk Metrics

Metric Value
Beta 0.85
Alpha 12.3% annualized
Sortino Ratio 2.1
Calmar Ratio 3.6

๐Ÿ› ๏ธ Technology Stack

Layer Technology Why
Agent Framework LangGraph Explicit state management, cyclic workflows
LLM GPT-4 Best reasoning for financial analysis
Vector Database Qdrant Hybrid search, Rust-based speed
Embeddings OpenAI Ada-002 Optimal cost/performance for financial text
Data Processing Spark + Pandas Batch + real-time
Orchestration Apache Airflow Production pipeline scheduling
Dashboard Streamlit Real-time monitoring
Backtesting Backtrader Industry-standard, extensible

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.9+
  • Docker (for Qdrant)
  • OpenAI API key

Installation

# 1. Clone repository
git clone https://github.com/mrudula1501/Synapse-Street.git
cd Synapse-Street

# 2. Start Qdrant
docker run -p 6333:6333 -v $(pwd)/qdrant_storage:/qdrant/storage qdrant/qdrant

# 3. Install dependencies
pip install -r requirements.txt

# 4. Configure environment
cp .env.example .env
# Edit .env with your OPENAI_API_KEY

# 5. Download historical data
python scripts/download_data.py --symbols SPY,AAPL,MSFT --start 2020-01-01

# 6. Run backtest
python main.py --mode backtest --config configs/backtest.yaml

Usage

from synapse_street import TradingSystem
from synapse_street.config import load_config

config = load_config('configs/production.yaml')
system = TradingSystem(config)

signals = system.generate_signals(
    symbols=['AAPL', 'MSFT', 'GOOGL', 'AMZN'],
    lookback_days=30
)

print(signals)
# [
#   {
#     'symbol': 'AAPL',
#     'signal': 'BUY',
#     'confidence': 0.87,
#     'agents_agree': '3/3',
#     'rationale': 'Technical breakout + positive earnings sentiment',
#     'position_size': 0.15
#   },
#   ...
# ]

๐ŸŽฅ Agent Decision Flow (Example)

[14:32:05] DATA_AGENT:      Fetched AAPL 1-min bars, RSI=68, MACD crossing
[14:32:06] DATA_AGENT:      News sentiment: +0.8 (earnings beat)
[14:32:07] DATA_AGENT:      Stored to Qdrant: 5 vectors

[14:32:08] ANALYSIS_AGENT:  Retrieved similar patterns (3 bullish, 1 bearish)
[14:32:09] ANALYSIS_AGENT:  Technical: 0.75 | Sentiment: 0.82 | Risk: LOW
[14:32:09] ANALYSIS_AGENT:  โ†’ BULLISH (confidence: 0.79)

[14:32:10] EXECUTION_AGENT: Portfolio: 20% cash, max position 15%
[14:32:10] EXECUTION_AGENT: โ†’ BUY, Size: 12% (within risk limits)

[14:32:11] CONSENSUS:        All 3 agents agree โ†’ HIGH confidence
[14:32:11] CONSENSUS:        โ†’ EXECUTE BUY AAPL @ $178.50, 12% position

๐Ÿ”ฌ Technical Deep Dives

Consensus Mechanism

Not simple majority voting - we use weighted confidence scoring:

def calculate_consensus(agent_outputs):
    weighted_sum = sum(
        output['confidence'] * output['signal_value']
        for output in agent_outputs
    )
    total_confidence = sum(output['confidence'] for output in agent_outputs)
    consensus_score = weighted_sum / total_confidence

    if consensus_score > 0.7:
        return 'BUY', 'HIGH'
    elif consensus_score < -0.7:
        return 'SELL', 'HIGH'
    else:
        return 'HOLD', 'LOW'

Vector Search Strategy (Qdrant Hybrid)

results = qdrant.search(
    collection_name="market_conditions",
    query_vector=dense_embedding,      # Ada-002: semantic similarity
    query_sparse=sparse_vector,        # BM25: ticker/term matching
    limit=5,
    score_threshold=0.75
)

๐Ÿ“ Project Structure

Synapse-Street/
โ”œโ”€โ”€ agents/
โ”‚   โ”œโ”€โ”€ base_agent.py          # Abstract base class
โ”‚   โ”œโ”€โ”€ data_agent.py          # Market data ingestion
โ”‚   โ”œโ”€โ”€ analysis_agent.py      # Technical + sentiment analysis
โ”‚   โ””โ”€โ”€ execution_agent.py     # Signal generation + sizing
โ”œโ”€โ”€ core/
โ”‚   โ”œโ”€โ”€ consensus_engine.py    # Agent voting mechanism
โ”‚   โ”œโ”€โ”€ vector_store.py        # Qdrant interface
โ”‚   โ”œโ”€โ”€ risk_manager.py        # Position sizing, stop-losses
โ”‚   โ””โ”€โ”€ backtester.py          # Strategy validation
โ”œโ”€โ”€ configs/
โ”‚   โ”œโ”€โ”€ backtest.yaml
โ”‚   โ””โ”€โ”€ production.yaml
โ”œโ”€โ”€ dashboard/
โ”‚   โ””โ”€โ”€ streamlit_app.py
โ”œโ”€โ”€ main.py
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ Dockerfile
โ””โ”€โ”€ README.md

๐Ÿ”ฎ Roadmap

  • Live trading integration (Alpaca / Interactive Brokers)
  • Reinforcement learning for dynamic position sizing
  • Alternative data (satellite imagery, credit card transactions)
  • Multi-asset support (crypto, forex, commodities)
  • Federated learning across distributed data sources

๐Ÿ† Hackathon Results โ€” UB Hacking 2024

  • ๐Ÿฅ‡ Best Use of AI/ML (Sponsor: OpenAI)
  • ๐Ÿฅˆ 2nd Place Overall (87 teams)
  • ๐Ÿ’ก Most Innovative Architecture (Judge's Choice)

"The multi-agent approach to financial analysis is genuinely novel. Most teams used single LLM calls; this team architected a collaborative system that mirrors real trading desks." โ€” Judges' Feedback

Team: Team of 4 - Mrudula Deshmukh (ML Engineer, Vector Search).

๐Ÿ“„ License

MIT License โ€” see LICENSE

โš ๏ธ Disclaimer: Educational purposes only. Not financial advice. Trading involves significant risk.


๐Ÿ“ฌ Contact

Mrudula Deshmukh

GitHub Portfolio LinkedIn Email

About

AI multi-agent system for stock market signal generation using LangGraph, GPT-4, and Qdrant vector search. Achieved 42.8% backtest return vs. 24.5% buy-and-hold, 78% win rate on high-consensus signals. ๐Ÿฅ‡ Best Use of AI/ML, UB Hacking 2024.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages