ALGORITHM OVERVIEW
The Perpguin algorithm combines technical analysis, sentiment processing, and order flow data to identify high-probability trading opportunities in perpetual futures markets. The system processes multiple data streams in real-time, including live intelligence from news sources and social media events, to generate high-confidence signals. By continuously monitoring Twitter sentiment, Reddit discussions, news headlines, and influencer posts, the algorithm captures market-moving information as it happens, applying weighted scoring mechanisms and generating signals only when confidence thresholds are met, ensuring consistent risk management across all trades.
ALGORITHM COMPONENTS
Main Algorithm - Signal Generation
// Core perpetual signal generation algorithm
const generateSignal = async (asset: string) => {
const technicalScore = await analyzeTechnicals(asset);
const sentimentScore = await analyzeSentiment(asset);
const volumeScore = await analyzeOrderFlow(asset);
const compositeScore = (technicalScore * 0.5) +
(sentimentScore * 0.3) +
(volumeScore * 0.2);
const signal = compositeScore > 0.7 ? 'LONG' :
compositeScore < -0.7 ? 'SHORT' : 'NEUTRAL';
const confidence = Math.abs(compositeScore);
const leverage = calculateLeverage(confidence, volatility);
return {
asset,
signal,
confidence: Math.round(confidence * 100),
leverage,
entry: getCurrentPrice(asset),
stopLoss: calculateStopLoss(signal, volatility),
takeProfit: calculateTakeProfit(signal, confidence)
};
};
Live Intelligence - News & Social Sentiment
// Real-time sentiment analysis from multiple sources
const analyzeSentiment = async (asset: string) => {
const sources = [
await scrapeTwitterSentiment(asset),
await parseNewsHeadlines(asset),
await analyzeRedditMentions(asset),
await checkInfluencerPosts(asset)
];
let bullishSignals = 0;
let bearishSignals = 0;
let totalWeight = 0;
sources.forEach(source => {
const weight = source.credibility * source.reach;
totalWeight += weight;
if (source.sentiment > 0.6) {
bullishSignals += weight * source.sentiment;
} else if (source.sentiment < -0.6) {
bearishSignals += weight * Math.abs(source.sentiment);
}
});
const netSentiment = (bullishSignals - bearishSignals) / totalWeight;
return {
score: netSentiment,
confidence: Math.min(totalWeight / 100, 1),
sources: sources.length
};
};
Technical Analysis - Order Flow & Volume
// Advanced technical analysis with order flow and volume
const analyzeTechnicals = async (asset: string) => {
const candles = await getCandles(asset, '15m', 100);
const orderBook = await getOrderBook(asset);
const volumeProfile = await getVolumeProfile(asset);
// RSI and MACD confluence
const rsi = calculateRSI(candles, 14);
const macd = calculateMACD(candles, 12, 26, 9);
const bollinger = calculateBollingerBands(candles, 20, 2);
// Order flow analysis
const bidAskRatio = orderBook.bids.total / orderBook.asks.total;
const volumeWeightedPrice = calculateVWAP(candles, volumeProfile);
const orderFlowImbalance = calculateOrderFlowImbalance(orderBook);
// Support/Resistance levels
const keyLevels = identifyKeyLevels(candles, volumeProfile);
const currentPrice = candles[candles.length - 1].close;
const levelProximity = calculateLevelProximity(currentPrice, keyLevels);
// Composite technical score
const technicalScore = (
(rsi > 70 ? -0.3 : rsi < 30 ? 0.3 : 0) +
(macd.signal > 0 ? 0.2 : -0.2) +
(bidAskRatio > 1.2 ? 0.2 : bidAskRatio < 0.8 ? -0.2 : 0) +
(orderFlowImbalance * 0.3) +
(levelProximity * 0.2)
);
return {
score: Math.max(-1, Math.min(1, technicalScore)),
rsi,
macd: macd.signal,
orderFlow: orderFlowImbalance,
keyLevels
};
};