Skip to content

IatomicreactorI/CSGOTrading

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CSGOTrading: Multi-Agent LLM Framework for CS2 Market Trading

License: MIT Python 3.8+ LangGraph

An intelligent multi-agent system leveraging Large Language Models for automated Counter-Strike 2 market analysis and trading decisions


πŸ“‹ Abstract

CSGOTrading presents a novel multi-agent framework that applies Large Language Models (LLMs) to the domain of virtual item trading in Counter-Strike 2 (CS2) markets. Our system employs a hierarchical agent architecture built on LangGraph, incorporating specialized analyst agents (technical, sentiment, liquidity, and event-driven) coordinated by a meta-planner agent. The portfolio manager agent synthesizes multi-modal market signals to generate optimal trading decisions while accounting for transaction costs and risk constraints.

Key contributions:

  • Multi-Agent Architecture: Modular design with specialized analyst agents for different market aspects
  • Dynamic Agent Selection: Meta-planner agent adaptively selects relevant analysts based on market conditions
  • Multi-Source Data Integration: Seamless aggregation of CS2 market data, Steam news, and Reddit sentiment
  • Configurable Workflow: Support for both agentic workflows and direct LLM analysis modes
  • Risk-Aware Portfolio Management: Sophisticated position sizing with transaction cost modeling

🎯 System Concept

System Concept

πŸ—οΈ System Architecture

Overall Structure

Agent Specifications

Agent Function Input Output
Planner Selects relevant analysts based on market context Ticker, available analysts List of selected analysts
Technical Analyst Analyzes price patterns and trends Historical price data Technical signals (BUY/SELL/HOLD)
Sentiment Analyst Processes community sentiment Reddit posts, Steam news Sentiment score and direction
Liquidity Analyst Evaluates market depth and volume Order book, trading volume Liquidity assessment
Event Analyst Identifies market-moving events News, updates Event impact analysis
Portfolio Manager Executes risk-aware trading decisions Analyst signals, portfolio state Trading actions with position sizes

✨ Key Features

πŸ€– Multi-Modal Analysis

  • Technical Analysis: Price action, trend detection, support/resistance levels
  • Sentiment Analysis: NLP-based sentiment extraction from Reddit and Steam communities
  • Liquidity Analysis: Market depth and volume-based assessments
  • Event-Driven Analysis: Impact evaluation of game updates and news

🧠 Intelligent Agent Coordination

  • Meta-Planner: Dynamically selects optimal analyst combination for each ticker
  • Modular Design: Easily extensible agent registry system
  • Flexible Workflows: Support for both agentic and direct LLM modes

πŸ’Ό Advanced Portfolio Management

  • Risk Control: Maximum position ratio constraints and drawdown protection
  • Transaction Costs: Realistic modeling of 2% trading fees
  • Position Sizing: Intelligent allocation across multiple assets
  • State Persistence: Complete portfolio history tracking in database

πŸ”§ Production-Ready Infrastructure

  • Database Support: SQLite for local development
  • Multi-Provider LLM: OpenAI, Anthropic, DeepSeek, Ollama, etc.
  • Extensive Configuration: 50+ pre-configured experiment setups
  • Comprehensive Logging: Detailed agent execution and decision tracking

πŸ“¦ Installation

Prerequisites

  • Python 3.8 or higher
  • pip package manager
  • (Optional) SQLite for local database

Setup

  1. Clone the repository
git clone https://github.com/IatomicreactorI/CSGOTrading.git
cd CSGOTrading
  1. Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies
pip install -r requirements.txt
  1. Configure environment variables
cp .env.example .env
# Edit .env and add your API keys:
# - OPENAI_API_KEY (for OpenAI models)
# - ANTHROPIC_API_KEY (for Claude models)
# - DEEPSEEK_API_KEY (for DeepSeek models)
  1. Initialize database
python database/cs2_sqlite_setup.py
  1. Fetch historical data

Before running experiments, you can pre-fetch historical data to avoid API rate limits during backtesting:

Fetch Reddit data (past 1 year):

# From project root directory
python -m apis.reddit.fetch_reddit_data

