fix: Convert trade prices and shares to float to prevent type errors
This commit is contained in:
parent
8d76d820fe
commit
0b07861265
@ -27,7 +27,12 @@ def plot_trade_history(trades):
|
||||
|
||||
for trade in trades:
|
||||
if trade['exit_price']:
|
||||
trade_pnl = (trade['exit_price'] - trade['entry_price']) * trade['shares']
|
||||
# Convert prices to float if they're strings
|
||||
exit_price = float(trade['exit_price'])
|
||||
entry_price = float(trade['entry_price'])
|
||||
shares = float(trade['shares'])
|
||||
|
||||
trade_pnl = (exit_price - entry_price) * shares
|
||||
cumulative_pnl += trade_pnl
|
||||
dates.append(trade['exit_date'])
|
||||
pnl.append(cumulative_pnl)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user