Any purchase and sale, or sale and purchase, of a security shall be exempt from section 16(b) of the Act, if the transaction is effected by an investment company registered under the Investment Company Act of 1940 (15 U.S.C. 80a-1 et seq.) and both the purchase and sale of such security have been exempted from the provisions of section 17(a) (15 U.S.C. 80a-17(a)) of the Investment Company Act of 1940, by rule or order of the Commission.