Add support for Alpaca action fetch options.
This commit is contained in:
@ -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(
|
||||
|
Reference in New Issue
Block a user