The Available Cash value displayed in the live trading dashboard is a bit misleading if the algorithm places any short trades . If one only trades long, this value is straightforward.
# Assume cash = $10,000 and positions_value = $0 and portfolio_value = $10,000
# What if we took a long position of XYZ
# Assuming XYZ sells for $10 and $0 commission
order(xyz, 1000)
# Buy reduces cash by $10,000 and increases positions_value by $10,000.
# So cash = $0 and positions_value = $10,000 and portfolio_value = $10,000
# now we sell..
order(xyz, -1000)
# Sell increases cash by $10,000 and reduces positions_value by $10,000.
# So cash = $10,000 and positions_value = $0 and portfolio_value = $10,000
Pretty straightforward. The Available Cash is what we would expect. Note, we could have purchased $15,000 of XYZ and our cash would be negative. Again, this makes sense. We 'borrowed' $5000 so now we have a negative cash balance.
Now, things become less straightforward if we place any short trades. Let's see how that works.
# Assume cash = $10,000 and positions_value = $0 and portfolio_value = $10,000
# What if we took a short position of XYZ.
# Assuming XYZ sells for $10 and $0 commission and a starting balance of $10,000
# All short means is we sell BEFORE we buy it. So...
order(xyz,- 1000)
# Sell increases cash by $10,000 and reduces positions_value by $10,000.
# So cash = $20,000 and positions_value = $-10,000 and portfolio_value = $10,000
# Now we buy (ie close the short position)...
order(xyz, 1000)
# Buy reduces cash by $10,000 and increases positions_value by $10,000.
# So cash = $10,000 and positions_value = $0 and portfolio_value = $10,000
Notice at all times the portfolio_value = $10,000 however the cash goes up to $20,000. Did I make money somehow? No (unfortunately). What isn't shown is the amount you needed to 'borrow' to buy the short stock. That will be the difference between the available cash and cash you started with. In the above example this would be $20,000-$10,000 = $10,000.
The term available cash is a bit misleading since it also includes funds 'borrowed' for short sales. That is probably why you are seeing $98k in available cash. You probably have some short positions?
The gross profit is labeled Dollar P/L and is shown on the live trading dashboard at the top. It can be calculated as
profit = starting_cash - buys + sells - commissions + dividends
The key is to remember two accounting rules.
A buy always increases shares and reduces cash.
A sell always reduces shares and increases cash.
The only difference between opening a long or opening a short position is timing.
When taking a long position, one is first placing a buy and then placing a sell.
When taking a short position, one is first placing a sell and then placing a buy (just the reverse).
Maybe more info than you wanted, but that's why the available cash is misleading if ever placing short trades. When live/paper trading you will probably want to look at Dollar P/L.