If buying and selling share is going to be a regular thing in this business then you'll have to spend some time and effort to learn how to setup, record and account for all the different types of transactions that you will run into - thats a whole big world unto itself.
But for one-off you should record the transfers in/out of the investment account as Bank Transfers to/from your regular bank (or check and deposit if thats how its done). The loss on sale would be a JE to credit (reduce) the investment account and DR a capital gain/loss account that is located in the 'other income' part of the GL