DEV Community

Market Masters
Market Masters

Posted on

Build a Python Trading Bot: Real-Time Crypto Prices and RSI Signals with Market Masters API

Build a Python Trading Bot: Real-Time Crypto Prices and RSI Signals with Market Masters API

Retail traders chase signals from noisy sources. What if you pulled institutional-grade data directly into your bot? Market Masters API gives live prices across 2500+ cryptos, S&P 500 stocks, ETFs, and futures. No middleman, no delays.

This tutorial builds a Python bot that:

  • Fetches real-time BTC/USDT and AAPL prices
  • Computes 14-period RSI
  • Sends Telegram alerts on oversold/overbought (RSI <30 or >70)

Time to build: 15 minutes. Cost: Free tier API key.

Prerequisites

pip install requests python-telegram-bot pandas ta
Enter fullscreen mode Exit fullscreen mode

Step 1: Get Your API Key

Sign up, grab your key from dashboard. Free tier: 100 calls/minute, perfect for bots.

Step 2: Fetch Live Prices

Market Masters /prices endpoint returns JSON with last price, volume, 24h change.

import requests
import os

API_KEY = os.getenv('MARKETMASTERS_API_KEY')
BASE_URL = 'https://api.marketmasters.ai/v1'

symbols = ['BTCUSDT', 'AAPL']

prices = requests.get(
    f'{BASE_URL}/prices',
    params={'symbols': ','.join(symbols)},
    headers={'Authorization': f'Bearer {API_KEY}'}
).json()
for p in prices['data']:
    print(f"{p['symbol']}: ${p['price']} (24h: {p['change24h']}%)" )
Enter fullscreen mode Exit fullscreen mode

Gotcha: Symbols must match exchange format (Binance for crypto, Yahoo for stocks). Check docs for full list.

Step 3: Compute RSI

Use ta library for battle-tested indicators. We need 14 closes, so track history.

import pandas as pd
from ta.momentum import RSIIndicator

closes = [45000, 45200, ...]
df = pd.DataFrame({'close': closes})
rsi = RSIIndicator(df['close'], window=14).rsi().iloc[-1]
print(f'RSI: {rsi:.1f}')
Enter fullscreen mode Exit fullscreen mode

Pro tip: Market Masters /ohlcv endpoint feeds this directly: period=1h&limit=20.

Step 4: Telegram Alerts

Simple bot loop checks every 5 minutes.

import asyncio
from telegram import Bot
import time

async def send_alert(bot, chat_id, message):
    await bot.send_message(chat_id=chat_id, text=message)

bot = Bot(token=os.getenv('TELEGRAM_TOKEN'))
CHAT_ID = 'YOUR_CHAT_ID'

while True:
    if rsi < 30:
        await send_alert(bot, CHAT_ID, 'BTC oversold: RSI 28. Buy signal?')
    elif rsi > 70:
        await send_alert(bot, CHAT_ID, 'BTC overbought: RSI 72. Trim?')
    time.sleep(300)
Enter fullscreen mode Exit fullscreen mode

Full Bot Script

Combine steps above. Handle rate limits with exponential backoff.

Tradeoffs:

  • Free tier limits history depth; premium unlocks 1y data.
  • Async for high-frequency? Use aiohttp over requests.
  • Backtest first: Paper trade on Market Masters ($10k sim capital).

Run It Live

Deploy on a $5 VPS. Add webhooks for Orion AI signals (45 tools in one call).

Ready to code? Start free at Market Masters. 30-day Premium trial, no card needed.

Questions? Drop a comment.

Top comments (0)