ContestTrade is an innovative Multi-Agent trading framework that aims to build a team of AI traders specialized in event-driven stock selection. The system works by mimicking the decision-making process of an investment firm, allowing different AI intelligences to collaborate and compete with each other through an internal competition mechanism. The whole process requires no human intervention, and the system is able to automatically scan the entire A-share market to discover investment opportunities driven by specific events from a huge amount of data such as news, announcements and capital flows. Eventually, through layers of screening and optimization, the system generates a trustworthy portfolio recommendation. Its core design idea is to utilize the "collective wisdom" of multiple AIs to improve the adaptability and reliability of decision-making in a complex market environment.
Function List
- Automated Stock Screening: The system automatically scans the entire market and generates a list of tradable stock candidates, eliminating the need for the user to manually screen them one by one.
- event-driven strategy: Focus on investment opportunities triggered by catalytic events such as news, company announcements, capital flows, industry policies, etc. to capture short-term market dynamics.
- Personalized Intelligent Body ConfigurationUsers can customize the "trading beliefs" of the Research Agent by modifying the configuration file, so that the AI's behavior matches their own unique investment style and risk appetite.
- Two-stage decision-making processThe workflow of a professional investment team is simulated through two phases: "Data Processing" and "Research and Decision Making". The first stage is to process raw data and refine effective factors, and the second stage is to conduct in-depth analysis based on these factors and form the final investment portfolio.
- Command Line Interactive Interface: With simple command line startup and operation, users can easily set the analysis time and view the final analysis reports and trading signals.
Using Help
ContestTrade provides a complete, out-of-the-box AI trading research environment. Below you will find details on how to install, configure and use this framework.
1. Installation process
The installation process is very simple and requires only a few basic steps. You'll need to install Git and a Python environment (Python version 3.10 is recommended).
Step 1: Clone the project code
First, open your terminal (command line tool) and use thegit
command to clone the project's code from GitHub to your local computer.
git clone https://github.com/FinStep-AI/ContestTrade.git
Then, go to the directory of the project you just cloned down.
cd ContestTrade
Step 2: Create and activate a virtual environment (recommended)
To avoid library dependency conflicts between different Python projects, it is highly recommended to create a separate virtual environment. Here's an example of a conda
As an example.
Create a file named contesttrade
and specify Python version 3.10.
conda create -n contesttrade python=3.10
After successful creation, activate this virtual environment.
conda activate contesttrade
After activation, the command prompt in front of your terminal will show (contesttrade)
, indicating that you are currently in this separate environment.
Step 3: Install project dependencies
All dependency libraries required by the project are documented in the requirements.txt
file. Use the pip
command can be installed with one click.
pip install -r requirements.txt
This command automatically downloads and installs all third-party libraries required for the framework to run.
2. Configuration instructions
Before running the program, you need to configure some necessary API keys so that the framework can fetch data and use the Large Language Model (LLM).
The configuration file is the project root directory config.yaml
. Please open this file with a text editor and fill in your personal key.
Required configuration item:
TUSHARE_KEY
: Tushare is a platform that provides domestic financial data. You need to register for a Tushare account and get your exclusive API key. This is the core interface for the framework to access basic data such as stock quotes, financials, etc. and must be filled out.LLM
: This is the Big Language Model API configuration for performing generic tasks. You will need to fill in the following fields depending on the big model service provider you choose (e.g. OpenAI, Smart Spectrum AI, Moonshot, etc.)api_key
,base_url
cap (a poem)model_name
The
Optional configuration item:
BOCHA_KEY
cap (a poem)SERP_KEY
: These are API keys for search engines, used to allow AI intelligences to search for information on the Internet. You can choose to configure them as needed, and configuring at least one can help the AI get a wider range of information.LLM_THINKING
: A large language modeling API for complex reasoning tasks. you can configure a more powerful model for steps that require deep thinking.VLM
: API for visual language modeling for possible future additions such as chart analysis.
A sample configuration might look like the following:
TUSHARE_KEY: "你的tushare密钥"
BOCHA_KEY: "你的bocha密钥"
SERP_KEY: ""
LLM:
api_key: "你的llm_api_key"
base_url: "你的llm_base_url"
model_name: "gpt-4"
LLM_THINKING:
api_key: "你的llm_api_key"
base_url: "你的llm_base_url"
model_name: "gpt-4-turbo"
VLM:
api_key: ""
base_url: ""
model_name: ""
3. Customized stock selection preferences
One of the core features of ContestTrade is that it allows the user to define the Trading Beliefs of the Research Agent. Each belief represents a different investment strategy or market perspective.
The configuration file is located in the contest_trade/config/belief_list.json
It is a text file in JSON format. It is a text file in JSON format with an array of strings, each of which is a transaction belief.
How to Modify:
Open with a text editor belief_list.json
Documentation. You can modify, delete, or add descriptions of the beliefs inside. The framework launches a corresponding research intelligence for each belief in the file.
Faith Example:
- Aggressive short-term event-driven strategies::
[
"专注于短期事件驱动机会:优先关注公司公告、并购重组、订单暴增、技术突破等催化事件;偏好中小市值、高波动的题材股,适合激进套利策略。"
]
- Robust deterministic event strategy::
[
"专注于稳健的确定性事件:关注分红、回购、业绩预告确认、重大合同落地和政策利好等;偏好大盘蓝筹、低波动、确定性高的标的,适合稳健配置。"
]
You can design as many beliefs as you like according to your own investment understanding. For example, you can add a focus on "northward capital movements and the resonance of institutional seats on the Dragon Tiger list" beliefs, the system will be specifically trained for this purpose, an intelligent body to analyze such opportunities.
4. Activation and utilization
After completing the installation and configuration, you can start the program.
In the root directory of the project (ContestTrade
directory), open a terminal (make sure the virtual environment is activated) and run the following command:
python -m cli.main run
When the program starts, it enters an interactive terminal interface. It will prompt you to enter an analyzed date (in the format of YYYY-MM-DD
). Type in the date you want to analyze and press enter and the system will start working.
After that, you will see the logs of the individual intelligences (Data Analytics Intelligence, Research Intelligence) starting to run in the terminal. The whole process is fully automated, they acquire data, analyze factors, generate reports, and screen stocks based on the beliefs you set.
After all the tasks are completed, the program outputs a summary of the results at the terminal, which contains the trading signals (list of candidate stocks) found by the individual research intelligences according to their beliefs. You can view this summary directly, or you can choose to view a more detailed analysis report generated by the AI.
application scenario
- Quantitative trading researchers
Researchers can use this framework to test and validate theories about the application of multi-intelligent body systems in financial markets. They can customize the behavior and beliefs of the intelligences, explore the impact of different AI collaboration patterns on investment decisions, and use it as a scalable infrastructure to develop more complex trading paradigms. - Finance or computer science majors
ContestTrade is an ideal learning tool for students who are studying quantitative trading, artificial intelligence, or financial technology. It provides a complete, real-world application example that demonstrates how to apply Large Language Modeling (LLM) and Multi-Intelligent Body techniques to complex financial decision-making scenarios. Students can practice and deepen their understanding hands-on by modifying code and configurations. - Individual investors and technology enthusiasts
Individual investors interested in a technology-driven approach to investing can use this framework to support their decision-making. By defining "trading beliefs" that align with their investment philosophy, they can use AI to automatically scan and identify potential event-driven opportunities in the marketplace, saving them a great deal of time in manually sifting through information.
QA
- Which countries' stock markets are currently supported by this framework?
Currently, the ContestTrade framework only supports the Chinese A-share market. According to the project's roadmap, there are plans to expand support for the US and Hong Kong stock markets in the future. - Do I need to pay to run this framework?
The ContestTrade project itself is open source and free, you can download and use it freely. However, running this framework requires calling some third-party services, which may incur costs. For example, the Tushare data interface, API calls for the Large Language Model (LLM), and APIs for search engines may require payment. - Can I use this framework if I am not a programmer?
Using this framework requires some basic programming knowledge, at least an understanding of how to use the terminal (command line), configure theYAML
cap (a poem)JSON
Documentation. While the core analysis process is automated, the preliminary installation and configuration steps need to be completed manually by the user. - Are the trading signals provided by this program investment advice?
Not. The project clearly states in its risk statement that ContestTrade is an open source project for academic research and educational purposes. All outputs, including trading signals and analysis, are based on AI model extrapolations of historical data and do not constitute any form of investment, financial, legal or tax advice. Users are responsible for all investment risks.