In finance, the margin is the difference between two sums, prices or quotations.
Margin means, how big a difference there is between, for example, your desired purchase price and sales prices that are in the order book or similar. An easy explanation is that margin is the difference between two prices.

When trading instruments with collateral or via instruments that need collateral, margin means a deposit or a guarantee amount.
Here, then, margin means leeway or safety. This is something you have to "line up" with as an investor if, for example, you have a mortgaged portfolio, or make investments that may require more capital if the investment goes the "wrong" way. You then have to provide more margins for the trade/investment to still be active and not forced closed by the brokes, if the margins get to low.