How to calculate the cash value in "Daily Positions & Gains" of backtest result

I write the simple code to test the backtest result.
I am confused in how to calculate the cash value in "Daily Positions & Gains" of backtest result.
Please see the sample codes as below, and I find these results are totoally different.
I know some fee should be considered, but it is still hard for me to understand how to evaluate these final cash value!
Who can help me understand it?

code 1:
9:40: current_price = data.current(XXX, 'price')
9:40: order(XXX, 300, style=LimitOrder(current_price))
15:30: current_price = data.current(XXX, 'price')
15:30: order(XXX, -300, style=LimitOrder(current_price))

code 2:
9:40: current_price = data.current(XXX, 'price')
9:40: order(XXX, 100, style=LimitOrder(current_price))
9:40: order(XXX, 100, style=LimitOrder(current_price))
9:40: order(XXX, 100, style=LimitOrder(current_price))
15:30: current_price = data.current(XXX, 'price')
15:30: order(XXX, -100, style=LimitOrder(current_price))
15:30: order(XXX, -100, style=LimitOrder(current_price))
15:30: order(XXX, -100, style=LimitOrder(current_price))