Add support for Alpaca action fetch options.

This commit is contained in:
2023-11-03 16:19:58 -04:00
parent 158c92c4a5
commit 5b66bcd2c0
2 changed files with 16 additions and 9 deletions

View File

@ -1,5 +1,5 @@
import Alpaca from '@alpacahq/alpaca-trade-api';
import { Action, ActionSide, ActionFetchOptions, ActionFetchResponse } from '../interface/actions';
import { Action, ActionSide, ActionFetchOptions, ActionFetchResponse, ActionDateType } from '../interface/actions';
class AlpacaActivity {
id!: string;
@ -22,11 +22,11 @@ export class AlpacaActionProvider {
readonly fetchActions = (options: ActionFetchOptions): Promise<ActionFetchResponse> => {
return (this.alpaca.getAccountActivities({
activityTypes: "FILL",
until: undefined,
after: undefined,
until: options.dateOptions?.dateType === ActionDateType.Before ? options.dateOptions.date : undefined,
after: options.dateOptions?.dateType === ActionDateType.After ? options.dateOptions.date : undefined,
direction: "desc",
date: undefined,
pageSize: undefined,
date: options.dateOptions?.dateType === ActionDateType.On ? options.dateOptions.date : undefined,
pageSize: options.pageSize,
pageToken: undefined,
}) as Promise<AlpacaActivity[]>).then((activities) => {
return new ActionFetchResponse(