def proportion_of_demands_met(sim, threshold=0.1):
    """ Calculate the percentage of charging sessions where the energy request was met.

    Args:
        sim (Simulator): A Simulator object which has been run.
        threshold (float): Close to finished a session should be to be considered finished. Default: 0.1. [kW]

    Returns:
        float: Proportion of sessions where the energy demand was fully met.
    """
    finished = sum(1 for ev in sim.ev_history.values() if ev.remaining_demand < threshold)
    return finished / len(sim.ev_history)