Floating profit and loss = (latest price-position price) * position quantity * direction * contract unit
Settlement gain/loss = (settlement price-position price) * position quantity * direction * contract unit
Closing profit and loss = (closing price-position price) * closing quantity * direction
Total profit and loss = floating profit and loss+ending profit and loss or settlement profit and loss+liquidation profit and loss
Net value = balance+floating profit and loss
Occupancy margin = ∑ opening price * number of positions * contract unit * margin ratio
Frozen margin = ∑ price limit * number of positions * contract unit * margin ratio
Available margin = net value-occupied margin-frozen margin
Customer risk rate = net value/occupation margin * 100%
I hope I can help you solve the problem.