Enhance ticker search and validation in "Convert to Trade" form (#688)

- Updated resolution logic to support combobox-based ticker selection and validation.
- Added market price display with validation against entered prices to detect significant mismatches.
- Improved messaging and UI for custom ticker input and market price warnings.

Co-authored-by: luckyPipewrench <luckypipewrench@proton.me>
This commit is contained in:
LPW
2026-01-17 16:46:15 -05:00
committed by GitHub
parent 47e0185409
commit 0f6dd536df
5 changed files with 184 additions and 32 deletions

View File

@@ -82,11 +82,13 @@ class Security::Resolver
filtered_candidates = filtered_candidates.select { |s| s.country_code.upcase.to_s == country_code.upcase.to_s }
end
# 1. Prefer exact exchange_operating_mic matches (if one was provided)
# 2. Rank by country relevance (lower index in the list is more relevant)
# 3. Rank by exchange_operating_mic relevance (lower index in the list is more relevant)
# 1. Prefer exact ticker matches (MSTR before MSTRX when searching for "MSTR")
# 2. Prefer exact exchange_operating_mic matches (if one was provided)
# 3. Rank by country relevance (lower index in the list is more relevant)
# 4. Rank by exchange_operating_mic relevance (lower index in the list is more relevant)
sorted_candidates = filtered_candidates.sort_by do |s|
[
s.ticker.upcase.to_s == symbol.upcase.to_s ? 0 : 1,
exchange_operating_mic.present? && s.exchange_operating_mic.upcase.to_s == exchange_operating_mic.upcase.to_s ? 0 : 1,
sorted_country_codes_by_relevance.index(s.country_code&.upcase.to_s) || sorted_country_codes_by_relevance.length,
sorted_exchange_operating_mics_by_relevance.index(s.exchange_operating_mic&.upcase.to_s) || sorted_exchange_operating_mics_by_relevance.length