Create an entity to store energy price along the time

Please format you posts correctly for the forum. https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

The way you could implement this is with a daily energy utility meter and a triggered template sensor.

Trigger the template sensor just before midnight, calculate your daily cost by multiplying the daily energy by the current price. Then add this to the running total of the template sensor,