What is the formula for calculating margin ?

The margin formula for CFD products is: number of lots x contract size x market price / leverage; the margin ratio is: number of lots x contract size x open price x margin ratio.