Filling between two specific lines?

Found the answer elsewhere:

Apparently “tonexty” actually fill the space between the current trace and the trace that was previously added in the ‘trace storage’, and not to the ‘nearest’ trace. This means that the order in which the traces are added to the figure is the main factor in determining between which trends the fill happens.

A workaround can therefore be:

# add a transparent 'red' trace not visible on legend.
fig.add_trace(
    go.Scatter(
        x=series2.index,
        y=series2,
        fill=None,
        mode="lines",
        line_color="rgba(0,0,0,0)",
        showlegend=False,
    )
)
# add orange trace
fig.add_trace(
    go.Scatter(
        x=series2.index,
        y=positive_contribution,
        fill="tonexty",
        mode="lines",
        line_color="orange",
    )
)
# re add the red trace, but visible this time, as this is the last one
fig.add_trace(
    go.Scatter(
        x=series2.index,
        y=series2,
        fill=None,
        mode="lines",
        line_color="red",
    )
)
# add the cyan trace
fig.add_trace(
    go.Scatter(
        x=series2.index,
        y=negative_contribution,
        fill="tonexty",
        mode="lines",
        line_color="cyan",
    )
)
# finally add the black trace
fig.add_trace(
    go.Scatter(
        x=series1.index,
        y=series1,
        fill=None,
        mode="lines",
        line_color="black",
    )
)