You don't have to have the anchor light on the top of the mast. It needs to be visible 360 degrees around the boat and it needs to be visible for a certain distance. That is all the regulations on those.
Bad O is correct, the anchor light does not have to be at the mast head.
Technically as I understand it, and was confirmed by the USCG, it's 354 degree visibility. The COLREG's are a little unclear about this, like many things. The light itself must be a 360 degree light but the visibility of it must comply with the CFR paragraph below:
Here's the COLREG's wording:
(e)"All-round light"
means a light showing an unbroken light over an arc of the horizon of 360 degrees.
It does not make clear that the "light" itself need to be
visible to all 360 degrees just that the light itself needs to be showing an unbroken light over an arc of the horizon of 360.
"CFR 33 Title 84.17 Horizontal Sectors:
b) All-round lights shall be so located as not to be obscured by masts, topmasts or structures within angular sectors of more than 6 degrees, except anchor lights prescribed in Rule 30, which need not be placed at an impracticable height above the hull, and the all-round white light described in Rule 23(d), which may not be obscured at all."
and
"(c) If it is impracticable to comply with paragraph (b) of this section by exhibiting only one all-round light, two all-round lights shall be used suitably positioned or screened to appear, as far as practicable, as one light at a minimum distance of one nautical mile."
You can always revert to the 354 degree rule but beyond that anchor lights do not have to be placed any higher beyond the hull than "is practicable". Meaning it could likely be obscured by a mast and still be totally legal if it was not practical to climb to the top of the mast to place an anchor light if using say an oil lamp.
To get a more detailed understanding of the COLREG's, when it is not totally clear, I usually revert to the Code of Federal Regulations which are the "rules behind the rules"..
I have an anchor light mounted to my radar pole on the stern. I have at least 358 degrees, or more, of visibility with it as I have circled in my dinghy at night and can hardly find a break in the light. Not only that it lights up my bimini and boat around it so it can be seen very well as you get within 1/8 of a mile. I still keep one at the mast head too but rarely use it as I feel much safer with the radar pole anchor light.