Building Algorithmic Trading Strategies With AI (Bring Your Own Key)
How to use an AI trading assistant to build algorithmic strategies in Python while keeping full control: your model, your API key, your code, running locally from the terminal.
By Finny-AI team
AI is good at a specific, tedious part of algorithmic trading: turning a described edge into correct, runnable strategy code. It is not a crystal ball, and any tool that implies otherwise is selling something. This post is about using AI for what it is actually good at, while keeping control of the model, the key, and the code.
What “bring your own key” means and why it matters
Bring your own key (BYOK) means you connect the AI model of your choice using your own API credentials, instead of routing everything through a vendor's hosted model. Finny supports Claude, OpenAI, Gemini, and local models. That choice matters for three reasons:
- Cost control. You pay your model provider directly at their rates, with no markup layered on top.
- Model choice. Different models are better at different things. You can pick the one that writes the cleanest strategy code for your workflow, or run a local model when you want everything to stay on your machine.
- Privacy. Your key and your strategies stay under your control rather than being pooled behind someone else's service.
Connect a model
Point Finny at whichever model you want to use. Full configuration is in the BYOK docs, but the shape of it is simple:
# use your own key with the provider of your choice export ANTHROPIC_API_KEY=sk-... finny
The workflow: idea to strategy to test
The loop is the same regardless of which model you connect. You describe, the AI drafts, and you verify against data.
1. Describe the edge
Be specific about entries, exits, and the universe. “Mean-reversion on the QQQ: buy when RSI(2) drops below 10, sell when it closes above 60” gives the model everything it needs to write a testable strategy. Vague prompts produce vague code.
2. Let the AI write the Python
Finny generates a complete strategy that conforms to a canonical strategy contract. The output is open, readable Python, not a hidden configuration. You can read exactly what it will do before you trust it with anything.
3. Verify with a backtest
This is the non-negotiable step. Generated code is a hypothesis until it has run against real history. Backtest it, read the risk and drawdown numbers, and decide whether the idea survives contact with data. Our guide to backtesting from the terminal walks through how to read the results without fooling yourself.
Keep the human in the loop
The reason open code matters so much with AI is trust. A model will confidently write a strategy with a subtle look-ahead bug, an off-by-one in the signal, or an assumption that quietly inflates returns. Because Finny's output is Python you can read and edit, you can catch those problems instead of discovering them with real money. Treat the AI as a fast, tireless collaborator whose work you always review.
Getting started
Install the CLI, connect your model with your own key, and describe your first idea. The install guide and BYOK setup are the two pages you need to be running in a few minutes.
— Finny-AI team