Hi,
If you donβt mind manipulating the ticks array manually, you could use something like this:
midpoint = 262.5 # following your example
tickvals = [250, 255, 260, 265, 270, 275 280] # must be set manually
ticktext = [f"<span style='color: {'green' if t <= midpoint else 'red'}'>{t}</span>" for t in tickvals]
fig.update_yaxes(
tickmode='array',
tickvals=tickvals,
ticktext=ticktext,
)
Wrapping the text in a HTML span element does the trick.
Otherwise, you could use two yaxis and have individual traces for bid and ask, but it gets much more complicated IMO.
Hope this helps!
EDIT: Fixed undefined ticks
.