If the example you are talking about is "stock index futures", then the volume and position are calculated according to "unilateral"; If the example you are talking about is commodity futures in Shanghai, Zhengzhou and Dalian, then the volume and position are calculated according to "bilateral". As can be seen from the quotation software, the mantissa of the trading volume and positions of stock index futures may be "odd", that is, the mantissa of 1, 3, 5, 7 and 9, while the mantissa of the trading volume and positions of Shanghai, Zhengzhou and Dalian commodity futures must be "even", that is, 2, 4, 6, 8 and 0.
Let's go back to your example: only A and B are doing futures, A has 20 long positions and B has short positions 10, so only 10 can be traded. The volume displayed at this time is 10 lots, and the position is also 10 lots.
If commodity futures are placed in Shanghai, Zhengzhou and Dalian, then the trading volume is 20 lots and the positions are also 20 lots. Of course, A only sold 10 lots, and 10 lots were not sold.