📦 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.
🏭 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
Source Location
.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
.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
.data()¶
Returns the cached ticker data, loading it if necessary.
Returns
Type: Hash{String => Hash}
Hash mapping ticker symbols to info hashes
Source Location
.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
Source Location
.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
Source Location
.reset!()¶
Resets the cached ticker data. Useful for testing to force a fresh load.
Returns
Type: Hash
Empty hash