Overview
Syra provides comprehensive technical analysis tools including correlation analysis, OHLC (Open-High-Low-Close) data, and computed technical indicators to support trading decisions.
Correlation Analysis
Token Correlation
Analyze how different cryptocurrencies move together:
const response = await fetch(
'https://api.syraa.fun/v2/binance/correlation?symbol=BTCUSDT&limit=10',
{ headers: { 'Payment-Request': paymentHeader } }
);
const { symbol, top } = await response.json();
Response:
{
"symbol": "BTCUSDT",
"top": [
{ "symbol": "ETHUSDT", "correlation": 0.8542 },
{ "symbol": "BNBUSDT", "correlation": 0.7234 },
{ "symbol": "SOLUSDT", "correlation": 0.6891 },
{ "symbol": "ADAUSDT", "correlation": 0.6543 },
{ "symbol": "XRPUSDT", "correlation": 0.6234 }
]
}
Correlation Interpretation
| Correlation | Relationship | Trading Implication |
|---|
| 0.9 to 1.0 | Very Strong Positive | Assets move almost identically |
| 0.7 to 0.9 | Strong Positive | Assets tend to move together |
| 0.4 to 0.7 | Moderate Positive | Some correlation exists |
| 0.0 to 0.4 | Weak Positive | Little relationship |
| -0.4 to 0.0 | Weak Negative | Slight inverse movement |
| -0.7 to -0.4 | Moderate Negative | Often move opposite |
| -0.9 to -0.7 | Strong Negative | Strong inverse relationship |
| -1.0 to -0.9 | Very Strong Negative | Move in opposite directions |
Correlation Matrix
Get full correlation matrix for portfolio analysis:
const response = await fetch(
'https://api.syraa.fun/v2/binance/correlation-matrix',
{ headers: { 'Payment-Request': paymentHeader } }
);
const { interval, count, tokens, data } = await response.json();
Matrix Response:
{
"interval": "1m",
"count": 50,
"tokens": ["BTCUSDT", "ETHUSDT", "SOLUSDT", ...],
"data": {
"BTCUSDT": {
"BTCUSDT": 1.0000,
"ETHUSDT": 0.8542,
"SOLUSDT": 0.6891
},
"ETHUSDT": {
"BTCUSDT": 0.8542,
"ETHUSDT": 1.0000,
"SOLUSDT": 0.7234
}
}
}
Correlation is calculated using Pearson correlation on log returns of 1-minute OHLC data.
Tracked Tokens
The correlation system tracks 50+ major tokens:
- Layer 1s: BTC, ETH, SOL, ADA, AVAX, DOT, ATOM, etc.
- DeFi: UNI, AAVE, MKR, SNX, PENDLE, LDO, etc.
- Layer 2s: OP, ARB, MATIC, etc.
- AI Tokens: FET, RNDR, TIA, etc.
- Memes: DOGE, SHIB, PEPE, etc.
OHLC Data
Candlestick Data
Get historical candlestick data for any Binance pair:
const response = await fetch(
'https://api.syraa.fun/v2/binance/ohlc?symbol=BTCUSDT&interval=1h&limit=100',
{ headers: { 'Payment-Request': paymentHeader } }
);
const { symbol, interval, data } = await response.json();
OHLC Response:
{
"symbol": "BTCUSDT",
"interval": "1h",
"data": [
{
"time": 1709467200000,
"open": "65100.00",
"high": "65432.00",
"low": "64890.00",
"close": "65234.00",
"volume": "1234.56"
}
]
}
Supported Intervals
- Minutes: 1m, 3m, 5m, 15m, 30m
- Hours: 1h, 2h, 4h, 6h, 8h, 12h
- Days: 1d, 3d
- Weeks: 1w
- Months: 1M
Batch OHLC Requests
Fetch OHLC data for multiple symbols:
import { fetchBinanceOhlcBatch } from './libs/binanceOhlcBatch.js';
const tickers = 'BTCUSDT,ETHUSDT,SOLUSDT,BNBUSDT';
const result = await fetchBinanceOhlcBatch(tickers, '1h');
Batch Response:
{
"interval": "1h",
"count": 4,
"results": [
{
"symbol": "BTCUSDT",
"success": true,
"data": [ /* OHLC array */ ]
},
{
"symbol": "ETHUSDT",
"success": true,
"data": [ /* OHLC array */ ]
}
]
}
Technical Indicators
Moving Averages
Calculate moving averages from OHLC data:
function calculateSMA(data, period) {
const sma = [];
for (let i = period - 1; i < data.length; i++) {
const sum = data.slice(i - period + 1, i + 1)
.reduce((acc, candle) => acc + parseFloat(candle.close), 0);
sma.push({
time: data[i].time,
value: sum / period
});
}
return sma;
}
// Usage
const ohlc = await getOHLC('BTCUSDT', '1h', 200);
const sma20 = calculateSMA(ohlc.data, 20);
const sma50 = calculateSMA(ohlc.data, 50);
const sma200 = calculateSMA(ohlc.data, 200);
RSI (Relative Strength Index)
function calculateRSI(data, period = 14) {
const changes = [];
for (let i = 1; i < data.length; i++) {
const change = parseFloat(data[i].close) - parseFloat(data[i - 1].close);
changes.push(change);
}
const rsi = [];
for (let i = period; i < changes.length; i++) {
const recentChanges = changes.slice(i - period, i);
const gains = recentChanges.filter(c => c > 0).reduce((a, b) => a + b, 0) / period;
const losses = Math.abs(recentChanges.filter(c => c < 0).reduce((a, b) => a + b, 0)) / period;
const rs = gains / (losses || 1);
const rsiValue = 100 - (100 / (1 + rs));
rsi.push({
time: data[i + 1].time,
value: rsiValue
});
}
return rsi;
}
MACD (Moving Average Convergence Divergence)
function calculateEMA(data, period) {
const multiplier = 2 / (period + 1);
const ema = [parseFloat(data[0].close)];
for (let i = 1; i < data.length; i++) {
const value = (parseFloat(data[i].close) - ema[i - 1]) * multiplier + ema[i - 1];
ema.push(value);
}
return ema;
}
function calculateMACD(data, fastPeriod = 12, slowPeriod = 26, signalPeriod = 9) {
const emaFast = calculateEMA(data, fastPeriod);
const emaSlow = calculateEMA(data, slowPeriod);
const macdLine = emaFast.map((fast, i) => fast - emaSlow[i]);
const signalLine = calculateEMA(
macdLine.map((value, i) => ({ close: value.toString(), time: data[i].time })),
signalPeriod
);
const histogram = macdLine.map((macd, i) => macd - signalLine[i]);
return { macdLine, signalLine, histogram };
}
Bollinger Bands
function calculateBollingerBands(data, period = 20, multiplier = 2) {
const sma = calculateSMA(data, period);
const bands = [];
for (let i = period - 1; i < data.length; i++) {
const slice = data.slice(i - period + 1, i + 1);
const mean = sma[i - period + 1].value;
const variance = slice.reduce((sum, candle) => {
const diff = parseFloat(candle.close) - mean;
return sum + (diff * diff);
}, 0) / period;
const stdDev = Math.sqrt(variance);
bands.push({
time: data[i].time,
upper: mean + (stdDev * multiplier),
middle: mean,
lower: mean - (stdDev * multiplier)
});
}
return bands;
}
Correlation-Based Strategies
Pair Trading
Identify highly correlated pairs for pair trading:
async function findPairTradingOpportunities() {
const matrix = await getCorrelationMatrix();
const pairs = [];
for (const [token1, correlations] of Object.entries(matrix.data)) {
for (const [token2, correlation] of Object.entries(correlations)) {
if (token1 < token2 && Math.abs(correlation) > 0.8) {
pairs.push({ token1, token2, correlation });
}
}
}
return pairs.sort((a, b) => Math.abs(b.correlation) - Math.abs(a.correlation));
}
Portfolio Diversification
Build diversified portfolios using correlation:
async function buildDiversifiedPortfolio(tokens, maxCorrelation = 0.7) {
const matrix = await getCorrelationMatrix();
const portfolio = [tokens[0]];
for (const token of tokens.slice(1)) {
let isUncorrelated = true;
for (const portfolioToken of portfolio) {
const correlation = matrix.data[token]?.[portfolioToken];
if (Math.abs(correlation) > maxCorrelation) {
isUncorrelated = false;
break;
}
}
if (isUncorrelated) {
portfolio.push(token);
}
}
return portfolio;
}
Integration Example
import { PaymentClient } from '@faremeter/x402-client';
class TechnicalAnalysis {
constructor(wallet) {
this.client = new PaymentClient({
network: 'solana',
wallet
});
this.baseUrl = 'https://api.syraa.fun/v2/binance';
}
async getOHLC(symbol, interval, limit = 100) {
const response = await this.client.fetch(
`${this.baseUrl}/ohlc?symbol=${symbol}&interval=${interval}&limit=${limit}`
);
return await response.json();
}
async getCorrelation(symbol, limit = 10) {
const response = await this.client.fetch(
`${this.baseUrl}/correlation?symbol=${symbol}&limit=${limit}`
);
return await response.json();
}
async getCorrelationMatrix() {
const response = await this.client.fetch(
`${this.baseUrl}/correlation-matrix`
);
return await response.json();
}
async analyzeToken(symbol) {
// Get OHLC data
const ohlc = await this.getOHLC(symbol, '1h', 200);
// Calculate indicators
const sma20 = this.calculateSMA(ohlc.data, 20);
const sma50 = this.calculateSMA(ohlc.data, 50);
const rsi = this.calculateRSI(ohlc.data);
const macd = this.calculateMACD(ohlc.data);
const bb = this.calculateBollingerBands(ohlc.data);
// Get correlation
const correlation = await this.getCorrelation(symbol);
return {
symbol,
price: parseFloat(ohlc.data[ohlc.data.length - 1].close),
indicators: {
sma20: sma20[sma20.length - 1].value,
sma50: sma50[sma50.length - 1].value,
rsi: rsi[rsi.length - 1].value,
macd: macd.macdLine[macd.macdLine.length - 1],
bollingerBands: bb[bb.length - 1]
},
correlation: correlation.top
};
}
calculateSMA(data, period) {
// Implementation from above
}
calculateRSI(data, period = 14) {
// Implementation from above
}
calculateMACD(data) {
// Implementation from above
}
calculateBollingerBands(data) {
// Implementation from above
}
}
// Usage
const ta = new TechnicalAnalysis(yourWallet);
const analysis = await ta.analyzeToken('BTCUSDT');
console.log('BTC Analysis:', analysis);
console.log(`Price: $${analysis.price}`);
console.log(`RSI: ${analysis.indicators.rsi.toFixed(2)}`);
console.log(`Top Correlation: ${analysis.correlation[0].symbol} (${analysis.correlation[0].correlation})`);
Best Practices
Use multiple timeframes for confirmation. A signal on the 1-hour chart is stronger when confirmed by the 4-hour or daily chart.
- Multiple Indicators: Don’t rely on a single indicator
- Timeframe Confluence: Verify signals across multiple timeframes
- Correlation Context: Consider market-wide correlation in analysis
- Volume Confirmation: Validate price moves with volume
- Risk Management: Use indicators for entries, not just signals
Technical indicators are lagging indicators. They describe past price action and don’t predict the future with certainty.
Indicator Combinations
Trend Following
function isTrendingUp(analysis) {
return (
analysis.price > analysis.indicators.sma20 &&
analysis.indicators.sma20 > analysis.indicators.sma50 &&
analysis.indicators.macd > 0
);
}
Overbought/Oversold
function getMarketCondition(analysis) {
const rsi = analysis.indicators.rsi;
const bb = analysis.indicators.bollingerBands;
const price = analysis.price;
if (rsi > 70 && price > bb.upper) {
return 'OVERBOUGHT';
} else if (rsi < 30 && price < bb.lower) {
return 'OVERSOLD';
}
return 'NEUTRAL';
}