Originally published on medium.com

Disclosure: This is a paper-trading demonstration, not financial advice or a record of money invested. The Python implementation and its mocked tests have been run. The live EODHD data pipeline (fetching, feature calculation and eligibility filtering for AAPL, TSLA, AMZN and VTI) has been verified against the real EODHD API. The live Jev call has not been made in this environment, because it requires a TypeSafe API key that was not available here. No live model selection, real-money return or market outperformance is claimed below.
Ask a chatbot which stock to buy and you will get a confident answer.
Ask again tomorrow, with slightly different wording, and you may get a different one.
That is not really the modelās fault. It is the experimentās fault. If you never define what data the AI can see, what it is allowed to decide, and what happens when the evidence is weak, you cannot tell a useful answer from a convincing one.
If youāre:
this is for you.
A good paragraph about Appleās momentum is still just a paragraph.
It may mention valuation, market conditions and risk. It may even sound like something an analyst would write. But there is no process behind it. No fixed inputs, no constraints, no record of what the model knew at the time.
So I built a narrower challenge: give an AI a hypothetical $10,000 portfolio, real historical market data, and exactly one decision to make. Then evaluate that decision in a transparent paper portfolio instead of trusting the prose.
The system has three jobs, each owned by a different piece:
Jev cannot change the portfolio weights. It cannot execute a trade.
It can only choose from a menu I wrote in advance.
Jev is not a chat model asked to write an essay about Tesla. Its API accepts a state and typed questions, including a choice between predefined options. The response contains the selected option, a probability distribution and a confidence measure. My code decides what to do with that answer. (TypeSafe API documentation)
That solves half the problem. The other half is data.
Most AI-investing demos quietly skip this part. Prices get copied from screenshots, or worse, the model is asked to remember them. For a reproducible experiment you need a proper market-data feed, so I use the EODHD End-of-Day Historical Data API. Each daily record includes the date and an adjusted closing price, which works for split- and dividend-adjusted return comparisons. Adjusted prices are a total-return proxy, not prices you could actually have traded at.
The tutorial uses four symbols: AAPL.US, TSLA.US, AMZN.US and VTI.US. EODHD's demo-access documentation lists these for testing with a demo token, though you should still check availability and account limits before running a full series. (EODHD Quick Start)
Get the data layer I used for this experiment
Daily adjusted prices for stocks and ETFs through one REST API, with a demo token to test first. Use code KEVIN10 for 10% off.
ā Try the EODHD API
I split the imaginary portfolio into two parts:

