47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import { AIAnalysisRule } from '../src/strategies/rules/AIAnalysisRule.js';
|
|
import { MarketContext, SignalDirection } from '../src/strategies/rules/types.js';
|
|
import logger from '../src/utils/logger.js';
|
|
import * as dotenv from 'dotenv';
|
|
|
|
dotenv.config();
|
|
|
|
async function testAICache() {
|
|
console.log("--- 🧠 TESTING AI CACHING & NON-BLOCKING LOGIC ---");
|
|
|
|
const aiRule = new AIAnalysisRule();
|
|
|
|
const mockContext: MarketContext = {
|
|
symbol: 'BTC/USDT',
|
|
candles4h: [],
|
|
candles1h: [],
|
|
candles15m: [],
|
|
currentPrice: 100000,
|
|
change24h: 0,
|
|
changeToday: 0,
|
|
session: 'NY',
|
|
isMajorSession: true,
|
|
volatility: 'Low',
|
|
latestSignal: SignalDirection.NONE
|
|
};
|
|
|
|
console.log("\n1. Running FIRST check (Should be 'Fresh')...");
|
|
const result1 = await aiRule.check(mockContext);
|
|
console.log("Result 1:", result1.reason);
|
|
console.log("Passed (Should be true):", result1.passed);
|
|
|
|
console.log("\n2. Running SECOND check (Should be 'Cached')...");
|
|
const result2 = await aiRule.check(mockContext);
|
|
console.log("Result 2:", result2.reason);
|
|
console.log("Passed (Should be true):", result2.passed);
|
|
|
|
if (result2.reason?.includes('[Cached]')) {
|
|
console.log("\n✅ SUCCESS: Cache working correctly.");
|
|
} else {
|
|
console.error("\n❌ FAILED: Cache not working as expected.");
|
|
}
|
|
|
|
console.log("\n--- ✨ TEST COMPLETE ---");
|
|
}
|
|
|
|
testAICache().catch(console.error);
|