Add security prices provider (Synth integration) #1039
Reference in New Issue
Block a user
Delete Branch "1036-incorporate-daily-security-prices-from-synth-into-new-holdings-view"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A basic implementation of security price fetching from our "default" data provider, Synth.
A lot of the code here is intentionally left with some duplication as we implement more and more Synth endpoints and incorporate more providers. Eventually we'll need to consolidate and refactor provider logic.
Major changes here include:
tickerrather thanisinto identify a security internallyfetch_security_pricesmethod toSynthwith pagination support for fetching multiple prices at once (1 Synth credit used per "group" rather than per securities price)@@ -35,3 +33,3 @@# Run tests in parallel with specified workersparallelize(workers: :number_of_processors) unless ENV["DISABLE_PARALLELIZATION"]parallelize(workers: :number_of_processors) unless ENV["DISABLE_PARALLELIZATION"] == "true"Previously, I had removed dotenv from the test environment entirely to avoid "mystery guest" values and keep test configurations transparent for new contributors. Now that we're starting to introduce more data providers which require live api keys to generate VCR cassettes, I think the
.env.teststrategy (as outlined in the dotenv-rails docs below) is a good compromise.Everything after the
require_relative "../config/environment"is the "default" value, while thewith_env_overridehelper method can override these defaults on a per-test basis.@@ -0,0 +4,4 @@remove_column :securities, :isin, :stringrename_column :security_prices, :isin, :tickerendendThis is largely a simplification of how we identify securities internally. My original thinking was that
isincodes would provide globally unique identification for securities and help us avoid duplicates, but after doing some research on various data providers, this is not viable.For example, Plaid provides an
isincode for each security, while Polygon (a popular stock price provider) doesn't provide an isin code at all. Instead, it provides a FIGI code, which is the new globally unique identifier standard for all types of financial instruments that is not subject to change when a company reclassifies, splits, moves exchanges, etc. (isin can change in rare cases).While a "ticker" symbol isn't globally unique, it fits our domain model well. Each ticker represents a company + exchange pair, which results in a unique price.
@zachgoll great work here! In case you're wondering (you may have already figured this out) this was put in place to have a single point of extension to stub responses for all providers, since these tests will eventually be shared across them.
All good removing, and all good to never bring it back. Just realized it may not be obvious so thought I'd point it out.
@josefarias ahh, good callout! Was this the direction you were thinking?
Yes! Something like that
@@ -0,0 +4,4 @@remove_column :securities, :isin, :stringrename_column :security_prices, :isin, :tickerendendThe main issue is that tickers are for specific companies. All ETF and active funds will have an ISIN instead.
Tickers are useful but ISIN are the standard for looking up values of an investment and are widely available on the Key Investor Information or popular web sites such as morningstar.
Without the ISIN, how will you add investments which are not companies?