Skip to content

An algorithmic trading system based on FinGPT, demonstrating new applications of large pre-trained Language Models in quantitative finance.

Notifications You must be signed in to change notification settings

ashioyajotham/fingpt_trader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FinGPT Trader & Robo Advisor

An intelligent trading system combining FinGPT LLM for sentiment analysis with market inefficiency modeling.

Key Features

  • Sentiment analysis using FinGPT for financial news and market data
  • Market inefficiency detection and modeling
  • Automated trading signals generation
  • Robo advisor with personalized investment recommendations
  • Real-time market monitoring and analysis

System Architecture

graph TD
    subgraph Data Sources
        A1[Market Data APIs] --> B1
        A2[News Feeds] --> B1
        A3[Financial Statements] --> B1
    end

    subgraph Data Processing
        B1[Data Collection Service] --> B2[Data Preprocessor]
        B2 --> B3[Feature Engineering]
    end

    subgraph Analysis Engine
        C1[FinGPT Model] --> C4
        B3 --> C2[Market Inefficiency Detector]
        C2 --> C4[Signal Generator]
        C3[Technical Analysis] --> C4
    end

    subgraph Portfolio Management
        D1[Risk Analyzer] --> D3
        D2[Portfolio Optimizer] --> D3[Order Generator]
    end

    subgraph Execution
        D3 --> E1[Order Manager]
        E1 --> E2[Broker Service]
        E2 --> E3[Market]
    end

    subgraph Monitoring
        F1[Performance Tracker]
        F2[Risk Monitor]
        F3[System Monitor]
    end

    C4 --> D1
    C4 --> D2
    E2 --> F1
    D1 --> F2
    B1 --> F3
Loading

Project Structure

fingpt-trader/
│
├── data/
│   ├── raw/                # Raw market data, news feeds
│   ├── processed/          # Processed and engineered features
│   └── logs/              # System and performance logs
│
├── models/
│   ├── sentiment/
│   │   ├── fingpt/        # FinGPT model implementation
│   │   └── preprocessor.py
│   ├── market_analysis/
│   │   ├── inefficiency/
│   │   │   ├── detector.py
│   │   │   └── patterns.py
│   │   └── signals.py
│   ├── portfolio/
│   │   ├── optimization.py
│   │   └── risk.py
│   └── robo_advisor/
│       ├── profile_manager.py     # Client profile management
│       ├── recommendation.py      # Investment recommendations
│       ├── rebalancing.py        # Portfolio rebalancing
│       └── tax_harvesting.py     # Tax-loss harvesting
│
├── services/
│   ├── base_service.py    # Base service interface
│   ├── data_feeds/
│   │   ├── market_data_service.py  # Market data integration
│   │   └── news_service.py         # News aggregation service
│   ├── trading/
│   │   ├── broker_service.py       # Broker API integration
│   │   └── order_manager.py        # Order lifecycle management
│   │   └── robo_service.py         # Robo advisor service
│   └── monitoring/
│       ├── system_monitor.py       # System health tracking
│       └── performance_tracker.py   # Trading performance analytics
│
├── strategies/
│   ├── base_strategy.py   # Strategy interface
│   ├── sentiment/         # Sentiment-based strategies
│   ├── inefficiency/      # Market inefficiency strategies
│   ├── hybrid/           # Combined strategy implementations
│   └── robo/
│       ├── allocation.py      # Asset allocation strategies
│       ├── rebalancing.py     # Rebalancing strategies
│       └── tax_aware.py       # Tax-aware trading strategies
│
├── utils/
│   ├── config.py         # Configuration management
│   ├── logging.py        # Logging utilities
│   └── validation.py     # Data validation helpers
│
├── config/
│   ├── services.yaml     # Service configurations
│   ├── strategies.yaml   # Strategy parameters
│   └── logging.yaml      # Logging configuration
│
├── tests/
│   ├── services/         # Service unit tests
│   ├── strategies/       # Strategy unit tests
│   └── integration/      # Integration tests
│
├── scripts/
│   ├── backtest.py      # Backtesting framework
│   ├── live_trade.py    # Live trading entry point
│   └── analyze.py       # Performance analysis
│
├── requirements.txt
├── setup.py
├── LICENSE
└── README.md

Technical Implementation

  1. FinGPT Integration

    • Fine-tune FinGPT for financial sentiment analysis
    • Process real-time news and market data
    • Generate sentiment scores and market insights
  2. Market Inefficiency Detection

    • Model market microstructure patterns
    • Analyze trader psychology indicators
    • Track company events and anomalies
  3. Trading Strategy

    • Combine sentiment analysis with market inefficiency signals
    • Risk management and position sizing
    • Portfolio optimization

Getting Started

  1. Clone the repository
  2. Install dependencies: pip install -r requirements.txt
  3. Run data preprocessing: python scripts/data_preprocessing.py
  4. Train models: python scripts/train_models.py
  5. Evaluate models: python scripts/evaluate_models.py
  6. Start the trading bot: python scripts/trading_bot.py

Contributing

Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

i) The first is data mining.

A trading system based on data mining looks for patterns in past price data and fits a model to them.

The only assumption is that the patterns of the past will repeat in the future. This is where most people start throwing in machine learning.

Few successful trading systems are built through data mining****

ii) The second is modeling market inefficiencies.

Model-based systems start with a model of a market inefficiency.

Inefficiencies can be based on trader psychology, economics, market microstructure, company events, or anything else that affects the price.

These inefficiencies cause patterns that deviate from the normal randomness of the market.

Sometimes, these patterns repeat and can be detected, predicted, and traded.

******Most successful algorithmic trading systems are built by modeling market inefficiencies

An edge is a market anomaly that consistently, and non-randomly, makes you money.

Algorithmic trading is a constant cycle of hypothesis formation and testing. This is why you learned Minimum Viable Python. You need to cycle through ideas as fast as you can since most of them will not work.

Service Architecture

The system is built on a service-oriented architecture with the following core services:

  1. Data Feed Services

    • MarketDataService: Real-time market data integration
    • NewsService: Multi-source news aggregation and preprocessing
  2. Trading Services

    • BrokerService: Broker API integration and order execution
    • OrderManager: Order lifecycle and position management
    • RoboAdvisorService: Automated portfolio management and recommendations
  3. Monitoring Services

    • SystemMonitor: System health and resource monitoring
    • PerformanceTracker: Trading performance analytics

Implementation Details

Service Layer

  • All services inherit from BaseService
  • Async/await pattern for improved performance
  • Robust error handling and logging
  • Configurable through YAML files
  • Built-in monitoring and metrics

Robo Advisor Components

  • Client profile management and risk assessment
  • Automated portfolio construction and rebalancing
  • Tax-loss harvesting optimization
  • Custom investment recommendations
  • Regular portfolio review and adjustments

Data Processing

  • Real-time market data processing
  • News aggregation and deduplication
  • Sentiment analysis using FinGPT
  • Market inefficiency detection

Trading Logic

  • Order lifecycle management
  • Position tracking and risk management
  • Performance monitoring and reporting
  • Automated trading signals

About

An algorithmic trading system based on FinGPT, demonstrating new applications of large pre-trained Language Models in quantitative finance.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages