Skip to content

AtharvaBeesen/OptionsPricing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Options Pricing with RAG-based Sentiment Analysis and an Options Arbitrage Backtest

System combining Longstaff-Schwartz Monte Carlo simulation with RAG-powered sentiment analysis for American options pricing and arbitrage detection.

Core Components

Options Pricing Engine (options_pricer.py)

  • Longstaff-Schwartz Method: Backward induction with polynomial regression for American option valuation
  • Monte Carlo Simulation: 10,000+ paths with antithetic variates for variance reduction
  • Greeks Calculation: Delta, Gamma, Vega, Rho, Theta via finite difference methods
  • Sentiment Integration: Dynamic parameter adjustment based on news sentiment

RAG Sentiment Analyzer (sentiment_analyzer.py)

  • Embedding Model: SentenceTransformers (all-MiniLM-L6-v2) for semantic similarity
  • Vector Index: FAISS for efficient similarity search across historical news
  • LLM Analysis: GPT-4 for contextual sentiment scoring (-1 to +1 scale)
  • Parameter Adjustment: Confidence-weighted modification of S0 and volatility

Backtesting Framework (backtester.py)

  • Arbitrage Detection: Identifies options with >10% price discrepancy
  • Optimal Exercise: Tracks performance with perfect timing execution
  • Multi-Asset Coverage: NVDA, AAPL, MSFT, GOOGL, AMZN, META, TSLA, PYPL, INTC, AMD

Technical Flow

  1. News API collects historical articles for target tickers.
  2. RAG system builds FAISS index from article embeddings and uses GPT-4 for sentiment analysis by finding relevant news articles.
  3. Sentiment scores adjust option pricing parameters (S0, volatility) dynamically.
  4. Longstaff-Schwartz method prices American options with Monte Carlo simulation.
  5. Backtesting framework identifies mispriced options and tracks optimal exercise performance.

Performance Results

  • 35.2% Average Return: On identified undervalued options
  • 80% Accuracy: Correctly identified undervalued options
  • Multi-Asset Coverage: 10 major tech stocks
  • Real-time Integration: News sentiment affects pricing within minutes

Dependencies

  • numpy>=1.21.0: Numerical computations
  • torch>=2.0.0: PyTorch for embeddings
  • sentence-transformers>=2.2.2: Semantic similarity
  • faiss-cpu>=1.7.4: Vector similarity search
  • yfinance>=0.2.18: Market data
  • newsapi-python>=0.2.7: News aggregation
  • openai>=1.0.0: GPT-4 integration

Usage

# Initialize pricing model
option = AmericanOptionsLSMC(
    option_type='call',
    S0=1224.40,
    strike=1200.00,
    T=1.0,
    r=0.05,
    sigma=0.4,
    simulations=10000,
    ticker='NVDA'
)

# Price with sentiment
result = option.price_with_sentiment(news_article)
print(f"Price: ${result['price']:.2f}")
print(f"Delta: {result['delta']:.4f}")

API Keys Required

  • OPENAI_API_KEY: GPT-4 sentiment analysis
  • NEWS_API_KEY: Historical news collection
  • ALPHA_VANTAGE_KEY: Volatility data (optional)

Key Outcomes...

  1. Dynamic Sentiment Integration: Real-time news affects option pricing parameters
  2. RAG-Powered Analysis: Contextual similarity search for relevant historical news
  3. Arbitrage Detection: Automated identification of mispriced options

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages