Reply To: Spread Calculation

Optuma Forums Optuma Scripting Spread Calculation Reply To: Spread Calculation

  • Topics: 32
  • Replies: 1,590
  • Posts: 1,622

Hi Thomas,

You would need to start with a GetData() function. So on the S&P chart you would get the data for the German Bond.


GB1 = GetData(code={select the code});

While it is not necessary, I would also add the SP into a variable so it makes the script easy to follow


SP1 = Close();  //  assuming this script is added to a S&P chart – if not you can also do a GetData() here.

Then you can use these in your scripts.

eg your first line would become


Now, a better way to get the yield is just to use the Change() function. The trouble with going back “x” bars is that as soon as you change time frame the calculation is wrong (120 days will not give you the right value).

CS1 = Change(SP1, INT_TYPE=Year, INT_COUNT=10);
YS1 = (POWER(CS1 , POWER=$V4) – 1)*100; // to get it to a yearly compounded figure (we might have to add a CAGR function).

Hope that helps


Pin It on Pinterest

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.