Editing Valuation Code
There are two types of Valuations
  1. Your Custom Valuations, that you write.
  2. Default Valuations, that the application has by Default for demonstration purposes(such as The Dividend Discount Model).

We already saw how to apply a Default Valuation, so in this page we will walk through creating your own valuations.

Running our first Valuation Code

To apply a Valuation Method to a Stock, we need to go through some steps
We will run a very basic example of Code that prints "Hello World!" to the terminal:

  1. Head to the Valuation page.
  2. Copy and Paste the following Code:
  3. This is the base code template that we will be using in all valuations.
    Note: It uses the jQuery function "$.when().done();" to make sure that all financial data has been loaded and is ready for processing.
    The logic of the valuation model should be written between the brackets { }.
  1. In order for the Valuation Code to run, we need to specify which company we want to evaluate, by using the Ticker field.
    In the example below, we use "AAPL" for Apple Inc:
  2. Press Run and you should see the following output:
  3. (Optional) Hit the Save button to Save your code and give it an Unique name!
Retrieving Financial Data (in JSON format)

We have seen how to run a basic "Hello World!" printing program.
Next we will see how to retrieve the Financial Statements (Income Statement, Balance Sheet, Cash Flow) and more financial data.

  1. Start by running the following program

    This template retrieves ALL FINANCIAL DATA of a Company and the Treasury Rates.
    Note: To save time and resources, please request only the data that you use in your analysis.
    After finishing all requests, the data is returned in JSON format and stored in the args (arguments) of function().

    The table below describes where do functions store the returned values. Also there is a link to a JSON response for each element.
    Function Link to API (JSON)
    get_income_statement() Income Statement Annual
    get_income_statement_quarterly() Income Statement Quarterly
    get_income_statement_ltm() Income Statement LTM
    get_balance_sheet_statement() Balance Sheet Statement Annual
    get_balance_sheet_statement_quarterly() Balance Sheet Statement Quarterly
    get_cash_flow_statement() Cash Flow Statement Annual
    get_cash_flow_statement_quarterly() Cash Flow Statement Quarterly
    get_cash_flow_statement_ltm() Cash Flow Statement LTM
    get_quote() Stock Market Quotes
    get_profile() Company's Profile
    get_treasury() Treasury Rates
  2. Lets have a look at the output of the above Code for Ticker "AAPL"
  3. We can see the statements in JSON format printed to the terminal.
Implementing the Dividend Discount Model - DDM

We now know how to retrieve financial data and print it to the screen.
Lets process this data in order to implement a Valuation Method (The Dividend Discount Model) that outputs an intrinsic value of a company based on its Dividends.

  1. The following code implements the Dividend Discount Model by calculating the Average Dividend Growth Rate in the past YEARS (we can see the value of YEARS is 5 in the INPUTS section) and using that growth rate to estimate the value of next year's dividend.
    The constant growth rate for dividends in perpetuity is the Average Dividend Growth Rate but not higher than MAX_GROWTH_PERPETUITY (or 5%).
    Also, the company's cost of capital equity is defined by a REQUIRED_RATE_OF_RETURN of 0.1 (or 10%).

    For the code below, please perform the same steps as in our previous tutorials.

  2. Description:
    • nextDividend = lastDividend * (1 + Average Dividend Growth Rate) = the estimated value of next year’s dividend
    • REQUIRED_RATE_OF_RETURN = the company’s cost of capital equity
    • g = the constant growth rate for dividends, in perpetuity


    Feel free to modify the algorithm above to suit your own needs.
    This algorithm was made for illustration purposes to get you more familiar with the application.

    Disclaimer: Do not take any decisions based on the Algorithm above. Please do your own research as this is not investment advice!

  3. The output of the above Code for Ticker "T" (Company AT&T):

Next section is going to be about displaying results, tables and charts in the Valuation Tab, to better observe the data.