Profit Calculation Problem

I have created an us stock trade system yesterday. I closed all the trade before market closed, and I calculated total profit from the trade record detail, and found that the actual profit is $158, but the system statistics show me the profit is $508. Which is correct profit and the reason is?