Add tests for backtest-client getAssets and createOrder unknown symbol

Covers the two remaining uncovered lines: getAssets returning all
symbols from bar data, and createOrder throwing on unknown symbols.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jon
2026-02-10 19:56:00 -07:00
parent 2208524a3f
commit 06deefe011

View File

@@ -150,6 +150,17 @@ describe('BacktestClient', () => {
}); });
}); });
describe('getAssets', () => {
it('returns all symbols from bar data', async () => {
const assets = await client.getAssets({ status: 'active', asset_class: 'us_equity' });
const symbols = assets.map(a => a.symbol);
expect(symbols).toEqual(['QQQ', 'TQQQ', 'SQQQ']);
expect(assets[0].status).toBe('active');
expect(assets[0].asset_class).toBe('us_equity');
expect(assets[0].fractionable).toBe(true);
});
});
describe('getAsset', () => { describe('getAsset', () => {
it('returns asset info', async () => { it('returns asset info', async () => {
const asset = await client.getAsset('TQQQ'); const asset = await client.getAsset('TQQQ');
@@ -157,4 +168,16 @@ describe('BacktestClient', () => {
expect(asset.fractionable).toBe(true); expect(asset.fractionable).toBe(true);
}); });
}); });
describe('createOrder - unknown symbol', () => {
it('throws when no bar data exists', async () => {
await expect(client.createOrder({
symbol: 'AAPL',
notional: 1000,
side: 'buy',
type: 'market',
time_in_force: 'day',
})).rejects.toThrow('No bar data for AAPL');
});
});
}); });