I don't think shares was your problem. I think it was the margin loan. You could have tried reducing your LVR on margin loan to much more conservative levels. Sure it means less profit if the market moved higher but it also means less stress about being margin called.
Anyways, you have to do...