For fun, I checked out what the maximum leverage would be that you could run, if you rebalanced your investment every day to reach your exact target leverage (an assuming no transaction costs and no interest on your margin loan) without you going bankrupt.
Under those conditions that's mostly governed by the what's the largest single day loss. The S&P 500 had a really bad day on 2020-03-16. Microsoft's worst single day loss was on 2000-04-24 when the dot com bubble burst.
All data from yahoo finance adjusted closing price.
My simple analysis suggests that you would have made the most money with 1.8x leverage on Microsoft. And with 1.9x leverage on the S&P 500. Both starting at August 22nd 1997 up to 2020-07-24.
That 'optimal' leverage would have multiplied your initial investment by 4.888 for S&P 500 and 35.956 for MSFT over those years.
I would have expected the optimal leverage to differ much more. But the pandemic really did a number on the S&P 500 for a while without hitting Microsoft nearly as hard.
(There are probably some bugs in my code. And in practice you'd probably want to vary your leverage based on observed volatility. You also wouldn't want to rebalance every day.)