automated-trading-with-ichimoku
1
总安装量
1
周安装量
#43695
全站排名
安装命令
npx skills add https://github.com/chipagosfinest/claude-finance-trading --skill automated-trading-with-ichimoku
Agent 安装分布
replit
1
openclaw
1
opencode
1
codex
1
claude-code
1
Skill 文档
Automated Trading with Ichimoku and Multi-Source Signals
Problem
Building an automated trading system that:
- Uses Ichimoku Cloud for entry/exit signals
- Integrates news and social sentiment for confirmation
- Enforces strict risk management (mandatory stop losses)
- Trades on decentralized perp exchanges (Hyperliquid, Ostium)
Context / Trigger Conditions
- User wants to automate trading with technical analysis
- Need to combine multiple signal sources (technical + sentiment)
- Trading perpetual futures on crypto or RWA markets
- Must protect capital with proper risk management
Solution
1. Signal Quality Filters (Be Strict)
// Only trade strong, high-confidence signals
if (signal.combinedSignal.strength !== 'strong') {
return { action: 'skip', reason: 'Not strong enough' };
}
if (signal.combinedSignal.confidence < 75) {
return { action: 'skip', reason: 'Confidence too low' };
}
// All timeframes must agree
const allAgreed = signal.timeframes.every(
tf => tf.signal.type === signal.combinedSignal.type
);
if (!allAgreed) {
return { action: 'skip', reason: 'Timeframes not aligned' };
}
2. Mandatory Stop Loss Validation
// NEVER trade without a stop loss
if (!advice.stopLoss || advice.stopLoss <= 0) {
return { action: 'skip', reason: 'NO STOP LOSS - refusing trade' };
}
// Validate stop distance (0.5% - 10% for perps)
const stopDistance = Math.abs(price - advice.stopLoss) / price;
if (stopDistance > 0.10 || stopDistance < 0.005) {
return { action: 'skip', reason: 'Invalid stop distance' };
}
// Require 1.5:1 minimum risk/reward
const riskRewardRatio = reward / risk;
if (riskRewardRatio < 1.5) {
return { action: 'skip', reason: 'R:R too low' };
}
3. Multi-Source Sentiment Integration
// Fetch external signals from database
const externalSignals = await fetchExternalSignals(symbol);
// Analyze sentiment alignment
const sentimentAnalysis = analyzeExternalSentiment(
externalSignals,
signal.combinedSignal.type // 'buy' or 'sell'
);
// Veto if sentiment strongly opposes
if (sentimentAnalysis.veto) {
return { action: 'skip', reason: sentimentAnalysis.veto };
}
// Adjust confidence based on sentiment
const adjustedConfidence = confidence + sentimentAnalysis.adjustment;
4. Ichimoku-Based Exit Signals
// Check for exit conditions in order of priority:
// 1. Stop loss (ALWAYS FIRST)
if (isLong && currentPrice <= position.stopLoss) {
return { close: true, reason: 'STOP LOSS HIT' };
}
// 2. Take profit
if (isLong && currentPrice >= position.takeProfit) {
return { close: true, reason: 'TAKE PROFIT reached' };
}
// 3. Signal reversal (70%+ confidence opposite signal)
if (isLong && signal.type === 'sell' && signal.confidence >= 70) {
return { close: true, reason: 'ICHIMOKU REVERSAL' };
}
// 4. Cloud exit (price crosses Kumo)
if (isLong && ichimoku.isBelowCloud && ichimoku.cloudColor === 'red') {
return { close: true, reason: 'KUMO EXIT' };
}
// 5. TK Cross against position
const tkCrossBearish = tenkanSen < kijunSen && isBelowCloud;
if (isLong && tkCrossBearish) {
return { close: true, reason: 'TK CROSS bearish' };
}
// 6. Kijun trailing stop (2% beyond Kijun-sen)
if (isLong && currentPrice < kijunSen * 0.98) {
return { close: true, reason: 'KIJUN BREAK' };
}
5. Position Sizing Based on Risk
// Calculate size from stop loss and max risk
const maxRiskDollars = capital * (maxRiskPercent / 100);
const stopDistance = Math.abs(entry - stopLoss) / entry;
const positionSize = maxRiskDollars / stopDistance;
// Apply additional limits
const finalSize = Math.min(
positionSize,
availableCapital * 0.25, // Max 25% per trade
100 // Hard cap
);
6. Hyperliquid SDK Integration
import { HyperliquidClient, HyperliquidTransport } from '@nktkas/hyperliquid';
import { privateKeyToAccount } from 'viem/accounts';
// Create account from private key
const account = privateKeyToAccount(`0x${privateKey}`);
// Setup transport and client
const transport = new HyperliquidTransport({ url: 'https://api.hyperliquid.xyz' });
const client = new HyperliquidClient({ transport, wallet: account });
// Place market order
const result = await client.exchange.placeOrder({
asset: assetIndex,
isBuy: direction === 'long',
limitPx: price * (isBuy ? 1.01 : 0.99), // 1% slippage
sz: quantity,
reduceOnly: false,
orderType: { limit: { tif: 'Ioc' } }, // IOC for market-like fills
});
Verification
- Build passes:
npm run build - Dry run shows correct signal filtering
- Stop losses calculated correctly
- Sentiment veto works when opposing signals exist
- Hyperliquid API connects and shows account state
Example
// In autoTrader.ts
const trader = new AutoTrader({
dryRun: true, // Always start dry
cryptoSymbols: ['BTC', 'ETH', 'SOL'],
timeframes: ['1h', '4h'],
minConfidence: 75,
});
// Run scan
const { signals, decisions, actionable } = await trader.scan();
// Log results
actionable.forEach(d => {
console.log(`${d.action} ${d.symbol}: ${d.reason}`);
console.log(` Stop: $${d.stopLoss} | TP: $${d.takeProfit}`);
});
Notes
- Always use
dryRun: trueinitially to verify logic - Hyperliquid requires USDC deposited on their L1 (not just wallet balance)
- The
@nktkas/hyperliquidpackage handles signing properly - Stop loss validation prevents catastrophic losses
- Sentiment can veto but not initiate trades (technical is primary)