My postgres database has a table with records from multiple sources. The schema looks like this:
time | source | bid | ask 12:01 | bitmex | 10 | 11 12:01 | deribit | 10 | 11 12:02 | bitmex | 9 | 11
The exact times per source are different. I’m able to plot different lines for every source:
I’m looking to plot the difference (grouped per minute) of two different sources. I think I need to select grouped minutes where “source = x” and the same where “source = y” and subtract those, while keeping the time macros in there to keep the whole thing speedy. Can anyone point me in the right direction?