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:
@@ -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', () => {
|
||||
it('returns asset info', async () => {
|
||||
const asset = await client.getAsset('TQQQ');
|
||||
@@ -157,4 +168,16 @@ describe('BacktestClient', () => {
|
||||
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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user