US Bond Yield Magma Curve
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © giancarlopagliaroli

//@version=5
indicator('US Bond Yield Magma Curve (automiamo.com)', precision=6, overlay=false)

us3M = input.symbol(title= '3M Bond Yield', defval='TVC:US03M')
us01 = input.symbol(title= '1 Year Bond Yield', defval='TVC:US01Y')
us02 = input.symbol(title= '2 Year Bond Yield', defval='TVC:US02Y')
us03 = input.symbol(title= '3 Year Bond Yield', defval='TVC:US03Y')
us05 = input.symbol(title='5 Year Bond Yield', defval='TVC:US05Y')
us07 = input.symbol(title='10 Year Bond Yield', defval='TVC:US07Y')
us10 = input.symbol(title='10 Year Bond Yield', defval='TVC:US10Y')
us20 = input.symbol(title='20 Year Bond Yield', defval='TVC:US20Y')
us30 = input.symbol(title='30 Year Bond Yield', defval='TVC:US30Y')

diff_30_10 = request.security(us30, timeframe.period, close) - request.security(us10, timeframe.period, close)
diff_20_10 = request.security(us20, timeframe.period, close) - request.security(us10, timeframe.period, close)
diff_7_10 = request.security(us07, timeframe.period, close) - request.security(us10, timeframe.period, close)
diff_5_10 = request.security(us05, timeframe.period, close) - request.security(us10, timeframe.period, close)
diff_3_10 = request.security(us03, timeframe.period, close) - request.security(us10, timeframe.period, close)
diff_2_10 = request.security(us02, timeframe.period, close) - request.security(us10, timeframe.period, close)
diff_1_10 = request.security(us01, timeframe.period, close) - request.security(us10, timeframe.period, close)
diff_3M_10 = request.security(us3M, timeframe.period, close) - request.security(us10, timeframe.period, close)

plot(0, title = "10Y",  color = color.green, linewidth = 4 )
plot(diff_30_10, title = "30Y-10Y Diff",  color = color.blue, linewidth = 3 )
plot(diff_20_10,title = "20Y-10Y Diff", color = color.blue, linewidth = 2)
plot(diff_7_10,title = "07Y-10Y Diff", color = color.orange, linewidth = 2)
plot(diff_5_10,title = "05Y-10Y Diff", color = color.orange, linewidth = 3)
plot(diff_3_10,title = "03Y-10Y Diff", color = color.orange, linewidth = 4)
plot(diff_2_10,title = "02Y-10Y Diff", color = color.red, linewidth = 3)
plot(diff_1_10,title = "01Y-10Y Diff", color = color.yellow, linewidth = 3)
plot(diff_3M_10,title = "03M-10Y Diff", color = color.yellow, linewidth = 4)