I love this direction.
Instead of "adding AI," you're going to build a distributed system where
a C++ client talks to a Python AI service. That's much closer to how production systems are
designed.
I would make this Repository 2 (or Phase 12 if you want to keep it in the same repo). The
questions should be incremental so that each one introduces a new concept without
overwhelming you.
Repository 2 — QuantCalc AI Service
Objective
Extend QuantCalc by building a Python AI microservice that communicates with your C++
application.
By the end, your project should include:
● Python FastAPI server
● REST API
● JSON communication
● Prompt management
● AI integration
● Shared schema
● C++ HTTP client
● End-to-end communication
Phase 1 — Python Service Setup
Question 1
Create a new folder
python_ai/
Inside it create
[Link]
[Link]
[Link]
[Link]
.env
Question 2
Create a Python virtual environment.
Install
● FastAPI
● Uvicorn
● Pydantic
● python-dotenv
● OpenAI (or Ollama client)
Save all dependencies inside
[Link]
Question 3
Create a basic FastAPI application.
Running
uvicorn app:app --reload
should display
QuantCalc AI Service Running
when visiting
[Link]
Question 4
Create a health endpoint.
GET /health
Return
{
"status":"ok"
}
Your C++ application will use this later to verify the AI service is online.
Phase 2 — JSON Communication
Question 5
Create a folder
shared/
Question 6
Create
trade_schema.json
containing
● Buy Price
● Current Price
● Shares
● Position Value
● Profit
● Return
● Risk
● Reward
● Risk Reward Ratio
Question 7
Create a Pydantic model in Python that matches the JSON schema.
Name it
TradeAnalysisRequest
Question 8
Create
POST /analyze-trade
that accepts the TradeAnalysisRequest.
For now, simply return
{
"message":"Trade received successfully."
}
Phase 3 — Prompt Engineering
Question 9
Create
[Link]
Store prompts as reusable Python functions.
Example
build_trade_prompt(...)
Question 10
Generate a prompt using the trade information.
The prompt should include
● Position Value
● Profit
● Return
● Risk
● Reward
● Risk/Reward Ratio
Question 11
Modify
/analyze-trade
so that instead of returning
Trade received
it returns the generated prompt.
This verifies your prompt builder works correctly.
Phase 4 — AI Integration
Question 12
Load your API key from
.env
Never hardcode secrets inside your code.
Question 13
Create
[Link]
Implement
analyzeTrade(prompt)
This function should
● receive a prompt
● call the selected AI model
● return the response
Question 14
Update
/analyze-trade
to return the AI response instead of the generated prompt.
Question 15
Handle AI errors gracefully.
If the AI service is unavailable,
return
{
"error":"Unable to analyze trade."
}
instead of crashing.
Phase 5 — Portfolio Review
Question 16
Create another request model
PortfolioRequest
Accept
● Stock 1
● Stock 2
● Stock 3
● Total Value
Question 17
Create
POST /portfolio-review
Generate an AI portfolio review.
Question 18
Store the portfolio prompt inside
[Link]
Reuse your AI function.
Phase 6 — Learning Mode
Question 19
Create
POST /explain
Inputs
● Formula Name
● Formula
● Result
Question 20
Ask the AI to explain the calculation in beginner-friendly language.
Phase 7 — Connecting C++ and Python
Question 21
Research how C++ applications communicate with REST APIs.
Write a short section in your README explaining
● HTTP
● JSON
● Client
● Server
Question 22
Choose an HTTP library for C++.
Recommended options:
● libcurl
● cpr
Install it.
Question 23
Create a reusable C++ function
std::string sendPostRequest(...)
that sends JSON to the Python service.
Question 24
Convert your Position Value result into JSON.
Send it to
POST /explain
Display the returned explanation.
Question 25
Convert your trade calculation into JSON.
Send it to
POST /analyze-trade
Display the AI analysis.
Question 26
Send your portfolio information to
POST /portfolio-review
Display the AI response.
Phase 8 — Integration
Question 27
Add a new menu to QuantCalc.
9. AI Features
Question 28
Create an AI submenu.
1. Trade Analysis
2. Portfolio Review
3. Explain Calculation
4. Back
Question 29
Before sending a request,
check
GET /health
If the Python service is offline,
display
AI Service Offline
instead of crashing.
Question 30
Display a loading message while waiting for the AI response.
Example
Analyzing trade...
Phase 9 — Final Challenge
Question 31
Refactor your project into the following structure.
quantcalc/
├── cpp/
│ ├── include/
│ ├── src/
│ └── [Link]
│
├── python_ai/
│ ├── [Link]
│ ├── [Link]
│ ├── [Link]
│ ├── [Link]
│ └── .env
│
├── shared/
│ └── trade_schema.json
│
└── [Link]
Question 32
Document how to start both applications.
Example workflow:
1. Start the Python AI service.
2. Verify it is healthy using /health.
3. Build and run the C++ application.
4. Use the AI menu to analyze trades, review portfolios, or explain calculations.
Final Outcome
When you finish these questions, you'll have a complete client-server application:
User
│
▼
QuantCalc (C++)
│
Financial Library
│
JSON Request
│
▼
FastAPI AI Service
│
Prompt Builder
│
▼
OpenAI / Ollama
│
AI Response
│
▼
QuantCalc Terminal
This teaches far more than AI alone. You'll gain practical experience with C++, Python,
REST APIs, JSON serialization, FastAPI, LLM integration, and client-server
architecture—all skills that transfer well to modern quant, fintech, and AI engineering
projects.
I actually like where you're going with this. Right now your first repository isn't just "build a
calculator"—it's a guided project where every question teaches one concept.
I'd do the same for the AI part.
Instead of saying "Create [Link]", the questions should gradually teach:
● FastAPI
● REST APIs
● Pydantic
● JSON
● Environment variables
● Prompt engineering
● HTTP requests
● C++ HTTP clients
● API integration
Then by the end, you've naturally built the entire system.
Here's how I'd structure it.
Repository 2 — QuantCalc AI
Objective
Turn QuantCalc into an AI-powered quantitative finance assistant.
By the end, your application should:
● Run a Python AI server
● Accept requests from C++
● Analyze trades with AI
● Explain calculations
● Review portfolios
● Return responses back to the C++ terminal
Phase 1 — Building Your First API
Question 1
Create a folder
python_ai/
Inside create
[Link]
[Link]
.env
Question 2
Create a Python virtual environment.
Install
● fastapi
● uvicorn
● pydantic
● python-dotenv
Generate
[Link]
Question 3
Inside [Link], create your first FastAPI application.
When you run
uvicorn app:app --reload
the server should start successfully.
Question 4
Create a GET endpoint
that returns
{
"message":"QuantCalc AI Server Running"
}
Question 5
Open the endpoint in your browser.
Verify that the JSON response is returned.
Question 6
Create another endpoint
GET /health
Return
{
"status":"healthy"
}
Phase 2 — Learning REST APIs
Question 7
Research the difference between
● GET
● POST
Write your findings inside the README.
Question 8
Create your first POST endpoint.
POST /hello
Accept
{
"name":"Yvvon"
}
Return
{
"message":"Hello Yvvon"
}
Question 9
Instead of reading JSON manually,
create your first Pydantic model.
class HelloRequest(BaseModel):
Use it in your endpoint.
Question 10
Verify your endpoint works using
Swagger UI
[Link]
Phase 3 — Trade Models
Question 11
Create a folder
shared/
Question 12
Create
trade_schema.json
Describe a trade containing
● Buy Price
● Current Price
● Shares
Question 13
Create
TradeRequest
inside [Link].
It should match the schema.
Question 14
Expand the model.
Add
● Position Value
● Profit
● Return
Question 15
Expand it again.
Add
● Risk
● Reward
● Risk Reward Ratio
Question 16
Create
POST /trade
Return
{
"received": true
}
Question 17
Return the received trade back to the user.
This teaches serialization.
Phase 4 — Prompt Engineering
Question 18
Create
[Link]
Question 19
Create
buildTradePrompt(...)
Accept a TradeRequest.
Return a formatted string.
Question 20
Include
● Position Value
● Profit
● Return
inside the prompt.
Question 21
Add
● Risk
● Reward
● Risk Reward Ratio
Question 22
Modify
POST /trade
Return the generated prompt instead of JSON.
Phase 5 — Talking to AI
Question 23
Create
[Link]
Question 24
Load the API key from
.env
Never hardcode it.
Question 25
Create
def ask_ai(prompt):
For now
return
"AI Coming Soon"
Question 26
Replace the dummy string.
Call the OpenAI (or Ollama) API.
Return the response.
Question 27
Modify
POST /trade
Call
ask_ai()
Return the AI response.
Question 28
Handle API errors.
Return meaningful JSON if something fails.
Phase 6 — Portfolio Review
Question 29
Create
PortfolioRequest
Question 30
Create
POST /portfolio-review
Accept
● Stock 1
● Stock 2
● Stock 3
● Portfolio Value
Question 31
Create
buildPortfolioPrompt()
Question 32
Send it to the AI.
Return the response.
Phase 7 — Learning Mode
Question 33
Create
POST /explain
Accept
● Formula
● Inputs
● Output
Question 34
Generate a prompt asking the AI to explain the calculation.
Question 35
Return the explanation.
Phase 8 — C++ HTTP Client
Question 36
Research HTTP requests in C++.
Choose one library
● libcurl
● cpr
Question 37
Install the library.
Verify it compiles.
Question 38
Create
std::string sendGetRequest(...)
Test it using
GET /health
Display
Server Online
if successful.
Question 39
Create
std::string sendPostRequest(...)
Accept
● URL
● JSON
Return the server response.
Question 40
Research JSON libraries for C++.
Install
nlohmann/json
Question 41
Create a Trade JSON object using your calculation results.
Question 42
Serialize it into JSON text.
Question 43
Send it to
POST /trade
Display the returned AI analysis.
Question 44
Create another JSON object for
/explain
Question 45
Display the AI explanation inside your terminal.
Phase 9 — Integrating Everything
Question 46
Add an AI menu to QuantCalc.
9. AI Features
Question 47
Create an AI submenu.
1. Trade Analysis
2. Portfolio Review
3. Explain Formula
4. Back
Question 48
Connect Trade Analysis to
POST /trade
Question 49
Connect Portfolio Review to
POST /portfolio-review
Question 50
Connect Explain Formula to
POST /explain
Question 51
Before every request,
check
GET /health
If offline,
display
AI Service Offline
Question 52
Display
Analyzing...
while waiting.
Question 53
Display the AI response inside a nicely formatted terminal box.
Example:
=========================================
AI TRADE ANALYSIS
=========================================
Profit: $650
Return: 8.3%
Recommendation:
Your trade has a healthy
risk/reward ratio...
=========================================
Final Challenge — End-to-End
Integration
Question 54
Refactor the project into:
quantcalc/
├── cpp/
│ ├── include/
│ ├── src/
│ └── [Link]
│
├── python_ai/
│ ├── [Link]
│ ├── [Link]
│ ├── [Link]
│ ├── [Link]
│ └── .env
│
├── shared/
│ └── trade_schema.json
│
└── [Link]
Question 55
Run both applications together.
● Start the Python FastAPI server.
● Build and run the C++ application.
● Verify the C++ client can:
○ Check the AI server health.
○ Send trade analysis requests.
○ Request portfolio reviews.
○ Ask for calculation explanations.
○ Display the AI responses in the terminal.
I like this progression because every question requires you to write real code. By the end,
you'll have built a complete multi-language system where C++ acts as the client, Python
provides the AI service, and the two communicate over HTTP using JSON—the same
architectural pattern you'll encounter in many modern fintech and AI-backed applications.