CurrencySnaphot how to convert getRate() to a price

Bob B's Avatar

Bob B

04 Jan, 2022 03:48 AM

I'm trying to get all the recorded prices for a security (CurrencyType). I iterate through all the snapshots from security.getSnapshots(). I can't figure out how to get the value that snapshot.getRate() returns converted to a dollars and cents value. I know I'm missing something fundamental but I don't know what it is.

Once I have that value, how do I adjust it for any splits so the price is shown relative to today's date once splits are accounted for.

Thanks for your help.

UPDATE: I figured it out, you have to divide 1 by the rate.

I'm using the following to get the split adjusted rate. Is this the best way to get it from a snap rate?

adjustedPrice = 1/security.adjustRateForSplitsInt(snap.getDateInt(), snap.getRate());
  1. Support Staff 1 Posted by Sean Reilly on 04 Jan, 2022 07:56 AM

    Sean Reilly's Avatar

    Hi Bob,

    You've got it exactly. I should also add that the snap.getRate() method will return the rate relative to the security's associated currency and not necessarily the base currency of the file.

    You might also be interested in this method which does most of the work for you:


    Sean Reilly
    Developer, The Infinite Kind

  2. 2 Posted by Bob B on 06 Jan, 2022 02:06 AM

    Bob B's Avatar

    Thanks very much

  3. Bob B closed this discussion on 27 Mar, 2022 08:29 PM.

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

Keyboard shortcuts


? 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