2024-10-30 18:08:19 -04:00
|
|
|
class FetchSecurityInfoJob < ApplicationJob
|
2025-01-24 13:39:08 -05:00
|
|
|
queue_as :latency_low
|
2024-10-30 18:08:19 -04:00
|
|
|
|
|
|
|
def perform(security_id)
|
|
|
|
return unless Security.security_info_provider.present?
|
|
|
|
|
|
|
|
security = Security.find(security_id)
|
|
|
|
|
2025-02-11 10:40:30 -06:00
|
|
|
params = {
|
|
|
|
ticker: security.ticker
|
|
|
|
}
|
|
|
|
params[:mic_code] = security.exchange_mic if security.exchange_mic.present?
|
|
|
|
params[:operating_mic] = security.exchange_operating_mic if security.exchange_operating_mic.present?
|
|
|
|
|
|
|
|
security_info_response = Security.security_info_provider.fetch_security_info(**params)
|
2024-10-30 18:08:19 -04:00
|
|
|
|
|
|
|
security.update(
|
2024-11-07 11:52:16 -06:00
|
|
|
name: security_info_response.info.dig("name")
|
2024-10-30 18:08:19 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|