VTI tracks the broad US stock market. It is not an S&P 500 ETF, so the fair baseline here is a 100% VTI paper portfolio, not the S&P 500.
Before Jev sees anything, Python checks three conditions for every candidate stock, using only data available on or before the decision date:
These are demonstration rules, not universal buy signals.
If no stock qualifies, the sleeve stays in CASH and Jev is never called. If Jev picks a stock but its confidence is low, the result defaults to CASH anyway. The 55% confidence gate is a workflow choice. It is not a 55% chance of making money.
The endpoint:
GET https://eodhd.com/api/eod/AAPL.US?api_token=demo&fmt=json
The full script requests a date window, parses date and adjusted_close, rejects missing or nonpositive prices, and aligns all four instruments to common trading sessions. The token comes from an environment variable, so it never ends up hardcoded in a public notebook.
import os
import requests
response = requests.get(
"https://eodhd.com/api/eod/AAPL.US",
params={
"api_token": os.environ.get("EODHD_API_KEY", "demo"),
"from": "2025-06-01",
"to": "2026-09-22",
"fmt": "json",
"order": "a",
},
timeout=20,
)
response.raise_for_status()
rows = response.json()
if not isinstance(rows, list) or not rows:
raise ValueError("No valid EODHD price history returned")
print(rows[-1]["date"], rows[-1]["adjusted_close"])
This preview is handy for checking the response shape. The complete project is more defensive. It validates every price, detects duplicate dates, requests 460 calendar days of lookback, and keeps future observations out of anything sent to Jev.
For each candidate, Python calculates:
(latest adjusted close / adjusted close 60 sessions earlier) - 1(latest adjusted close / mean of last 200 adjusted closes) - 1sqrt(252)Every number uses strictly historical rows.
This part is boring and it matters more than anything else in the article. One future price leaking into a feature is enough to make a backtest look brilliant. Adjusted-price series need extra care too, because dividend adjustments can restate past price levels after the fact.
I donāt ask Jev to predict tomorrowās price. I donāt ask whether I should invest my savings.
I hand it the eligible candidates with their precomputed indicators and ask it to choose one option for further paper-portfolio evaluation, with CASH explicitly on the table.
The request shape:
payload = {
"model": "jev-latest",
"state": {
"task": "Choose a 20% tactical sleeve for a hypothetical 20-session paper portfolio.",
"constraints": "Long-only; 80% VTI core; eligible assets or CASH only.",
"eligible_instruments": {"AAPL.US": {
"momentum_60d_pct": 4.2,
"distance_sma200_pct": 3.1,
"volatility_20d_annual_pct": 27.5,
}},
},
"questions": {
"tactical_choice": {
"type": "choice",
"instructions": "Which eligible option is most suitable for further paper-portfolio evaluation? Prefer CASH if unclear. Do not predict returns.",
"criteria": {
"AAPL.US": "Choose AAPL for the hypothetical tactical sleeve",
"CASH": "Abstain from an additional risky position",
},
},
},
}
The numbers in that snippet are placeholders, not observed AAPL data and not a Jev response. The runnable project builds the state from real EODHD price records and sends it to https://api.typesafe.ai/v1/systemone with a bearer token. The response is validated against the exact allowed choices. An invalid result stops the workflow. An uncertain valid result becomes CASH. (TypeSafe quick start)
Look at what the model cannot do here. It cannot invent a ticker outside the list. It cannot turn a 20% sleeve into a leveraged bet. It cannot send an order to a broker, because there is no broker integration in this demo.
The intelligence is boxed in by design.
I record the decision at the historical as-of close, assume entry at the next common sessionās adjusted close, and measure the result 20 common sessions later. A signal produced after the close canāt be filled at that same close, so I donāt pretend it can.
The calculation:
Portfolio gross return = 0.80 Ć VTI return + 0.20 Ć tactical return
Tactical return = chosen stock's return, or 0 if CASH
Portfolio net return = gross return ā illustrative round-trip fees
Benchmark net return = 100% VTI return ā illustrative round-trip fees
I use an illustrative 10 basis points per invested sleeve on entry and on exit. The program reports hypothetical ending dollar amounts for both the $10,000 portfolio and the VTI benchmark. It does not model real fills, bid-ask spreads, slippage, currency conversion, cash interest, taxes or the exact timing of dividend payments.
If the 20-session window hasnāt finished, the script prints PENDING. Pending is not a win. It's not a loss either.
Now the honest part.
There are no live Jev decisions or verified performance results in this article. The code passes local offline tests, but I havenāt submitted an authenticated Jev request or completed a live EODHD-to-Jev run. And a July 2026 āretrospectiveā with a model released in September would prove very little: even with perfectly time-limited price features, the modelās training could carry knowledge of what happened next. The credible test starts with a decision timestamp after the model became available, and reports the outcome only once the holding period actually ends.
Save jev_portfolio.py and test_jev_portfolio.py from the companion code package and run this in PowerShell:
py -m pip install requests pytest
$env:EODHD_API_KEY = "demo" # Replace if your account requires a private token.
$env:TYPESAFE_API_KEY = "YOUR_TYPESAFE_KEY"
py -m pytest -q
py jev_portfolio.py --as-of 2026-09-22
Pick a date with at least 201 common prior trading sessions. September 22, 2026 is a post-launch illustrative date, so its 20-session outcome stays PENDING until enough future data exists. API access and provider entitlements may vary. For a historical dry run, change the date, but don't call the result forward-tested performance.
The output shows the eligible symbols, their input indicators, Jevās selection, its confidence, and either a pending status or a hypothetical comparison against VTI.
You get the full decision trail. Not a black-box profit screenshot.
The interesting part is not an AI picking a stock.
Itās a system where every decision can be traced: which market observations the model received, which constraints the code imposed, and which future prices were held back for evaluation.
Thatās also where the EODHD API earns its place. Without a consistent historical feed, the AI only has stories about the market. With reproducible data, you can rerun the same experiment with different dates, rules or models, and anyone can challenge the assumptions.
One 20-session outcome would still be an anecdote. Before claiming any edge, youād need a forward-collected series of decisions and a predefined comparison against simpler rules, after realistic costs.
A confident model output is a structured judgment. It is not a probability of positive returns.
No predictive accuracy has been established by this example. Jev chooses between pre-approved options based on the indicators itās given. Forward evaluation would be needed before any forecasting claim is justified.
Not here. Python computes the indicators, applies the deterministic limits and calculates the paper returns. Jev receives a compact structured snapshot and returns a bounded choice.
EODHD publishes a demo token for selected tickers and offers a limited free tier, subject to current access restrictions. The official Quick Start lists eligible instruments, quotas and plans.
adjusted_close instead of close?EODHDās adjusted closes account for splits and dividends, which makes them useful for an approximate total-return comparison. They are not the literal prices a trader could have bought or sold at, and future corporate actions can restate historical adjusted levels. (EODHD historical-price documentation)
The 80/20 structure keeps the moving parts to a minimum and isolates Jevās single tactical choice. Itās an illustrative allocation, not a recommendation for a real investor.
No. The script has no broker connection and places no orders. Real execution would need compliance checks, position sizing, exchange calendars, risk controls, broker integration and extensive forward validation. This demo was not designed or validated for live trading.
It summarizes the modelās certainty across the available choices. It does not mean an 80% chance the stock rises, or an 80% chance of beating VTI. (TypeSafe confidence documentation)
Most AI investing demos donāt fail because of the model.
They fail because nobody can check what the model was looking at.
Start with a reproducible market-data feed
End-of-day prices, adjusted closes and more datasets for your own Python experiments. Use code KEVIN10 at checkout for 10% off.
ā Get 10% off EODHDWant more experiments like this one?
Python, APIs and AI tools applied to real financial data, with the code included.
ā Visit kevinmeneses.com
Better AI answers wonāt fix a weak investment process.
Better structure will.
This article is educational and contains affiliate links. It is not investment advice. All investments involve risk, including loss of principal. No return is promised.
Looking for technical content for your company? I can help ā LinkedIn Ā· kevinmenesesgonzalez@gmail.com