Code for the Medium article I Made GPT-4 Trade Options
This repo uses poetry for dependency management. To install the dependencies, run:
poetry install
# then activate the virtual environment
poetry shell
Once the dependencies are installed, you must create a .env
file at ./tradegpt/.env
. This file should contain the following:
# ------- OPTIONAL --------
API_KEY=YOUR TDAmeritrade API KEY
REDIRECT_URI=https://localhost:8080
TOKEN_PATH=credentials.json
ACCOUNT_ID=YOUR TDAmeritrade ACCOUNT ID
# --------------------------
OPENAI_KEY=YOUR OPENAI KEY
and to run the bot:
cd tradegpt
python main.py AAPL
All runs are logged to ./tradegpt/reports/
.
The most important files for configuration are main.py and prompt.py. The former is the entrypoint for the bot, and the latter contains the prompt templates for the GPT-4 API.
main.py
: Update insights, data sources, model, and prompt selection. For a full list of insights, see insights/. For a full list of data sources, see sources/.prompt.py
: Update prompt templates.main.py
replaces the string$C
with insights at runtime.
If you'd like to contribute or have any questions, feel free to open an issue or PR.