usxi/src/interface/actions.ts

111 lines
2.2 KiB
TypeScript

/**
* Enum representing the possible sides of an action.
*/
export const enum ActionSide {
Buy,
Sell,
}
/**
* Represents an action taken on a stock, such as a buy or sell order.
*/
export interface Action {
/**
* The symbol of the asset being traded.
*/
readonly symbol: string;
/**
* The quantity of the asset being traded.
*/
readonly quantity: number;
/**
* The side of the action, either "buy" or "sell".
*/
readonly side: ActionSide;
/**
* The price per share of the asset.
*/
readonly pricePerShare: number;
/**
* The timestamp of the action
*/
readonly timestamp: Date;
}
/**
* Enum representing the type of date filter used in an action fetch.
* @enum {number}
*/
export const enum ActionDateType {
On,
After,
Before,
}
/**
* Represents options for a date filter in an action fetch.
*/
export interface ActionDateOptions {
/**
* The date to filter on.
*/
readonly date: Date;
/**
* The type of date filter to use.
*/
readonly dateType: ActionDateType;
}
/**
* Represents the options for fetching actions.
*/
export interface ActionFetchOptions {
/**
* The number of items to fetch per page.
*/
readonly pageSize?: number;
/**
* The date options for filtering actions.
*/
readonly dateOptions?: ActionDateOptions;
}
/**
* Represents the response of a fetch action request.
*/
export interface ActionFetchResponse {
/**
* An array of `Action` objects.
*/
readonly actions: Action[];
/**
* A function that fetches the next page of actions, if available.
* Returns a promise that resolves to an `ActionFetchResponse` object.
*/
readonly fetchNextPage?: () => Promise<ActionFetchResponse>;
}
/**
* An interface representing an object that provides actions.
*/
export interface ActionProvider {
/**
* Fetches actions based on the provided options.
* @param options - The options to use when fetching actions.
* @returns A promise that resolves to an object containing the fetched actions.
*/
readonly fetchActions: (options: ActionFetchOptions) => Promise<ActionFetchResponse>;
}