Add timestamp to actions.

This commit is contained in:
Carter Bertolini 2023-11-03 16:23:33 -04:00
parent 5b66bcd2c0
commit 27b49dc6dc
2 changed files with 10 additions and 2 deletions

View File

@ -37,7 +37,8 @@ export class AlpacaActionProvider {
activity.symbol,
parseInt(activity.qty, 10),
activity.side === "buy" ? ActionSide.Buy : ActionSide.Sell,
parseFloat(activity.price)
parseFloat(activity.price),
new Date(activity.transaction_time),
);
}),
undefined

View File

@ -30,6 +30,11 @@ export class Action {
*/
readonly pricePerShare: number;
/**
* The timestamp of the action
*/
readonly timestamp: Date;
/**
* Represents a user Action.
* @constructor
@ -37,12 +42,14 @@ export class Action {
* @param {number} quantity - The quantity of the asset being traded.
* @param {ActionSide} side - The side of the trade (buy or sell).
* @param {number} pricePerShare - The price per share of the asset being traded.
* @param {Date} timestamp - The timestamp of the action.
*/
constructor(symbol: string, quantity: number, side: ActionSide, pricePerShare: number) {
constructor(symbol: string, quantity: number, side: ActionSide, pricePerShare: number, timestamp: Date) {
this.symbol = symbol;
this.quantity = quantity;
this.side = side;
this.pricePerShare = pricePerShare;
this.timestamp = timestamp;
}
}