the taxable event is the stock sale. moving your money from one of your accounts to another is not a taxable event. thus moving the money from a brokerage account to a margin account (which by the way is a brokerage account) isn't taxable and neither is moving the money from your margin account to say your checking account.