UNPKG

skayn-trading-sdk

Version:

Professional Bitcoin trading strategy backtesting framework with institutional-grade architecture

58 lines (47 loc) 1.82 kB
const { SDK } = require('../index'); describe('Skayn SDK', () => { test('SDK.create() returns instance', () => { const sdk = SDK.create(); expect(sdk).toBeDefined(); expect(typeof sdk.strategy).toBe('function'); expect(typeof sdk.dataProvider).toBe('function'); expect(typeof sdk.backtest).toBe('function'); }); test('Strategy helper creates valid strategy', () => { const testStrategy = SDK.strategy(async (data, portfolio) => { return { action: 'HOLD', confidence: 0 }; }); expect(testStrategy).toBeDefined(); expect(typeof testStrategy.analyze).toBe('function'); }); test('Chainable API works', () => { const mockStrategy = SDK.strategy(async () => ({ action: 'HOLD' })); const mockDataProvider = SDK.dataProvider(async () => []); const sdk = SDK.create() .strategy(mockStrategy) .dataProvider(mockDataProvider); expect(sdk).toBeDefined(); }); test('Backtest with mock data', async () => { const mockStrategy = SDK.strategy(async (data) => { if (data.length > 0) { return { action: 'BUY', confidence: 0.8, quantity: 0.001, strategy: 'momentum' }; } return { action: 'HOLD', confidence: 0, strategy: 'momentum' }; }); const mockData = [ { timestamp: Date.now(), open: 45000, high: 46000, low: 44000, close: 45500, volume: 100 } ]; const mockDataProvider = SDK.dataProvider(async () => mockData); const results = await SDK.create() .strategy(mockStrategy) .dataProvider(mockDataProvider) .backtest({ startDate: '2024-01-01', endDate: '2024-01-02', initialBalance: 10000 }); expect(results).toBeDefined(); expect(typeof results).toBe('object'); }, 15000); // 15 second timeout });