Skip to main content

Module util

Module util 

Source
Expand description

URL helpers, request headers, millify, display formatting, and column-name utilities.

Constants§

DEFAULT_TIMEOUT_SECS
Default HTTP timeout for screener POSTs (seconds).
DEFAULT_USER_AGENT
Default User-Agent for scanner POSTs.
MIN_STREAM_INTERVAL_SECS
Minimum stream refresh interval (seconds).
SCANNER_ORIGIN
Base URL for scan endpoints: {SCANNER_ORIGIN}/{subtype}/scan.
TRADINGVIEW_ORIGIN
Origin header value
TRADINGVIEW_REFERER
Referer header value (TRADINGVIEW_ORIGIN + trailing /).

Functions§

add_historical
Appends a historical lookback suffix
add_historical_to_label
Label for a historical column
add_rec
Recommendation companion column key
add_rec_to_label
Recommendation companion column label
format_recommendation
Formats a numeric recommendation as an arrow + letter (↑ B / ↓ S / - N).
format_row
Formats a ScreenerRow, optionally limiting to column_labels.
format_timed_field
Rewrites timed field names for the wire format
format_value
Formats one JSON cell for display; null becomes "--".
get_columns_to_request
Assembles (technical_name, label) pairs for a scan payload
get_recommendation
Maps a numeric rating to "S", "N", or "B"
get_url
Build the scan URL for a screener subtype ("crypto", "global", …).
is_status_code_ok
Returns true when status is in the HTTP 2xx range
millify
Format a magnitude with K / M / B / T suffixes and three decimal places
request_headers
HTTP headers for TradingView scanner POSTs.