mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-05 05:25:24 +02:00
Add security prices provider (Synth integration) (#1039)
* User tickers as primary lookup symbol instead of isin * Add security price provider * Fetch security prices in bulk to improve sync performance * Fetch prices in bulk, better mocking for tests
This commit is contained in:
parent
c70c8b6d86
commit
453a54e5e6
33 changed files with 584 additions and 118 deletions
|
@ -29,7 +29,7 @@ module Account::EntriesTestHelper
|
|||
end
|
||||
|
||||
def create_trade(security, account:, qty:, date:, price: nil)
|
||||
trade_price = price || Security::Price.find_by!(isin: security.isin, date: date).price
|
||||
trade_price = price || Security::Price.find_by!(ticker: security.ticker, date: date).price
|
||||
|
||||
trade = Account::Trade.new \
|
||||
qty: qty,
|
||||
|
|
|
@ -1,16 +1,9 @@
|
|||
module SecuritiesTestHelper
|
||||
def create_security(symbol, prices:)
|
||||
isin_codes = {
|
||||
"AMZN" => "US0231351067",
|
||||
"NVDA" => "US67066G1040"
|
||||
}
|
||||
|
||||
isin = isin_codes[symbol]
|
||||
|
||||
def create_security(ticker, prices:)
|
||||
prices.each do |price|
|
||||
Security::Price.create! isin: isin, date: price[:date], price: price[:price]
|
||||
Security::Price.create! ticker: ticker, date: price[:date], price: price[:price]
|
||||
end
|
||||
|
||||
Security.create! isin: isin, symbol: symbol
|
||||
Security.create! ticker: ticker
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue