Buying on margin refers to borrowing money to invest in a stock. This allows you to purchase stock that you otherwise might not be able to afford. When the stock increases in value, you gain more position than if you bought the smaller quantity allowed by your cash balance. This results in a higher Return on Investment (ROI), because your positioned is leveraged with the borrowed money. However, buying on margin is a relatively risky investment, and if the stock falls, you can lose considerably more than you would from a cash purchase.

Add the total cost of purchasing the stock. This should include broker fees, th estock price and any interest charged for buying on margin. Your broker should have all this information, if you don't have it readily available. For example, if you purchased 100 shares of a stock for $100 per share, the cost would be $10,000. However, you also need to add transactions fees and any accrued interest. If the buying and selling transaction fees totaled $50 and the interest is $150, then your total cost would be $10,200.

Subtract this figure from the gross amount received from the sale of the stock. This gives you your net profit. If the example stock sold at $200 per share, your gross return would be $20,000. Subtract the total cost from that figure to get a net profit of $9,800.

Calculate the amount you personally invested in the purchase. This includes your portion of the stock's cost, along with transaction fees and interest. If you only contributed $1,000 to the purchase price, your total investment would be just $1,200 when you include interest and transaction fees.

Divide the net profit by your total investment and multiply by 100 to calculate your ROI in percentage terms. In the example, $9,800 divided by $1,200 gives you 8.1667. Multiply by 100 to convert into percent format, or 816.67 percent ROI.