#!/usr/bin/env python

global moneydance  # Entry point into the Moneydance API
mdGUI = moneydance.getUI()  # Entry point into the GUI
book = moneydance.getCurrentAccountBook()  # Entry point into your dataset
root = moneydance.getCurrentAccount()

currencies = book.getCurrencies()

def setPriceForSecurity(symbol, price, dateint):
    price = 1.0 / price
    security = currencies.getCurrencyByTickerSymbol(symbol)
    if not security:
        print("No security with symbol/name: %s" %(symbol))
        return
    if dateint:
        security.setSnapshotInt(dateint, price).syncItem()
    security.setUserRate(price)
    security.syncItem()
    print("Successfully set price for %s" % (security))


setPriceForSecurity('AAPL', 219.9175, 20060403)
setPriceForSecurity('DNA', 75.8455, 20060403)
