Deductions & credits

The purpose of using HELOC is to make money rather than spending it on a "home improvement" for instance. Is there any difference how I want to make money, whether buying a stock or loaning for a above HELOC interest rate to someone else? I made money on the transaction and my question is can I deduct the HELOC interest as expense from the income I made from that deal, in my case - loaning my HELOC?