For many people the price of electricity changes hourly or worse.
The amount of energy out of the panels changes moment by moment.
This would be a rather complex problem to solve at the integration level.
Perhaps you could come up with a template sensor that would do this and post it as a ‘share your projects’ so we can see what you are thinking. That might help get this into the integration you stated this should fit into.