How to Build a ChatGPT Trading Assistant with Real Market Data
Connect ChatGPT to live forex and crypto market data using the TickAtlas API. Build an AI trading assistant that answers questions with real-time prices and indicators.
The Problem with ChatGPT and Markets
Out of the box, ChatGPT has no access to live market data. Ask it "What is EURUSD trading at right now?" and you will get a disclaimer about its training cutoff date. But with function calling (tool use), you can give ChatGPT real-time access to the TickAtlas API and turn it into a powerful trading research assistant.
The result: a conversational interface where you can ask "Is gold oversold right now?" and get an answer backed by live RSI data, not hallucinated numbers.
Architecture
User: "Is EURUSD oversold?"
|
v
ChatGPT (with function definitions)
|
v calls get_indicators("EURUSD", "H1", ["RSI_14"])
|
TickAtlas API --> returns RSI: 28.4
|
v
ChatGPT: "Yes, EURUSD is currently oversold with an RSI of 28.4
on the H1 timeframe. This typically indicates..."
Step 1: Define the Tools
OpenAI's function calling requires you to define tool schemas that describe what data the function accepts and returns:
tools = [
{
"type": "function",
"function": {
"name": "get_indicators",
"description": "Get technical indicator values for a forex or crypto pair",
"parameters": {
"type": "object",
"properties": {
"symbol": {
"type": "string",
"description": "Trading pair, e.g. EURUSD, XAUUSD, BTCUSD"
},
"timeframe": {
"type": "string",
"enum": ["M5", "M15", "H1", "H4", "D1"],
"description": "Candle timeframe"
},
"indicators": {
"type": "array",
"items": {"type": "string"},
"description": "Indicators to fetch, e.g. RSI_14, MACD, BBANDS_20"
}
},
"required": ["symbol", "timeframe", "indicators"]
}
}
},
{
"type": "function",
"function": {
"name": "get_quote",
"description": "Get the current price for a trading pair",
"parameters": {
"type": "object",
"properties": {
"symbol": {
"type": "string",
"description": "Trading pair, e.g. EURUSD, XAUUSD"
}
},
"required": ["symbol"]
}
}
}
] Step 2: Implement the Tool Functions
import requests
CLAW_API_KEY = "your_tickatlas_api_key"
CLAW_BASE = "https://tickatlas.com/v1"
CLAW_HEADERS = {"X-API-Key": CLAW_API_KEY}
def get_indicators(symbol: str, timeframe: str,
indicators: list[str]) -> str:
resp = requests.get(f"{CLAW_BASE}/indicators", params={
"symbol": symbol,
"timeframe": timeframe,
"indicators": ",".join(indicators)
}, headers=CLAW_HEADERS)
return resp.text # Return raw JSON string for the LLM
def get_quote(symbol: str) -> str:
resp = requests.get(f"{CLAW_BASE}/quotes", params={
"symbol": symbol
}, headers=CLAW_HEADERS)
return resp.text
# Map function names to implementations
TOOL_MAP = {
"get_indicators": get_indicators,
"get_quote": get_quote,
} Step 3: The Conversation Loop
from openai import OpenAI
import json
client = OpenAI()
SYSTEM_PROMPT = """You are a trading analyst assistant with access to
real-time market data via the TickAtlas API. When users ask about
market conditions, prices, or technical analysis, use the available
tools to fetch live data. Always cite the specific indicator values
in your analysis. Never make up numbers."""
def chat(user_message: str, history: list) -> str:
history.append({"role": "user", "content": user_message})
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "system", "content": SYSTEM_PROMPT}] + history,
tools=tools,
tool_choice="auto"
)
msg = response.choices[0].message
# Handle tool calls
while msg.tool_calls:
history.append(msg)
for call in msg.tool_calls:
fn = TOOL_MAP[call.function.name]
args = json.loads(call.function.arguments)
result = fn(**args)
history.append({
"role": "tool",
"tool_call_id": call.id,
"content": result
})
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "system", "content": SYSTEM_PROMPT}] + history,
tools=tools
)
msg = response.choices[0].message
history.append(msg)
return msg.content Example Conversations
User: "Is gold oversold right now?"
Assistant fetches RSI_14 for XAUUSD on H1, returns: "XAUUSD has an RSI of 24.3 on the H1 timeframe, which is firmly in oversold territory (below 30). The last time RSI was this low was 3 days ago, which preceded a $28 bounce."
User: "Compare EURUSD and GBPUSD momentum"
Assistant fetches MACD + RSI for both pairs, compares histogram values and RSI levels, and provides a side-by-side momentum analysis.
User: "What is the current spread on USDJPY?"
Assistant calls get_quote for USDJPY, calculates the bid-ask spread from the response, and explains whether it is normal for the current session.
Making It Better
Add Multi-Timeframe Analysis
Define a tool that fetches the same indicator across H1, H4, and D1 to give the LLM context about whether the signal aligns across timeframes.
Include Economic Calendar
Use the /v1/calendar endpoint to let ChatGPT warn about upcoming high-impact events.
Add Memory
Store previous analysis results so the assistant can track whether its earlier signals played out correctly.
Cost Considerations
Each conversation turn with tool calls uses approximately 1,000-2,000 tokens for the tool definitions plus the API response data. At GPT-4o pricing, a typical trading analysis conversation costs $0.01-0.03. The TickAtlas API usage depends on your plan tier.
Further Reading
Try this with live data
Every account gets $2.50 in free PAYG credits. No card required — paste your API key and run the code above against live broker data.
Keep reading
All articles- Tutorial 11 min read
24/7 Crypto Monitoring: Building Always-On Analysis Systems
Build a monitoring system that watches crypto markets around the clock, detects significant moves, and sends alerts when conditions match your criteria.
March 28, 2026
- Tutorial 12 min read
How to Build an AI Market Analyst That Runs 24/7
Build a production-ready AI market analyst that monitors forex and crypto markets around the clock, generates daily briefings, and alerts you to opportunities via Telegram.
March 28, 2026
- Tutorial 10 min read
Using ATR for Dynamic Stop-Loss Placement
Learn how to use Average True Range (ATR) to set volatility-adjusted stop losses that adapt to market conditions, with full code examples.
March 28, 2026