Skip to content

Commit d82ddc2

Browse files
Patrick BanksPatrick Banks
authored andcommitted
Added profit and loss to balance history
1 parent 7972f69 commit d82ddc2

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/trader/trader.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,6 +2121,7 @@ function updateBalanceHistory(tradingType: TradingType, quote: string, entryType
21212121
// Update latest balances and stats
21222122
if (change) balance = balance.plus(change)
21232123
h.closeBalance = balance
2124+
h.profitLoss = h.closeBalance.minus(h.openBalance)
21242125
if (h.minOpenTrades == undefined || minOpenTradeCount < h.minOpenTrades) h.minOpenTrades = minOpenTradeCount
21252126
if (h.maxOpenTrades == undefined || maxOpenTradeCount > h.maxOpenTrades) h.maxOpenTrades = maxOpenTradeCount
21262127
if (entryType == EntryType.ENTER) {

src/trader/types/trader.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export class BalanceHistory {
128128
date: Date // Date and time that this history slice started
129129
openBalance: BigNumber // Opening balance
130130
closeBalance: BigNumber // Last observed balance
131+
profitLoss: BigNumber // Difference between open and close balance
131132
minOpenTrades?: number // Lowest number of concurrent open trades
132133
maxOpenTrades?: number // Highest number of concurrent open trades
133134
totalOpenedTrades: number // Total number of trades opened
@@ -138,6 +139,7 @@ export class BalanceHistory {
138139
this.date.setHours(0,0,0,0) // Clear the time
139140
this.openBalance = balance
140141
this.closeBalance = balance
142+
this.profitLoss = new BigNumber(0)
141143
this.totalOpenedTrades = 0
142144
this.totalClosedTrades = 0
143145
}

0 commit comments

Comments
 (0)