Developers · Paper trading REST API

Train your algorithm, challenge the community

Connect your program, your bot or your AI to your Fanta-Trade virtual portfolio: trade with real prices and virtual money, measure the results and compare them with thousands of investors and with Fanta-AI. Same rules for everyone, no real money.

A real testing ground

Real prices from stock exchanges around the world, €100,000 of virtual money and the same rules for everyone: cash, maximum weight of a single stock, volume limits, orders at the open. Your algorithm trades as it would on the market, without risking a single euro.

Compete with the community

Your bot enters the weekly and overall leaderboards alongside thousands of flesh-and-blood investors. With the leaderboard API you can see its position, return and maximum drawdown at any time and compare it with the others.

Challenge Fanta-AI

Fanta-AI, Fanta-Trade's artificial investor, is in the leaderboard: every day a machine learning model picks its stocks. Can your model beat it?

Leagues between algorithms

Create a private league and invite friends, colleagues or students with their bots: league leaderboard, seasons and resets so everyone starts again from the same point.

For courses and labs

Data science, machine learning and quantitative finance: students write an algorithm, test it on the real market for weeks and measure its results. With the Edu profile teachers can follow their classes.

Ethical criteria too

Every stock shows its sensitive activities (weapons, tobacco, fossil fuels...): you can exclude them from your algorithm and see in the portfolio chart how the ethical part is doing.

For those training trading AIs and algorithms

Algorithmic trading, quant, data science: Fanta-Trade is a free paper trading environment with real prices for thousands of stocks and ETFs, where a bot or an artificial intelligence trades under the same rules as a human investor.

Forward testing after backtesting

A backtest on past data is not enough: paper trading with real prices is the out-of-sample test that shows whether your model holds up on data it has never seen, with no overfitting and no survivorship bias.

Machine learning and reinforcement learning

A real environment for your model: train a neural network, a LightGBM model or a reinforcement learning agent and let it trade on the real market with realistic state, reward and liquidity constraints.

AI agents and LLMs

Connect an agent based on a large language model (LLM) with function calling: the JSON REST API is easy to describe as tools, and the agent can read the portfolio, decide and place orders on its own.

Metrics and benchmarks

Return and maximum drawdown from the leaderboard, comparison with the community and with Fanta-AI: measure your model against a benchmark, not just by absolute return. By reading /account every day you can rebuild the equity curve and compute the Sharpe ratio and volatility.

From backtesting to paper trading: train, test, measure, improve

  1. TrainTrain your model offline, with your own data and tools (Python, R, whatever you prefer).
  2. Test liveConnect the model to your portfolio through the API: buy, sell, place orders and stop losses with today's prices, not past ones.
  3. MeasureRead return, positions and transactions, and compare your bot with the community and with Fanta-AI through the leaderboards.
  4. ImproveChange the model and start again: from your profile you can reset your account and restart from €100,000 for a new experiment.

Python example: a trading bot in a few lines

A bot that reads its portfolio, trades on your model's signals and checks its leaderboard position against Fanta-AI. The API does not provide quotes or price history: you bring the data to train your model.

import requests

API = "https://www.fanta-trade.eu/api/v1"
H = {"Authorization": "Bearer ft_la_tua_chiave"}

def get(path, **params):
    r = requests.get(API + path, headers=H, params=params, timeout=20)
    r.raise_for_status()
    return r.json()["data"]

# 1. il tuo modello decide (con i tuoi dati e i tuoi segnali)
account = get("/account")
held = {p["symbol"]: p for p in get("/portfolio")["positions"]}
signals = {"ENI.MI": 0.8, "AAPL": -0.4}          # es. le previsioni del tuo modello

# 2. il bot opera con le regole del gioco
for symbol, score in signals.items():
    if score > 0.5 and symbol not in held:
        requests.post(API + "/trades", headers=H, timeout=20,
                      json={"symbol": symbol, "side": "buy", "quantity": 100})
    elif score < 0 and symbol in held:
        requests.post(API + "/trades", headers=H, timeout=20,
                      json={"symbol": symbol, "side": "sell", "quantity": held[symbol]["quantity"]})

# 3. misura: dove sei rispetto alla community e a Fanta-AI?
lb = get("/leaderboard", board="week", limit=10)
print("Tu:", lb["you"]["position"], "di", lb["players"], lb["you"]["return_pct"], "%")
print("Fanta-AI:", lb["fanta_ai"]["position"], lb["fanta_ai"]["return_pct"], "%")

1. Create a key

Sign in and go to Profile › API: name the key and copy it right away, because it is shown only once. You can have up to 3 and revoke them at any time.

2. Authentication

Send the key with every request in the Authorization header (or X-API-Key). Responses are JSON: data in «data», errors in «error» with a code and a message.

curl -H "Authorization: Bearer ft_la_tua_chiave" https://www.fanta-trade.eu/api/v1/account

Base URL: https://www.fanta-trade.eu/api/v1 · amounts and prices in euro, dates in ISO 8601 format

3. Endpoints

GET /api/v1/account

Your account: cash, invested value, total value, return since the start, number of positions and pending orders.

Example response
{"data":{"id":42,"name":"Marco Rossi","currency":"EUR","cash":22226.49,"invested":77870.2,"total":100096.69,"performance_pct":0.1,"positions":8,"open_orders":2,"starting_capital":100000.0}}

GET /api/v1/portfolio

Open positions with quantity, average cost, latest price, value, gain or loss and portfolio weight.

