From 27b49dc6dcdedce25debd07411da3b2d09136c62 Mon Sep 17 00:00:00 2001 From: Carter Bertolini Date: Fri, 3 Nov 2023 16:23:33 -0400 Subject: [PATCH] Add timestamp to actions. --- src/alpaca/actions.ts | 3 ++- src/interface/actions.ts | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/alpaca/actions.ts b/src/alpaca/actions.ts index 43c3b13..64a601f 100644 --- a/src/alpaca/actions.ts +++ b/src/alpaca/actions.ts @@ -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 diff --git a/src/interface/actions.ts b/src/interface/actions.ts index 31db230..2c6d52a 100644 --- a/src/interface/actions.ts +++ b/src/interface/actions.ts @@ -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; } }