This is not employment however there could be profit/ loss based on the situation.
As long as you invest only your own money for your own personal finances, this should be fine. what you do with your private money on private terms is none of Germany's business. You could already own stock or have other means of income (for example maybe you rent out property you own in your home country). Or you could simply win the lottery. Or maybe you buy a used car for yourself for cheap and manage to sell it for more than you bought it for after a year. And in the end, if you put your money into a bank account and get interest, that's not really different. As long as it's not a business.
Obviously, you need to declare all of this when you do your taxes, you may want to hire a tax accountant for that.