Quick Start
The xgbCrypto API provides cryptocurrency trading signals powered by XGBoost models. With a simple REST API call, you can retrieve real-time signals for 20 major coins across three timeframes.
1. Sign Up and Get Your API Key
Log in with your Google account and generate an API Key from the Dashboard.
2. Make a Request
Call the signals endpoint using your API Key:
curl -H "X-API-Key: YOUR_API_KEY" \
https://xgbcrypto.com/api/signals/latest/?symbol=BTCUSDT3. Interpret the Signal
The net_signal value in the response ranges from -1 to +1:
- > 0.2 → Strong Bullish
- 0 ~ 0.2 → Bullish
- ≈ 0 → Neutral
- -0.2 ~ 0 → Bearish
- < -0.2 → Strong Bearish
Signal Definitions
xgbCrypto provides three pre-configured signal timeframes, each designed for a different trading style. Every signal is generated by an XGBoost model trained on historical candlestick data using the Triple Barrier Method — the model predicts whether the price is more likely to hit take-profit or stop-loss first within a given time window.
Each signal outputs a net_signal value from -1 to +1. This is calculated as P(profit) - P(loss), where the model uses a Triple Barrier labeling approach: if the price hits the take-profit threshold first → profit; if it hits stop-loss first → loss; if neither is hit within the forward window → neutral.
Short-Term Signal (High Frequency)
| Data Source | 1-minute candlestick data from Binance |
| Update Frequency | Every 1 minute |
| Lookback Window | 60 candles (1 hour of price history) |
| Prediction Window | Next 30 minutes — will the price move ±0.5%? |
| Take-Profit / Stop-Loss | ±0.5% (take-profit and stop-loss) |
| Best For | Scalpers and day traders. Captures minute-level momentum shifts. Typical holding period: minutes to hours. |
Mid-Term Signal (Swing)
| Data Source | 1-hour candlestick data from Binance |
| Update Frequency | Every 1 hour |
| Lookback Window | 24 candles (1 day of price history) |
| Prediction Window | Next 12 hours — will the price move ±1%? |
| Take-Profit / Stop-Loss | ±1% (take-profit and stop-loss) |
| Best For | Swing traders. Focuses on hourly trend shifts. Typical holding period: hours to days. |
Long-Term Signal (Trend)
| Data Source | 6-hour candlestick data from Binance |
| Update Frequency | Every 6 hours |
| Lookback Window | 28 candles (7 days of price history) |
| Prediction Window | Next 2 days — will the price move ±2%? |
| Take-Profit / Stop-Loss | ±2% (take-profit and stop-loss) |
| Best For | Trend followers and position traders. Captures medium-to-long-term market direction. Typical holding period: days to weeks. |
Understanding net_signal
The net_signal value is the core output of every signal. It equals P(profit) - P(loss), ranging from -1 to +1. A positive value means the model believes the price is more likely to hit the take-profit target before the stop-loss, and vice versa.
net_signal = P(profit) - P(loss)- > 0.2 → Strong Bullish
- 0 ~ 0.2 → Bullish
- ≈ 0 → Neutral
- -0.2 ~ 0 → Bearish
- < -0.2 → Strong Bearish
Timestamps & Time Zones
All signal timestamps are in UTC, following the industry standard used by Binance, CoinGecko, and other major platforms. Your frontend application can convert UTC to the user's local timezone using standard JavaScript Date methods.
Enterprise plan users can request custom signal configurations — including custom timeframes, barrier thresholds, and lookback windows tailored to your trading strategy. Contact us for details.
Authentication
All signal endpoints require API Key authentication. Include the following header in your requests:
X-API-Key: your_api_keyGet Latest Signals
/api/signals/latest/Returns the latest signals for a given coin across all three timeframes.
Parameters
symbol (optional) — Coin pair, e.g. BTCUSDT. Omit to return all.
import requests
resp = requests.get(
"https://xgbcrypto.com/api/signals/latest/",
headers={"X-API-Key": "YOUR_API_KEY"},
params={"symbol": "BTCUSDT"}
)
data = resp.json()
print(data)const resp = await fetch(
"https://xgbcrypto.com/api/signals/latest/?symbol=BTCUSDT",
{ headers: { "X-API-Key": "YOUR_API_KEY" } }
);
const data = await resp.json();
console.log(data);Example Response
{
"data": [
{
"symbol": "BTCUSDT",
"signals": {
"long": {
"time": "2025-02-17T12:00:00",
"prob_win": 0.53,
"prob_loss": 0.47,
"net_signal": 0.06
},
"mid": { ... },
"short": { ... }
}
}
]
}Get Historical Signals
/api/signals/history/Returns historical signal data for a given coin and timeframe.
Parameters
- symbol (required) — Coin pair
- freq (optional) — Timeframe: 1m / 1h / 6h, default 1h
- limit (optional) — Number of records, default 100
resp = requests.get(
"https://xgbcrypto.com/api/signals/history/",
headers={"X-API-Key": "YOUR_API_KEY"},
params={"symbol": "ETHUSDT", "freq": "mid", "limit": 50}
)
print(resp.json())Strategy Example
Here is a simple Python strategy example showing how to use xgbCrypto signals for trading decisions:
import requests
import numpy as np
API_KEY = "YOUR_API_KEY"
SYMBOL = "BTCUSDT"
BASE_URL = "https://xgbcrypto.com"
# 1. 获取 xgbCrypto 信号
signal_resp = requests.get(
f"{'{'}BASE_URL{'}'}/api/signals/latest/",
headers={"X-API-Key": API_KEY},
params={"symbol": SYMBOL}
)
signal_data = signal_resp.json()["data"][0]["signals"]["mid"]
net_signal = signal_data["net_signal"]
prob_win = signal_data["prob_win"]
# 2. 获取 Binance K 线(最近 30 根 1h K 线)
klines = requests.get(
f"https://api.binance.com/api/v3/klines",
params={"symbol": SYMBOL, "interval": "1h", "limit": 30}
).json()
closes = np.array([float(k[4]) for k in klines])
current_price = closes[-1]
# 3. 计算 EMA-20
ema_20 = closes[-20:].mean() # 简化 SMA 近似
# 4. 计算布林带
bb_mid = closes[-20:].mean()
bb_std = closes[-20:].std()
bb_upper = bb_mid + 2 * bb_std
bb_lower = bb_mid - 2 * bb_std
# 5. 综合决策
score = 0
reasons = []
if net_signal > 0.05:
score += 1
reasons.append(f"信号看涨 (net={'{'}net_signal:.3f{'}'})")
elif net_signal < -0.05:
score -= 1
reasons.append(f"信号看跌 (net={'{'}net_signal:.3f{'}'})")
if current_price > ema_20:
score += 1
reasons.append("价格在 EMA20 上方")
else:
score -= 1
reasons.append("价格在 EMA20 下方")
if current_price <= bb_lower:
score += 1
reasons.append("触及布林带下轨(超卖)")
elif current_price >= bb_upper:
score -= 1
reasons.append("触及布林带上轨(超买)")
# 输出
if score >= 2:
decision = "BUY"
elif score <= -2:
decision = "SELL"
else:
decision = "HOLD"
print(f"币种: {'{'}SYMBOL{'}'}")
print(f"当前价格: {current_price:,.2f{'}'}")
print(f"决策: {'{'}decision{'}'} (综合得分: {'{'}score{'}'})")
print(f"依据: {'{'}'; '.join(reasons){'}'}")Error Codes
| Code | Description |
|---|---|
401 | 401 — Unauthorized or invalid API Key |
403 | 403 — Rate limit exceeded or trial quota exhausted |
429 | 429 — Too many requests, please try again later |
500 | 500 — Internal server error |
Plans & Limits
| Plan | Timeframes | Coins | Rate Limit |
|---|---|---|---|
| Free | 6h, 1h | BTCUSDT only | 1/hour |
| Basic | 6h, 1h, 1m | All 20 | 1,000/hour |
| Pro | 6h, 1h, 1m | All 20 | 3,000/hour |
| Premium | 6h, 1h, 1m | All 20 | 20,000/hour |
| Enterprise | All | All + Custom | Unlimited |
Live Test
Enter your API Key to test the signals endpoint right now.
GET /api/signals/latest/?symbol=BTCUSDT