investment for purposes of applying this section. (2) Exception for investments made by qualified active investors and related persons Such term shall not include any acquisition or loan made by a taxpayer who, immediately before the acquisition or loan, is a qualified active investor in the qualifying business entity or is related to any qualified active investor. (3) Amount of qualified investment The amount of a taxpayer's qualified investment with respect to any qualifying business entity for any taxable year shall be the monthly average for months ending within the taxable year of— (A) the taxpayer's aggregate unadjusted bases in all stock or interests described in paragraph (1)(A) as of the close of each such month, and (B) the aggregate outstanding principal amount of all qualified loans described in paragraph (1)(B) as of the close of each such month. (4) Special rules for transfers of qualifying loans (A) In general If a taxpayer sells, exchanges, or otherwise transfers all or any portion of a qualifying loan which is a qualified investment in a qualifying business entity, such investment shall be treated as a qualified investment in the hands of the transferee (and not of the transferor) for periods after the transfer. This paragraph shall also apply to any subsequent transfer of such interest. (B) Coordination of limits In applying subsection (b) to any qualifying loan treated as a qualified investment of a transferee under this paragraph— (i) all credits determined under this section for any periods before the transfer with respect to the qualified investment of any prior holder of such investment shall be taken into account under paragraphs (1)(B)(ii) and (2)(A)(ii)(II) of such subsection in the same manner as if such credits were determined for the transferee for prior taxable years, and (ii) if only a portion of the qualified investment was transferred, the amount taken into account under such paragraphs by reason of clause (i) shall be ratably reduced to reflect only the portion so transferred.