Skip to content

Commit

Permalink
Fix for certain securities returning incorrect prices
Browse files Browse the repository at this point in the history
  • Loading branch information
Shpigford committed Nov 7, 2024
1 parent 154a1a9 commit 31d9d92
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 1 addition & 3 deletions app/jobs/fetch_security_info_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ def perform(security_id)
)

security.update(
name: security_info_response.info.dig("name"),
exchange_acronym: security_info_response.info.dig("exchange", "acronym"),
country_code: security_info_response.info.dig("exchange", "country_code")
name: security_info_response.info.dig("name")
)
end
end
5 changes: 3 additions & 2 deletions app/models/account/trade_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ def create_entry
end

def security
ticker_symbol, exchange_mic = ticker.split("|")
ticker_symbol, exchange_mic, exchange_acronym, exchange_country_code = ticker.split("|")

security = Security.find_or_create_by(ticker: ticker_symbol, exchange_mic: exchange_mic)
security = Security.find_or_create_by(ticker: ticker_symbol, exchange_mic: exchange_mic, country_code: exchange_country_code)
security.update(exchange_acronym: exchange_acronym)

FetchSecurityInfoJob.perform_later(security.id)

Expand Down
3 changes: 2 additions & 1 deletion app/models/provider/synth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ def search_securities(query:, dataset: "limited", country_code:)
name: security.dig("name"),
logo_url: security.dig("logo_url"),
exchange_acronym: security.dig("exchange", "acronym"),
exchange_mic: security.dig("exchange", "mic_code")
exchange_mic: security.dig("exchange", "mic_code"),
exchange_country_code: security.dig("exchange", "country_code")
}
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/security/synth_combobox_option.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Security::SynthComboboxOption
include ActiveModel::Model
include Providable

attr_accessor :symbol, :name, :logo_url, :exchange_acronym, :exchange_mic
attr_accessor :symbol, :name, :logo_url, :exchange_acronym, :exchange_mic, :exchange_country_code

class << self
def find_in_synth(query)
Expand All @@ -18,7 +18,7 @@ def find_in_synth(query)
end

def id
"#{symbol}|#{exchange_mic}" # submitted by combobox as value
"#{symbol}|#{exchange_mic}|#{exchange_acronym}|#{exchange_country_code}" # submitted by combobox as value
end

def to_combobox_display
Expand Down

0 comments on commit 31d9d92

Please sign in to comment.