Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Net::ReadTimeout (MAYBE-MARKETING-3Q) #267

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions app/models/provider/synth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,15 @@ def recent_insider_trades(filters = {})
def fetch_stock_prices(ticker:, start_date:, end_date:, interval: "day", limit: 100)
HTTParty.get "#{BASE_URL}/tickers/#{ticker}/open-close",
query: { start_date: start_date.to_s, end_date: end_date.to_s, interval: interval, limit: limit },
headers: { "Authorization" => "Bearer #{api_key}", "X-Source" => "maybe_marketing", "X-Source-Type" => "api" }
headers: { "Authorization" => "Bearer #{api_key}", "X-Source" => "maybe_marketing", "X-Source-Type" => "api" },
timeout: 15
end

def fetch_exchange_rate(from_currency:, to_currency:)
HTTParty.get "#{BASE_URL}/rates/live",
query: { from: from_currency, to: to_currency },
headers: default_headers
headers: default_headers,
timeout: 15
end

def fetch_exchange_rates(from_currency:, to_currency:, start_date:, end_date:)
Expand All @@ -178,7 +180,8 @@ def fetch_exchange_rates(from_currency:, to_currency:, start_date:, end_date:)
date_start: start_date.to_s,
date_end: end_date.to_s
},
headers: default_headers
headers: default_headers,
timeout: 15
end

def fetch_insider_trades(ticker:, start_date:, end_date:, limit: 100)
Expand All @@ -194,7 +197,8 @@ def fetch_insider_trades(ticker:, start_date:, end_date:, limit: 100)

HTTParty.get url,
query: query,
headers: default_headers
headers: default_headers,
timeout: 15
end

def fetch_recent_insider_trades(**filters)
Expand All @@ -207,7 +211,8 @@ def fetch_recent_insider_trades(**filters)

HTTParty.get url,
query: query_params,
headers: default_headers
headers: default_headers,
timeout: 15
end

def default_headers
Expand Down
Loading