Market Analysis Agent
LangChain agent that queries all API endpoints and generates natural-language market reports. Framework: LangChain + Python.
Live Output Preview
If you ran this bot right now, the API would return:
# Live API output — March 12, 2026 Market Regime: Mean-Reverting Safety Score: 95.6 (HIGH) Composite Signals: BTC: neutral (score: 0.028)\n ETH: buy (score: 0.236)\n SOL: buy (score: 0.183)\n HYPE: strong_buy (score: 0.319)\n # The bot would use this data to make trading decisions
Complete Source Code
Copy this code, replace YOUR_API_KEY with your key, and run:
from langchain.agents import AgentExecutor, create_openai_functions_agent
from langchain.tools import tool
from langchain_openai import ChatOpenAI
import requests
API_KEY = "YOUR_API_KEY"
BASE = "https://algotick.dev"
@tool
def get_market_regime() -> str:
"""Get current market regime classification for all coins."""
resp = requests.get(f"{{BASE}}/v3/signals/regime", params={{"api_key": API_KEY}})
data = resp.json()
return "\n".join(
f"{{r['coin']}}: {{r['regime_label']}} (confidence: {{r['confidence_score']}})"
for r in data.get("regimes", [])
)
@tool
def get_composite_signal(coin: str) -> str:
"""Get composite trading signal for a specific coin (BTC, ETH, SOL, HYPE)."""
resp = requests.get(f"{{BASE}}/v1/signals/composite", params={{"api_key": API_KEY}})
data = resp.json()
sig = next((s for s in data.get("signals", []) if s.get("coin") == coin), None)
if not sig:
return f"No signal for {{coin}}"
components = sig.get("components", {{}})
parts = [f"{{k}}: value={{v.get('value', 0):.4f}}, score={{v.get('score', 0):.3f}}"
for k, v in components.items() if isinstance(v, dict)]
return (f"{{coin}} Composite: {{sig['regime']}} (score: {{sig['composite_score']:.3f}})\n"
f"Components: {{', '.join(parts)}}")
@tool
def get_whale_activity(coin: str) -> str:
"""Get whale order flow for a specific coin."""
resp = requests.get(f"{{BASE}}/v1/signals/whale-flow",
params={{"coin": coin, "api_key": API_KEY}})
data = resp.json()
return (f"{{coin}} Whale Imbalance: {{data.get('whale_imbalance', 0):.3f}}\n"
f"Bid: ${{data.get('total_whale_bid_usd', 0):,.0f}} | "
f"Ask: ${{data.get('total_whale_ask_usd', 0):,.0f}}")
tools = [get_market_regime, get_composite_signal, get_whale_activity]
llm = ChatOpenAI(model="gpt-4o", temperature=0)
# Create the agent
agent = create_openai_functions_agent(llm, tools, prompt=...)
executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
# Run analysis
result = executor.invoke({{"input": "Analyze the current crypto market. "
"Check all regimes, then get composite signals for BTC and ETH. "
"Also check whale activity. Give me a trading recommendation."}})
print(result["output"])
Setup Instructions
- Get an API key from the API page
- Replace
YOUR_API_KEYin the code above - Install dependencies:
pip install requests(Python) ornpm install node-fetch(TypeScript) - Run the script and monitor the output
- Connect your exchange API for live trading
API Endpoints Used
Framework
LangChain + Python
Data Source
Algo Tick API
# All endpoints used by this template:
curl -H "X-API-Key: YOUR_KEY" https://algotick.dev/v3/signals/regime
curl -H "X-API-Key: YOUR_KEY" https://algotick.dev/v1/signals/composite
curl -H "X-API-Key: YOUR_KEY" https://algotick.dev/v3/signals/safety
curl -H "X-API-Key: YOUR_KEY" https://algotick.dev/v1/signals/volatility?coin=BTCDon't just stare at the dashboard. Automate it.
Every metric on this page is available via our sub-millisecond API.
Build trading bots, backtest strategies, and power AI agents with institutional-grade data.