This project is a multi-portfolio trading simulator built with Python. It uses Alpaca's API along with other data sources and OpenAI for strategy generation.
-
Create a
.envfile based on.env.exampleand fill in your API keys. -
Install requirements:
pip install -r requirements.txt
-
Run the environment test:
python -m tests.env_test
-
Test the portfolio manager (requires Alpaca paper account keys):
python -m tests.portfolio_test
-
Run the research engine test (requires network and API keys for best results):
python -m tests.research_test
-
Try the OpenAI strategy demo:
python -m tests.strategy_test
-
Run the risk management test:
python -m tests.risk_test
-
Run the diversification analysis test:
python -m tests.diversification_test
-
Generate an example trade export and report:
python -m tests.report_test
-
Run the Flask dashboard:
python app.pyThe dashboard lets you pick a strategy for each portfolio from a dropdown.
Each portfolio requires its own Alpaca API key and secret. The create form
in the dashboard asks for these credentials – one key pair cannot be shared
between multiple portfolios. The "Step" button accepts an optional comma-
separated list of symbols. If left blank, the simulator will trade a set of
trending tickers automatically. Set TRENDING_SOURCE=openai in your .env
file to let ChatGPT suggest trending symbols instead of using Yahoo Finance.
The Buy Only button works similarly but ignores sell signals and only
executes trades when a buy recommendation is returned.
Select debug in the Activity filter to view the exact prompts sent to
OpenAI and the received responses.
A small form inside each portfolio block also lets you submit manual market
orders. Provide a symbol, quantity and choose buy or sell. Manual trades are
stored in the history marked with [M].
Within the dashboard each portfolio provides a textarea to configure a custom
prompt for OpenAI. The prompt must contain the placeholders {strategy_type},
{portfolio} and {research} which will automatically be filled in before the
request is sent. Use the "Preview" button to see the generated decision before
saving the prompt.