What you need before you start.
Project Setup
pip install requests schedule python-dotenv Create a .env file:
TICKATLAS_API_KEY=your_api_key_here Create the API Client
import os
import requests
from dotenv import load_dotenv
load_dotenv()
class TickAtlasClient:
def __init__(self):
self.base_url = "https://tickatlas.com/v1"
self.headers = {"X-API-Key": os.getenv("TICKATLAS_API_KEY")}
def get_indicator(self, symbol, indicator, timeframe):
"""Get a single indicator value."""
params = {"symbol": symbol, "indicator": indicator, "timeframe": timeframe}
response = requests.get(
f"{self.base_url}/indicator",
headers=self.headers,
params=params
)
response.raise_for_status()
return response.json()
def get_summary(self, symbol, timeframe):
"""Get the rule-based market analysis."""
params = {"symbol": symbol, "timeframe": timeframe}
response = requests.get(
f"{self.base_url}/summary",
headers=self.headers,
params=params
)
response.raise_for_status()
return response.json()
def get_multi(self, symbols, indicators, timeframe):
"""Get multiple indicators for multiple symbols."""
params = {
"symbols": ",".join(symbols),
"indicators": ",".join(indicators),
"timeframe": timeframe
}
response = requests.get(
f"{self.base_url}/multi",
headers=self.headers,
params=params
)
response.raise_for_status()
return response.json() Define Your Strategy
We'll implement a simple RSI + MACD confluence strategy:
class TradingStrategy:
def __init__(self, client):
self.client = client
def analyze(self, symbol, timeframe="H1"):
"""Analyze a symbol and return a trading signal."""
rsi = self.client.get_indicator(symbol, "RSI_14", timeframe)
macd = self.client.get_indicator(symbol, "MACD_hist", timeframe)
atr = self.client.get_indicator(symbol, "ATR_14", timeframe)
# Every success response is {"success": true, "data": {...}}.
rsi_value = rsi["data"]["value"]
macd_value = macd["data"]["value"]
atr_value = atr["data"]["value"]
signal = "HOLD"
if rsi_value < 35 and macd_value > 0:
signal = "BUY"
elif rsi_value > 65 and macd_value < 0:
signal = "SELL"
return {
"symbol": symbol,
"signal": signal,
"rsi": rsi_value,
"macd_hist": macd_value,
"atr": atr_value,
"stop_loss": atr_value * 2,
"take_profit": atr_value * 3,
} Create the Bot Loop
import schedule
import time
import logging
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(message)s")
def run_bot():
client = TickAtlasClient()
strategy = TradingStrategy(client)
symbols = ["EURUSD", "GBPUSD", "USDJPY", "XAUUSD"]
for symbol in symbols:
try:
result = strategy.analyze(symbol)
if result["signal"] != "HOLD":
logging.info(
f"📊 {result['signal']} {symbol} | "
f"RSI: {result['rsi']:.1f} | "
f"MACD: {result['macd_hist']:.5f} | "
f"SL: {result['stop_loss']:.5f} | "
f"TP: {result['take_profit']:.5f}"
)
# Here you would execute the trade via your broker API
else:
logging.debug(f"No signal for {symbol}")
except Exception as e:
logging.error(f"Error analyzing {symbol}: {e}")
# Run every hour at the top of the hour
schedule.every().hour.at(":01").do(run_bot)
logging.info("🤖 Trading bot started. Checking every hour...")
run_bot() # Run immediately on start
while True:
schedule.run_pending()
time.sleep(30) Confirm with the Market Summary
Use the /v1/summary endpoint for a rule-based confirmation:
def analyze_with_summary(self, symbol, timeframe="H1"):
"""Enhanced analysis using the rule-based market summary."""
basic = self.analyze(symbol, timeframe)
if basic["signal"] != "HOLD":
summary = self.client.get_summary(symbol, timeframe)["data"]
bias = summary["bias"] # "bullish", "bearish" or "neutral"
confidence = summary.get("confidence", 0) # 0-1 fraction, e.g. 0.78
# Only trade when the summary's bias agrees with your own signal
if basic["signal"] == "BUY" and bias == "bullish" and confidence > 0.6:
basic["confirmed"] = True
basic["summary_confidence"] = confidence
elif basic["signal"] == "SELL" and bias == "bearish" and confidence > 0.6:
basic["confirmed"] = True
basic["summary_confidence"] = confidence
else:
basic["confirmed"] = False
basic["signal"] = "HOLD" # Override - the summary disagrees
return basic Production hardening
The code above is the happy path. These are the concerns that decide whether it survives contact with a real deployment.
Next Steps
Everything this guide touches, linked directly — so it never dead-ends.