尚未偵測到更新。GitHub 發布版本後會顯示在這裡。
個人 GitHub 帳號下公開儲存庫的擁有者可以登入並驗證所有權,自行管理介紹,無需管理員核准。
登入並產生驗證檔案,在 30 分鐘內將其提交至此儲存庫的預設分支。其他分支或分叉儲存庫中的檔案無效。然後在下方檢查檔案,即可無需管理員核准直接管理專案。請保留檔案以維持管理權限。
如需登入,將前往登入頁面。登入後請回到此處,再次點擊所選的驗證按鈕。
在專案資料夾中執行 /nomorevibe verify,即可驗證所有權並自行管理介紹。
一分鐘完成驗證High-performance TypeScript technical indicators library with 45+ indicators optimized for real-time trading systems. Features memory-efficient architecture, complete type safety, and comprehensive documentation. Used in production by Gainium trading platform.
翻譯準備中
取自儲存庫 README
正在載入完整 README。
檢視完整 README ↗A high-performance, TypeScript-based technical indicators library built for professional trading applications. This library provides 45+ comprehensive technical analysis indicators optimized for real-time trading systems with minimal memory footprint and maximum computational efficiency.
Author: Maksym Shamko (https://github.com/maksymshamko)
Organization: Gainium (https://github.com/Gainium | https://gainium.io/)
# Install from npm
npm install @gainium/indicators
# or
yarn add @gainium/indicators
import { RSI, SMA, MACD, BollingerBands } from '@gainium/indicators';
// Create indicators
const rsi = new RSI(14);
const sma = new SMA(20);
const macd = new MACD();
const bb = new BollingerBands(20, 2);
// Feed price data
const price = 100.50;
const candle = { open: 100, high: 101, low: 99.5, close: 100.50, volume: 1000 };
// Get results
const rsiValue = rsi.next(price); // Returns RSI value or null if not ready
const smaValue = sma.next(price); // Returns SMA value or null
const macdResult = macd.next(price); // Returns {value, signal, histogram} or null
const bbResult = bb.next(candle); // Returns {upper, middle, lower} or null
console.log('RSI:', rsiValue?.value); // Access RSI value
console.log('SMA:', smaValue); // Direct numeric value
console.log('MACD:', macdResult?.value); // MACD line value
console.log('BB Upper:', bbResult?.upper); // Bollinger Bands upper band
import { SuperTrend, StochasticOscillator } from '@gainium/indicators';
// Create indicators
const superTrend = new SuperTrend(10, 3.0);
const stoch = new StochasticOscillator(14, 3, 3);
// Process multiple candles
const candles = [
{ open: 100, high: 102, low: 99, close: 101, volume: 1000 },
{ open: 101, high: 103, low: 100, close: 102, volume: 1100 },
// ... more candles
];
candles.forEach(candle => {
const stResult = superTrend.next(candle);
const stochResult = stoch.next(candle);
if (stResult && stochResult) {
console.log('SuperTrend:', stResult.trend ? 'Uptrend' : 'Downtrend');
console.log('Stochastic %K:', stochResult.stochK);
console.log('Stochastic %D:', stochResult.stochD);
}
});
// Save and restore state for persistence
const state = superTrend.exportState();
// ... save state to database/file
const newSuperTrend = new SuperTrend(10, 3.0);
newSuperTrend.restoreState(state);
Single-line oscillators (RSI, CCI, MFI, WR, UO, MOM, AO, ADX, BBPB, KCPB, BBW,
VO, MAR) can be smoothed through the factory:
createIndicator({ type: IndicatorEnum.rsi, interval: 14, smoothing: 'ema', smoothingLength: 14 })
returns a SmoothedIndicator whose value is the smoothed line and raw the
oscillator's own value (feed it with feedCandle).
priceChangeCondition gt / lt / between)All indicators extend the LightIndicator base class, providing:
// Basic indicator structure
abstract class LightIndicator<T = number, I = number> {
next(value: I): T | null // Process new value
preview(value: I): T | null // Preview without updating state
get result(): T | null // Get current result
exportState(): LightIndicatorState // Serialize state
restoreState(state: LightIndicatorState): void // Restore state
}
Indicators accept different input types based on their requirements:
Indicators return typed results:
// Simple numeric result
const smaResult: number | null = sma.next(price);
// Complex result objects
const rsiResult: PercentileResult | null = rsi.next(price);
const macdResult: MACDResult | null = macd.next(price);
const bbResult: BollingerBandsResult | null = bb.next(candle);
import { EMA, RSI, MACD } from '@gainium/indicators';
class TradingStrategy {
private ema20 = new EMA(20);
private ema50 = new EMA(50);
private rsi = new RSI(14);
private macd = new MACD();
onNewCandle(candle: OHLCV) {
const ema20Val = this.ema20.next(candle.close);
const ema50Val = this.ema50.next(candle.close);
const rsiVal = this.rsi.next(candle.close);
const macdVal = this.macd.next(candle.close);
if (ema20Val && ema50Val && rsiVal && macdVal) {
// Golden cross with RSI confirmation
if (ema20Val > ema50Val && rsiVal.value < 70 && macdVal.histogram > 0) {
this.enterLong();
}
}
}
}
import { SuperTrend, BollingerBands } from '@gainium/indicators';
function analyzeHistoricalData(candles: OHLCV[]) {
const superTrend = new SuperTrend(10, 3.0);
const bb = new BollingerBands(20, 2);
const signals = candles.map(candle => {
const stResult = superTrend.next(candle);
const bbResult = bb.next(candle);
return {
timestamp: candle.timestamp,
price: candle.close,
trend: stResult?.trend,
bbPosition: bbResult ? (candle.close - bbResult.middle) / (bbResult.upper - bbResult.middle) : null
};
});
return signals.filter(s => s.trend !== null);
}
import { RSI, MACD } from '@gainium/indicators';
class MultiTimeframeAnalysis {
private rsi1h = new RSI(14);
private rsi4h = new RSI(14);
private rsi1d = new RSI(14);
// Call with appropriate timeframe data
update1h(price: number) { return this.rsi1h.next(price); }
update4h(price: number) { return this.rsi4h.next(price); }
update1d(price: number) { return this.rsi1d.next(price); }
getOverallSignal() {
const rsi1h = this.rsi1h.result?.value;
const rsi4h = this.rsi4h.result?.value;
const rsi1d = this.rsi1d.result?.value;
if (rsi1h && rsi4h && rsi1d) {
// All timeframes oversold
if (rsi1h < 30 && rsi4h < 40 && rsi1d < 50) return 'STRONG_BUY';
// All timeframes overbought
if (rsi1h > 70 && rsi4h > 60 && rsi1d > 50) return 'STRONG_SELL';
}
return 'NEUTRAL';
}
}
We welcome contributions! Please follow these guidelines:
All indicators must extend the LightIndicator base class:
export class MyIndicator extends LightIndicator<ResultType, InputType> {
constructor(period: number) {
super(historyLength, defaultValue, stateSize, fillValue);
}
protected calculate(): ResultType | null {
// Implementation
}
}
exportState() and restoreState() methodsMIT License - see LICENSE file for details.
This library powers the technical analysis engine in Gainium, a professional cryptocurrency trading platform trusted by thousands of traders worldwide.
Built with ❤️ by the Gainium team for the trading community.