Non-profit organizations are allowed to have endowments and those endowments can invest in securities. The issue is - what is the ultimate purpose of the endowment? If it's clearly to aid the mission of the organization, it's theoretically possible but it should be clear that the purpose of the endowment is to support the mission of the organization.
Your non-profit should have legal counsel if it is thinking about an endowment; if it cannot afford a lawyer, it cannot afford to dump non-profit money into the stock market. Good luck.
In general, the answer is yes. However, is the not-for-profit a public charity, a private foundation or some other type of entity? Is the for-profit a publicly traded company or a private company? Is the for-profit have any connections to members of the Board of the not-for-profit? There are potential conflict issues if there are connections between the for-profit and not-for-profit. Also, organizations should invest there funds wisely or, in other words, not make too many risky investments (if any).