Skip to content

📦 SQA::Ticker

Description

sqa/lib/sqa/ticker.rb

Stock ticker symbol validation and lookup using the dumbstockapi.com service. Downloads and caches a CSV file containing ticker symbols, company names, and exchanges.

Source Information

Defined in: lib/sqa/ticker.rb:15

Inherits from: Object

🏭 Class Methods

.download(country = "US")

Downloads ticker data from dumbstockapi.com and saves to data directory.

Parameters

Name Type Description
country String Country code for ticker list (default: "US")

Returns

Type: Integer

HTTP status code from the download request

Usage Examples

SQA::Ticker.download("US")  # => 200
Source Location

lib/sqa/ticker.rb:31


.load()

Loads ticker data from cached CSV or downloads if not available. Retries download up to 3 times if no cached file exists.

Returns

Type: Hash{String => Hash}

Hash mapping ticker symbols to info hashes

Source Location

lib/sqa/ticker.rb:47


.load_from_csv(csv_path)

Loads ticker data from a specific CSV file.

Parameters

Name Type Description
csv_path Pathname, String Path to CSV file

Returns

Type: Hash{String => Hash}

Hash mapping ticker symbols to info hashes

Source Location

lib/sqa/ticker.rb:77


.data()

Returns the cached ticker data, loading it if necessary.

Returns

Type: Hash{String => Hash}

Hash mapping ticker symbols to info hashes

Source Location

lib/sqa/ticker.rb:92


.lookup(ticker)

Looks up information for a specific ticker symbol.

Parameters

Name Type Description
ticker String, nil Ticker symbol to look up

Returns

Type: Hash, nil

Hash with :name and :exchange keys, or nil if not found

Usage Examples

SQA::Ticker.lookup('AAPL')  # => { name: "Apple Inc", exchange: "NASDAQ" }
SQA::Ticker.lookup('FAKE')  # => nil
Source Location

lib/sqa/ticker.rb:106


.valid?(ticker)

Checks if a ticker symbol is valid (exists in the data).

Parameters

Name Type Description
ticker String, nil Ticker symbol to validate

Returns

Type: Boolean

true if ticker exists, false otherwise

Usage Examples

SQA::Ticker.valid?('AAPL')  # => true
SQA::Ticker.valid?(nil)     # => false
Source Location

lib/sqa/ticker.rb:120


.reset!()

Resets the cached ticker data. Useful for testing to force a fresh load.

Returns

Type: Hash

Empty hash

Source Location

lib/sqa/ticker.rb:129


📝 Attributes