The available margin for opening positions will change with the latest transaction price. The specific formula is as follows:

Calculate the amount of margin required for buying and selling orders:

The amount of sales required to be charged = min (c-abs (current position quantity), abs (number of selling orders))

The amount of purchase required to be charged = c-abs (current position quantity)-The quantity of sales that need to be collected.

In this formula:

c = MAX (a, b) (the number of buying orders> 0, the number of selling orders <0)

a = MAX (abs (current position quantity), abs (current position quantity + number of buying orders))

b = MAX (abs (current position quantity), abs (current position quantity + number of selling orders))

Example: holding 10 long positions, selling 100 with a need to freeze an additional of selling order of 80.

a = max (ads (10), abs (10 + 0)) = 10

b = max (ads (10), abs (10-100)) = 90

c = max (a, b) = max (10, 90) = 90

The amount of sales required to be charged = min (90-abs (10), abs (0)) = 80

The amount of purchase required to be charged = 90-abs (10)-80 = 0