This script fetches Reddit posts from the past year and saves them to apis/reddit/reddit_data.csv. No parameters required.

Fetch Steam news data:

# From project root directory
python -m apis.steam.fetch_steam_data \
  --config config/Direct-cd.yaml \
  --start-date 2025-09-25 \
  --end-date 2025-11-15 \
  --limit 15

Parameters:

  • --config: Path to config YAML file (must contain exp_name and tickers)
  • --start-date: Start date in YYYY-MM-DD format (required)
  • --end-date: End date in YYYY-MM-DD format, inclusive (required)
  • --limit: Maximum news items per ticker per day (default: 15, optional)
  • --output: Output CSV file path (default: <script_dir>/steam_data.csv, optional)

Fetch CS2 market data:

# From project root directory
python -m apis.cs2market.fetch_cs2_data

This script fetches current price data for candidate items from Steam Community Market and saves to apis/cs2market/cs2_data.csv. No parameters required. The script will automatically retry failed items up to 3 times.

Note: These fetch scripts can be run anytime to update the historical data. The main experiment workflow will use these CSV files to avoid making API calls during backtesting.


πŸš€ Quick Start

Basic Usage

Run a single-day experiment with default configuration:

python run.py --config TS-ds.yaml --start-date 2025-09-25 --end-date 2025-09-25

Batch Experiments

Run multi-day backtesting:

python run.py \
  --config TS-ds.yaml \
  --start-date 2025-09-25 \
  --end-date 2025-10-27

Configuration Options

The system supports multiple workflow configurations:

  • Direct: Direct LLM analysis without analyst agents
  • T: Technical analyst only
  • TS: Technical + Sentiment analysts
  • TSL: Technical + Sentiment + Liquidity
  • TSLE: All analysts (Technical + Sentiment + Liquidity + Event)
  • TSrL: Technical + Reverse Sentiment + Liquidity

Each configuration can be combined with different LLM providers:

  • -ds: DeepSeek
  • -gm: Gemini
  • -gt: GPT
  • -cd: Claude
  • -km: Kimi
  • -qw: Qwen

Example: TSLE-cd.yaml uses all analysts with Claude 3.5 Sonnet.

View Results

# View all information of specified experiment
python view.py TS-ds

# View portfolios
python view.py TS-ds portfolios

# View latest positions
python view.py TS-ds positions

# View daily portfolios and export CSV
python view.py TS-ds daily

# View portfolios of specified date
python view.py TS-ds daily 2025-09-26

# Export thinking process JSON file
python view.py TS-ds thinking

# View data summary
python view.py TS-ds summary

# List all experiments
python view.py list

Clear Results

# Clear experiment data
python clear.py --config-name TS-ds

πŸ“Š Configuration

Workflow Configuration (config/)

exp_name: "TS-ds"  # Experiment name
cashflow: 10000    # Initial capital
tickers:           # Assets to trade
  - "AK-47 | Redline (Field-Tested)"
  - "AWP | Asiimov (Field-Tested)"

llm:               # LLM configuration
  provider: "deepseek"
  model: "deepseek-chat"

planner_mode: true        # Enable meta-planner
workflow_analysts:        # Available analysts
  - technical
  - sentiment

enable_transaction_fee: true  # Include trading costs

Database Configuration

Local SQLite (default):

python run.py --config TS-ds.yaml

πŸ—‚οΈ Project Structure

