Added interface for fetching user actions.

This commit is contained in:
Carter Bertolini 2023-10-27 16:07:43 -04:00
parent f25f21a050
commit 20a8920a30
2 changed files with 55 additions and 0 deletions

49
src/interface/actions.ts Normal file
View File

@ -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<ActionFetchResponse>;
}
export interface ActionProvider {
readonly fetchActions: (options: ActionFetchOptions) => Promise<ActionFetchResponse>;
}

View File

@ -1,5 +1,6 @@
import { PortfolioProvider } from "./portfolio"; import { PortfolioProvider } from "./portfolio";
import { QuoteProvider } from "./quote"; import { QuoteProvider } from "./quote";
import { ActionProvider } from "./actions";
/** /**
* Represents an exchange, which provides access to a portfolio provider and a quote provider. * Represents an exchange, which provides access to a portfolio provider and a quote provider.
@ -16,6 +17,11 @@ export interface Exchange {
*/ */
readonly quoteProvider: QuoteProvider; readonly quoteProvider: QuoteProvider;
/**
* The action provider for the exchange.
*/
readonly actionProvider: ActionProvider;
/** /**
* The name of the exchange. * The name of the exchange.
*/ */