Views:
You can apply at any time from the date that the University reports your successful completion and award to UK Visas and Immigration (UKVI), up to the date your Student visa expires.  You will receive an email from the University when reported.
 
The length of your Graduate visa will be based on the date the decision is made to grant the visa, so there is usually no advantage in applying too early.  As long as you submit your online visa application before your current visa expires, it does not matter if your visa expires while you are waiting for a decision. You are allowed to remain in the UK while a visa application is pending and you are covered by your previous visa conditions.