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, activity.symbol,
parseInt(activity.qty, 10), parseInt(activity.qty, 10),
activity.side === "buy" ? ActionSide.Buy : ActionSide.Sell, activity.side === "buy" ? ActionSide.Buy : ActionSide.Sell,
parseFloat(activity.price) parseFloat(activity.price),
new Date(activity.transaction_time),
); );
}), }),
undefined undefined

View File

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