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 { Action, ActionSide, ActionFetchOptions, ActionFetchResponse, ActionDateType } from '../interface/actions';
|
||||
|
||||
class AlpacaActivity {
|
||||
id!: string;
|
||||
activity_type!: string;
|
||||
transaction_time!: string;
|
||||
type!: string;
|
||||
price!: string;
|
||||
qty!: string;
|
||||
side!: string;
|
||||
symbol!: string;
|
||||
leaves_qty!: string;
|
||||
order_id!: string;
|
||||
cum_qty!: string;
|
||||
order_status!: string;
|
||||
interface AlpacaActivity {
|
||||
id: string;
|
||||
activity_type: string;
|
||||
transaction_time: string;
|
||||
type: string;
|
||||
price: string;
|
||||
qty: string;
|
||||
side: string;
|
||||
symbol: string;
|
||||
leaves_qty: string;
|
||||
order_id: string;
|
||||
cum_qty: string;
|
||||
order_status: string;
|
||||
}
|
||||
|
||||
export class AlpacaActionProvider {
|
||||
|
@ -43,8 +43,21 @@ describe('Alpaca Tests', () => {
|
||||
|
||||
const response = await exchange.actionProvider.fetchActions(fetchOptions);
|
||||
|
||||
expect(response).toBeDefined();
|
||||
|
||||
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);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user