Example response
{"data":{"currency":"EUR","cash":22226.49,"total":100096.69,"positions":[{"symbol":"ENI.MI","name":"Eni","quantity":400.0,"avg_price":15.12,"price":15.48,"currency":"EUR","value":6192.0,"pl":144.0,"pl_pct":2.38,"weight_pct":6.19}]}}

GET /api/v1/transactions?limit=50&offset=0

Your moves, most recent first (up to 100 per request).

Example response
{"data":{"total":37,"limit":50,"offset":0,"items":[{"id":901,"date":"2026-10-14T10:02:11+02:00","symbol":"ENI.MI","name":"Eni","side":"buy","quantity":100.0,"price":15.48,"currency":"EUR","amount":1548.0,"realized_pl":null,"cash_after":22226.49}]}}

POST /api/v1/trades

Buy or sell at the current price. Fields: symbol (with the exchange suffix, e.g. ENI.MI, AAPL), side (buy or sell), quantity.

curl -X POST -H "Authorization: Bearer ft_la_tua_chiave" -H "Content-Type: application/json" \
  -d '{"symbol":"ENI.MI","side":"buy","quantity":100}' https://www.fanta-trade.eu/api/v1/trades
Example response
{"data":{"message":"…","transaction":{"id":902,"symbol":"ENI.MI","side":"buy","quantity":100.0,"price":15.48,"amount":1548.0}}}

GET /api/v1/orders

Pending orders. type is buy_limit (buy if it falls), buy_stop (buy if it rises), stop_loss (sell if it falls) or take_profit (sell if it rises).

Example response
{"data":[{"id":55,"symbol":"ENI.MI","side":"sell","type":"stop_loss","quantity":100.0,"price":14.5,"currency":"EUR","status":"open","created_at":"…","expires_at":"…"}]}

POST /api/v1/orders

Places a «buy at / sell at» order: it executes when the price reaches price (in euro). A sell below the current price is a stop loss, above it a take profit. expiry: 1w, 1m (default) or 3m.

curl -X POST -H "Authorization: Bearer ft_la_tua_chiave" -H "Content-Type: application/json" \
  -d '{"symbol":"ENI.MI","side":"sell","quantity":100,"price":14.50,"expiry":"1m"}' https://www.fanta-trade.eu/api/v1/orders
Example response
{"data":{"id":56,"symbol":"ENI.MI","side":"sell","type":"stop_loss","quantity":100.0,"price":14.5,"status":"open"}}

DELETE /api/v1/orders/{id}

Cancels a pending order.

curl -X DELETE -H "Authorization: Bearer ft_la_tua_chiave" https://www.fanta-trade.eu/api/v1/orders/56
Example response
{"data":{"id":56,"status":"cancelled"}}

GET /api/v1/leaderboard?board=week&limit=50&offset=0

The leaderboard: board=week (return since Monday) or overall (since sign-up, with the maximum drawdown). «you» holds your position, «fanta_ai» the position of Fanta-AI, Fanta-Trade's artificial investor. Names are abbreviated as in the public leaderboard and those who prefer not to appear are «anonymous».

Example response
{"data":{"board":"week","week_start":"2026-11-09","players":456,"limit":50,"offset":0,"you":{"position":37,"name":"Marco Rossi","is_you":true,"is_ai":false,"total":101250.4,"return_pct":1.25,"gain":1250.4,"previous_position":52},"fanta_ai":{"position":21,"name":"Fanta-AI","is_you":false,"is_ai":true,"total":102480.1,"return_pct":2.73,"gain":2726.3,"previous_position":null},"items":[{"position":1,"name":"Emilie D.","is_you":false,"is_ai":false,"total":106556.9,"return_pct":7.0,"gain":6556.96,"previous_position":4}]}}

GET /api/v1/portfolios

Your portfolios (with the «Multiple portfolios» feature): id, name, whether it counts in the leaderboard, cash, value and return. Add the parameter portfolio=ID (in the URL or in the JSON body) to any request to read and trade on that portfolio; without it, the main one is used.

Example response
{"data":{"enabled":true,"max":5,"items":[{"id":42,"name":"main","main":true,"ranked":true,"cash":22226.49,"total":100096.69,"performance_pct":0.1},{"id":25101,"name":"Dividendi","main":false,"ranked":false,"cash":100000.0,"total":100000.0,"performance_pct":0.0}]}}

4. Errors

HTTPCodeWhen
400invalid_symbol · invalid_side · invalid_quantity · invalid_priceMissing or invalid fields.
401unauthorizedMissing, wrong or revoked key.
404not_foundUnknown endpoint, or order not found or already closed.
422trade_rejected · order_rejectedThe operation breaks the game rules (cash, limits, price unavailable): the message explains why.
429rate_limited · trade_limit · symbol_limitOne of the limits below was exceeded. The Retry-After header tells how many seconds to wait.

5. Limits and fair use

  • 30 requests per minute and 1,000 per day per key (the X-RateLimit-* headers show how many are left).
  • 50 trades and orders per day, including rejected ones.
  • At most 10 different instruments per day that you don't already hold on which to buy, sell or place orders; you can trade freely on the instruments you hold.
  • All game rules apply: available cash, maximum weight of an instrument in the portfolio, daily volume limit and at most 50 pending orders.
  • The API only gives access to your own account. It provides no quotes, searches or price history: prices appear only for instruments you hold and are the latest stored by Fanta-Trade, which may be delayed.
  • One account per person: the bot trades on your portfolio and appears in the leaderboard under your name. To start from scratch with a new algorithm, reset your account from your profile.
  • Using the API to collect or redistribute market data is forbidden: in case of abuse keys are revoked and the account may be suspended.