Extracting stock prices from current book

hal's Avatar

hal

01 Jun, 2019 06:55 AM

I am writing an extension to extract stock prices from a Moneydance dataset. The object is to achieve the opposite of the example set_prices.py script available from the developer page.

My code is pasted below.

Can someone help with what is the correct attribute word to extract the price of a security on a given date (date entered as an int)? I cannot find any reference to help within the IK developer reference area.

Thanks
=================
book = moneydance.getCurrentAccountBook()
currencies = book.getCurrencies()

def getSecurityPrice(symbol,dateint):
  security = currencies.getCurrencyByTickerSymbol(symbol)
  if not security:
    print "No security with symbol/name: %s"%(symbol)
    return
  if dateint:
    print(dateint) # just for testing
# In next line, none of 'price', 'value', 'close' attribute words work
    thisprice = security.price(dateint) # This is where the correct price attribute of security is need to extract the price or 1/price
# thisprice = 1/thisprice # sort this and currency arithmetic after a valid price value is extracted in previous line
    print "Successfully retrieved price for security for: %s"%(symbol)
    print "Print retrieved price here: nn.nnnn"

getSecurityPrice('AAPL',20190531)
getSecurityPrice('WAB',20190531)
getSecurityPrice('XXXX',20180531) # deliberate error in code
getSecurityPrice('F',20190531)

  1. System closed this discussion on 31 Aug, 2019 07:00 AM.

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