1

I'm working on a simple label overlay for thinkorswim's charting software using thinkscript.

I'm noticing that all of the "Fundamental" API calls I make return NaN. Those "stock fundamental" API calls are documented here: https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Stock-Fundamentals

Here's my usage for the API call 'OperatingProfitMargin':

def opm = if IsNaN(OperatingProfitMargin()) then 123 else OperatingProfitMargin();

AddLabel(yes, "Op PM: " + opm, Color.White);

My label is rendered with '123', which suggests to me that the API is returning something that is NaN.

I've been unsuccessful finding example usages of these functions on the official documentation, you tube, or on stack overflow.

I assume I'm misusing the API, in that it's returning some sort of object or tuple with which I should be post-processing/de-structuring in some way.

Has anyone had success using these "Stock Fundamentals" API calls?

1 Answers1

0

Try it this way:

def opm = if IsNaN(OperatingProfitMargin()) then opm[1] else OperatingProfitMargin();

AddLabel(yes, "Op PM: " + opm, Color.WHITE);

leanne
  • 7,940
  • 48
  • 77