CSGOTrading/
β”œβ”€β”€ agents/                  # Agent implementations
β”‚   β”œβ”€β”€ planner.py          # Meta-planner agent
β”‚   β”œβ”€β”€ portfolio_manager.py # Portfolio management
β”‚   β”œβ”€β”€ registry.py         # Agent registry
β”‚   └── analysts/           # Specialized analysts
β”‚       β”œβ”€β”€ technical.py
β”‚       β”œβ”€β”€ sentiment.py
β”‚       β”œβ”€β”€ sentiment_reverse.py
β”‚       β”œβ”€β”€ liquidity.py
β”‚       └── event.py
β”œβ”€β”€ apis/                   # Data source integrations
β”‚   β”œβ”€β”€ cs2market/          # CS2 market data
β”‚   β”œβ”€β”€ steam/              # Steam news API
β”‚   β”œβ”€β”€ reddit/             # Reddit sentiment API
β”‚   β”œβ”€β”€ router.py           # API router
β”‚   └── common_model.py     # Common data models
β”œβ”€β”€ database/               # Database layer
β”‚   β”œβ”€β”€ interface.py        # Abstract interface
β”‚   β”œβ”€β”€ cs2_sqlite_helper.py
β”‚   └── cs2_sqlite_setup.py
β”œβ”€β”€ graph/                  # LangGraph workflow
β”‚   β”œβ”€β”€ workflow.py         # Main workflow
β”‚   β”œβ”€β”€ schema.py           # State definitions
β”‚   └── constants.py
β”œβ”€β”€ llm/                    # LLM integration
β”‚   β”œβ”€β”€ inference.py        # LLM calls
β”‚   β”œβ”€β”€ provider.py         # Provider configs
β”‚   └── prompt.py           # Prompt templates
β”œβ”€β”€ config/                 # Experiment configurations
β”œβ”€β”€ util/                   # Utilities
β”‚   β”œβ”€β”€ config.py
β”‚   β”œβ”€β”€ cs2_db_helper.py
β”‚   └── logger.py
β”œβ”€β”€ figs/                   # Figures and images
β”œβ”€β”€ run.py                  # Main execution script
β”œβ”€β”€ view.py                 # Results visualization
β”œβ”€β”€ clear.py                # Data cleanup
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ .env.example            # Environment variables template
β”œβ”€β”€ LICENSE
└── README.md

πŸ”¬ Advanced Usage

Adding Custom Analysts

  1. Create analyst implementation in agents/analysts/:
from graph.constants import AgentKey
from llm.inference import agent_call

def custom_analyst(ticker: str, llm_config, analyst_signal):
    # Your analysis logic here
    return {
        "action": "BUY",
        "confidence": 0.8,
        "justification": "Analysis reasoning"
    }
  1. Register in agents/registry.py:
AgentRegistry.register(
    AgentKey.CUSTOM,
    custom_analyst,
    "Custom analyst description"
)
  1. Add to workflow configuration:
workflow_analysts:
  - technical
  - sentiment
  - custom  # Your new analyst

Custom LLM Providers

Add provider configuration in llm/provider.py:

@dataclass
class ProviderConfig:
    name: str
    model_class: Any
    requires_api_key: bool = True
    env_key: str = "CUSTOM_API_KEY"
    base_url: str = None

# Register provider
Provider.add_provider("custom", ProviderConfig(...))

🀝 Contributing

We welcome contributions from the community! Please follow these guidelines:

  1. Fork the repository and create a feature branch
  2. Follow PEP 8 coding standards
  3. Add tests for new functionality
  4. Update documentation for API changes
  5. Submit a pull request with a clear description

Development Setup

# Install development dependencies
pip install -r requirements-dev.txt

# Run tests
pytest tests/

# Run linting
flake8 .
black .

πŸ“„ License

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


πŸ™ Acknowledgments

  • LangChain & LangGraph: Foundation for agent orchestration
  • OpenAI, Anthropic, DeepSeek: LLM providers
  • CS2 Community: Market data and insights
  • Contributors: All community contributors

πŸ—ΊοΈ Roadmap

Upcoming Features

  • Reinforcement Learning Integration: Train agents with RL for adaptive strategies
  • Real-time Trading: Live market integration and execution
  • Advanced Risk Models: VaR, CVaR, and Kelly criterion
  • Multi-Asset Correlation: Cross-asset analysis and hedging
  • Web Dashboard: Interactive visualization and monitoring
  • Distributed Execution: Multi-process and cloud deployment
  • More Data Sources: Integration with additional market APIs

Version History

  • v0.1.0 (2026-01-05): Initial release with core multi-agent framework
  • v0.0.1 (2025-12): Private beta testing

⭐ Star this repository if you find it useful! ⭐

Made with ❀️ by the CSGOTrading Team

About

This is an official github repo for CSGOTrading project.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages