From 20a8920a30fb81565f5f4034d44bce099104b7a0 Mon Sep 17 00:00:00 2001 From: Carter Bertolini Date: Fri, 27 Oct 2023 16:07:43 -0400 Subject: [PATCH] Added interface for fetching user actions. --- src/interface/actions.ts | 49 +++++++++++++++++++++++++++++++++++++++ src/interface/exchange.ts | 6 +++++ 2 files changed, 55 insertions(+) create mode 100644 src/interface/actions.ts diff --git a/src/interface/actions.ts b/src/interface/actions.ts new file mode 100644 index 0000000..29571fd --- /dev/null +++ b/src/interface/actions.ts @@ -0,0 +1,49 @@ +export enum ActionSide { + Buy, + Sell, +} + +export class Action { + readonly symbol: string; + readonly quantity: number; + readonly side: ActionSide; + readonly pricePerShare: number; + + constructor(symbol: string, quantity: number, side: ActionSide, pricePerShare: number) { + this.symbol = symbol; + this.quantity = quantity; + this.side = side; + this.pricePerShare = pricePerShare; + } +} + +export enum ActionDateType { + On, + After, + Before, +} + +export class ActionDateOptions { + readonly date: Date; + readonly dateType: ActionDateType; + + constructor(date: Date, dateType: ActionDateType) { + this.date = date; + this.dateType = dateType; + } +} + +export class ActionFetchOptions { + readonly pageSize?: number; + readonly dateOptions?: ActionDateOptions; +} + +export interface ActionFetchResponse { + readonly actions: Action[]; + + readonly fetchNextPage?: () => Promise; +} + +export interface ActionProvider { + readonly fetchActions: (options: ActionFetchOptions) => Promise; +} \ No newline at end of file diff --git a/src/interface/exchange.ts b/src/interface/exchange.ts index cb659fb..a708b23 100644 --- a/src/interface/exchange.ts +++ b/src/interface/exchange.ts @@ -1,5 +1,6 @@ import { PortfolioProvider } from "./portfolio"; import { QuoteProvider } from "./quote"; +import { ActionProvider } from "./actions"; /** * Represents an exchange, which provides access to a portfolio provider and a quote provider. @@ -16,6 +17,11 @@ export interface Exchange { */ readonly quoteProvider: QuoteProvider; + /** + * The action provider for the exchange. + */ + readonly actionProvider: ActionProvider; + /** * The name of the exchange. */