How to access the "Current Price" field in the "Currency/Security History" dialog

md_oz's Avatar

md_oz

21 Jan, 2018 01:24 PM

I am building a script to dump all securities to a file, but I can't determine how to get the "Current Price" field that is visible in the "Currency/Security History" dialog. Can you point me in the right direction?

The code I have so far is (see attachment for proper formatting):

import json


def dump_symbol_attributes(filename): output = []

for currency in currencies:
    out_dict = {}
    keys = currency.getParameterKeys()
    for key in keys:
        out_dict[key] =  currency.getParameter(key)
    if "ticker" in out_dict.keys(): #keep only securities
        output += [out_dict]
    else:
        pass
    print out_dict

with open(filename, "w") as file:
     file.write(json.dumps(output))

return output



if name == "main": filename = "location where output file is saved" print dump_symbol_attributes(filename)
  1. 1 Posted by md_oz on 21 Jan, 2018 01:26 PM

    md_oz's Avatar

    Sorry I truncated the code block and file. The correct file is attached

  2. 2 Posted by md_oz on 21 Jan, 2018 02:37 PM

    md_oz's Avatar

    The Current Price value appears to be represented by the rate field in the output file (which can also be accessed by getRawRate()).

    The Current Price can be calculated by:

    Current_Price = 100 / rate

    I attached my final code for reference.

  3. 3 Posted by md_oz on 21 Jan, 2018 08:20 PM

    md_oz's Avatar

    I was a little premature on my last post. If the security currency is different from the base currency, the method suggested above is invalid.

    So my original question remains, how do a get the displayed Current Price in the currency of the security?

    Thank you

  4. System closed this discussion on 22 Apr, 2018 08:20 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac