Spot vs Derivative Premium
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ShisuiCrypto

//@version=4
study("Spot vs Derivative Premium")
src1 = security("COINBASE:BTCUSD", timeframe.period, close)
src2 = security("BYBIT:BTCUSD.P", timeframe.period, close)

src3 = security("BINANCE:BTCUSDT", timeframe.period, close)
src4 = security("BINANCE:BTCUSDTPERP", timeframe.period, close)

plot(0, color=color.black)
plot(src1 - src2, title="Coinbase vs Bybit", display=display.none)
plot(src3 - src4, title="Binance", color=color.green, display=display.none)
plot(avg(src1 - src2, src3 - src4), title="average premium", color=color.red)
plot(close)
