All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
If the company has really started its business activity and it is not a company on paper then – if its shares are among the permissible ones – we do not see anything wrong with selling them directly after buying them, and it is not necessary to keep them for one day or more or less. This is because if the goods is transferred to the buyer, it becomes his right to dispose of it as he wishes, either by selling it, gifting it and the like. The stock market or else is not permitted to condition on the buyer not to sell his shares except after a given time. If it conditions this, then the condition is void because the Prophet said: "Whoever conditions a condition that is not in the Book of Allaah, then his condition is void, even if it were one hundred conditions.” [Al-Bukhari and Muslim] However, the sale is correct.
On the other hand, if the company has not yet started its business activity, then it is not permissible to sell its shares because at this time it is still cash money and it is not permissible to sell it for a bigger amount (of the same cash money) because this is Riba (interest and/or usury). Similarly, it is not permissible to sell the shares before they are owned by the buyer because this is selling what one does not possess and the Prophet forbade it. Such kind of forbidden contracts happen a lot in the future contracts in the stock market, in a way that the buyer sells the shares of a future contract before he possesses them and this is not permissible.
Therefore, you should know, dear brother, that it is not permissible to deal in the shares of a given company unless you know that its activity is permissible and that it does not put its money in banks that deal with Riba. If you do not know whether it puts its money in banks that deal with Riba or in Islamic banks, then it is not permissible for you to deal in its shares, because in principle, such companies do not care about the prohibited transactions and putting its money in banks that deal with Riba.
For more benefit, please refer to Fataawa 92713, 90770 and 81504.
Allaah Knows best.