Skip to content

OpenVanguard/Trade-Agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trade Agent

Overview

Trade Agent is a repository of AI agent configurations designed for scalable deployment across multiple stocks. Developed by the Open Agents Organization, these configurations leverage temporal stock data to optimize predictive accuracy for each stock. Built with scalability in mind, the repository allows for deploying and managing thousands of agent configurations on cloud platforms and container orchestration systems like AWS, Kubernetes, and Docker.

Key Features

  • Extensive Agent Pool: Each stock is analyzed by multiple agent configurations, enabling high predictive accuracy through top-performing agents. For example, 10 agents may be trained on data for Apple, and only the best are retained.

  • Massive Deployment Capability: Trade Agent configurations are built to run at scale, with thousands of agents deployed in parallel across stocks to optimize prediction.

  • Adaptive and Profitable Prediction: Agents automatically adapt to new data, ensuring predictions are continually refined to provide maximum potential accuracy.

Project Structure

Trade-Agent/
├── data/                # Temporal stock data for agent training
├── agents/              # Configuration files for each agent
├── models/              # Trained models for various configurations
├── src/                 # Core code for training, testing, and evaluation
│   ├── train.py         # Script to train agent configurations on stock data
│   ├── evaluate.py      # Script to evaluate and rank agents
│   ├── deploy.py        # Script for large-scale agent deployment
├── docker/              # Docker configuration files
├── kubernetes/          # Kubernetes deployment manifests
├── aws/                 # AWS setup scripts and configuration
├── README.md            # Project description and usage guide
└── requirements.txt     # Required packages

Getting Started

Prerequisites

  • Python 3.10.9
  • Packages listed in requirements.txt
  • Docker, AWS CLI, and kubectl installed for deployment

Install dependencies:

pip install -r requirements.txt

Setting Up Your Environment

  1. Prepare Stock Data: Gather historical stock data and place it in the data/ directory.

  2. Train Agent Configurations: Run the training script to initiate training for each stock. Each agent configuration will be evaluated for prediction quality.

    python src/train.py --stock-symbol AAPL --agent-count 10
  3. Evaluate Configurations: Use the evaluation script to rank agents and select only the top configurations for deployment.

    python src/evaluate.py --stock-symbol AAPL
  4. Deploy at Scale: Choose from deployment options below (AWS, Kubernetes, Docker) to deploy agents at scale.

Deployment Guide

1. Docker Deployment

To containerize and deploy Trade Agent configurations locally or in a cloud environment:

  1. Build the Docker Image:

    docker build -t trade-agent:latest -f docker/Dockerfile .
  2. Run a Docker Container: Run the container with a specific stock agent configuration.

    docker run -d --name trade_agent -e STOCK_SYMBOL=AAPL trade-agent:latest
  3. Build and Run the Docker Container Locally(additional): In the terminal, navigate to the directory containing your Dockerfile and run:

    # Build the Docker image
    docker build -t stock-agent .
    
    # Run the Docker container
    docker run -d stock-agent
  4. Scale with Docker Compose: If running multiple agents simultaneously, use docker-compose.yml for multi-container deployment:

    docker-compose -f docker/docker-compose.yml up -d

2. Kubernetes Deployment

For large-scale, distributed deployment, Trade Agent can be orchestrated using Kubernetes:

  1. Deploying on Kubernetes: Use the provided Kubernetes manifests to deploy agents as pods.

    kubectl apply -f kubernetes/deployment.yaml
  2. Scaling Pods: To run multiple agents for the same or different stocks, configure replicas in the deployment.yaml or scale the deployment on the fly:

    kubectl scale deployment trade-agent --replicas=10
  3. Monitoring and Logging: Use kubectl logs to view real-time logs of individual agent pods.

    kubectl logs -f <pod-name>

3. AWS Deployment

To deploy agents on AWS infrastructure, the repository includes CloudFormation templates and sample scripts:

  1. Setting up an EC2 Instance: Use the AWS CLI or console to set up an EC2 instance with Docker and Docker Compose pre-installed.

  2. Using ECS for Container Deployment:

    • Build and Push to ECR: First, create an Elastic Container Registry (ECR) repository and push the Docker image:

      aws ecr create-repository --repository-name trade-agent
      docker tag trade-agent:latest <aws_account_id>.dkr.ecr.<region>.amazonaws.com/trade-agent:latest
      docker push <aws_account_id>.dkr.ecr.<region>.amazonaws.com/trade-agent:latest
    • Deploy to ECS: Use ECS to run and manage Docker containers at scale. Use aws/ecs-task-definition.json to define task parameters.

      aws ecs register-task-definition --cli-input-json file://aws/ecs-task-definition.json
      aws ecs run-task --cluster <cluster-name> --task-definition trade-agent
  3. Auto-Scaling with AWS Lambda and CloudWatch: Set up auto-scaling policies on ECS based on CPU/memory metrics, using CloudWatch alarms and Lambda functions to dynamically scale up or down based on load.

Emphasis on Scale and Adaptability

Trade Agent is designed for large-scale deployment, supporting thousands of agent configurations operating in parallel across multiple stocks. By deploying on Docker, Kubernetes, or AWS, the repository provides flexible deployment options for small-scale testing to full production environments, enabling rapid identification of optimal agents for stock prediction.

Contributions

The Open Agents Organization welcomes community contributions! Improvements, bug fixes, and suggestions for enhancing the scalability and predictive accuracy of Trade Agent configurations are encouraged.

License

This project is licensed under the MIT License.

Contact

For questions, suggestions, or collaboration requests, please reach out to the Open Agents.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages