Use an interface for AlpacaActivity and add date checks to tests.
This commit is contained in:
parent
960285e503
commit
ef1ee52a38
@ -1,19 +1,19 @@
|
|||||||
import Alpaca from '@alpacahq/alpaca-trade-api';
|
import Alpaca from '@alpacahq/alpaca-trade-api';
|
||||||
import { Action, ActionSide, ActionFetchOptions, ActionFetchResponse, ActionDateType } from '../interface/actions';
|
import { Action, ActionSide, ActionFetchOptions, ActionFetchResponse, ActionDateType } from '../interface/actions';
|
||||||
|
|
||||||
class AlpacaActivity {
|
interface AlpacaActivity {
|
||||||
id!: string;
|
id: string;
|
||||||
activity_type!: string;
|
activity_type: string;
|
||||||
transaction_time!: string;
|
transaction_time: string;
|
||||||
type!: string;
|
type: string;
|
||||||
price!: string;
|
price: string;
|
||||||
qty!: string;
|
qty: string;
|
||||||
side!: string;
|
side: string;
|
||||||
symbol!: string;
|
symbol: string;
|
||||||
leaves_qty!: string;
|
leaves_qty: string;
|
||||||
order_id!: string;
|
order_id: string;
|
||||||
cum_qty!: string;
|
cum_qty: string;
|
||||||
order_status!: string;
|
order_status: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class AlpacaActionProvider {
|
export class AlpacaActionProvider {
|
||||||
|
@ -43,8 +43,21 @@ describe('Alpaca Tests', () => {
|
|||||||
|
|
||||||
const response = await exchange.actionProvider.fetchActions(fetchOptions);
|
const response = await exchange.actionProvider.fetchActions(fetchOptions);
|
||||||
|
|
||||||
|
expect(response).toBeDefined();
|
||||||
|
|
||||||
logger.info(JSON.stringify(response));
|
logger.info(JSON.stringify(response));
|
||||||
|
|
||||||
await expect(exchange.actionProvider.fetchActions(fetchOptions)).resolves.toBeDefined();
|
for (const action of response.actions) {
|
||||||
|
expect(action).toBeDefined();
|
||||||
|
expect(action.symbol).toBeDefined();
|
||||||
|
expect(action.quantity).toBeDefined();
|
||||||
|
expect(action.side).toBeDefined();
|
||||||
|
expect(action.pricePerShare).toBeDefined();
|
||||||
|
|
||||||
|
expect(action.timestamp).toBeDefined();
|
||||||
|
expect(action.timestamp.getFullYear()).toBe(2023);
|
||||||
|
expect(action.timestamp.getMonth()).toBe(9);
|
||||||
|
expect(action.timestamp.getDate()).toBe(23);
|
||||||
|
}
|
||||||
}, timeout);
|
}, timeout);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user