trademagic guides
How to build a trading bot
Every working trading bot is three components: a signal source worth trusting, a consumer that turns signals into orders, and risk rules that keep you alive. Here is how to build one properly.
Start with a free trial. No credit card required.

1. Start with the signal source, not the code
Most bot projects die at the first component. Scraping Telegram groups gives you unverifiable calls with no stops. Indicator mashups backtest beautifully and then bleed live. Before writing a line of code, demand four things from any signal source: a timestamped feed, a defined stop and target on every signal, quantified confidence and risk to reward, and an auditable outcome history.
That checklist is what trademagic's certified FX models were built to satisfy. Each model is a specialist trained on real tape-driven flow, macro surprise, positioning, and carry drawn from more than 900 data feeds, then tested and certified before its first live signal. Every signal arrives with entry, stop, target, confidence, and risk to reward, and resolves to an outcome you can audit.
2. Consume the feed with a cursor, not a scraper
The FX Insights API has two read endpoints: a snapshot of every fresh signal, and an incremental updates feed that returns only what changed since your last poll. A bot should use the updates feed: bootstrap once, persist the cursor, then poll every 30 to 60 seconds. New signals, TP and SL hits, expiries, and edits all arrive as ordered events.
import time
import requests
API = "https://trademagic.ai/api/ext/v1"
HEADERS = {"Authorization": "Bearer tp_live_YOUR_KEY"}
def handle_signal(sig):
# Your risk rules live here: sizing from the SL distance, exposure
# caps, session filters, then an order to YOUR broker's API.
print(sig["pair"], sig["side"], sig["entry"], sig["sl"], sig["tp"], sig["rr"])
cursor = None
while True:
params = {"after": cursor} if cursor else {}
r = requests.get(f"{API}/signals/updates", headers=HEADERS,
params=params, timeout=10)
r.raise_for_status()
data = r.json()
for sig in data["signals"]: # first call: the open set
handle_signal(sig)
for event in data["events"]: # later calls: what changed
if event["type"] == "created":
handle_signal(event["signal"])
cursor = data["next_cursor"]
time.sleep(0 if data["has_more"] else 30)3. Keep execution and risk in your hands
trademagic never executes trades and never touches your funds. Your bot maps each signal to an order at your broker, and that mapping is where your edge management lives:
- Sizing: derive position size from the distance between entry and stop so every trade risks the same fraction of the account.
- Exposure caps: a maximum number of open positions and a per-pair cap.
- Systematic execution: take every signal the models publish. The certified statistics assume systematic execution; cherry-picking diverges from them.
4. Paper trade the live feed before risking capital
Run the bot against a demo account for at least a couple of weeks. You are testing your plumbing, not the models: order mapping, sizing math, reconnects, and duplicate handling. The free trial exists precisely so you can do this against the live feed before paying anything.
Start with a free trial
Create an account and your API key is minutes away.
Frequently asked questions
Do I need to be a strong programmer to build a trading bot?
No. A signal-consuming bot is a polling loop, a little JSON parsing, and calls to your broker's API. Tools like ChatGPT or Claude can scaffold the whole consumer in an afternoon; your judgment goes into the risk rules, not the plumbing.
Which language should I use?
Whichever you already know. The signals API is plain HTTPS and JSON, so Python, JavaScript, MQL5, Go, and even no-code tools like n8n all work equally well.
Where do the signals come from?
From trademagic's certified, specialist FX models: quantitative models built on more than 900 data feeds covering real tape-driven flow, macro, positioning, and carry, with no technical indicators anywhere in the stack.
Can the bot run unattended?
Yes, that is the point. Run it on a small VPS or a spare machine, poll every 30 to 60 seconds, and let your risk rules do the deciding. Signals play out over hours, so you do not need low-latency infrastructure.
Start with a free trial
Create an account and your API key is minutes away.