Skip to content

Latest commit

 

History

History
102 lines (65 loc) · 2.79 KB

File metadata and controls

102 lines (65 loc) · 2.79 KB

API Reference — display/

Covers display/tables.py. All functions return Rich renderables — no computation, no API calls.


display/tables.py


render_slots

Description: Build the GE (Grand Exchange) Slots panel showing action advice for every active offer.

Arguments:

  • actions (list[SlotAction]): Slot actions from market.slots.get_slot_actions().
  • n_free (int): Number of free slots (shown in panel title).
  • total_slots (int): Total slot count. Default 8.
  • source_note (str): Data source description (e.g. "Flipping Utilities (3m old)"). Default "".
  • is_stale (bool): If True, the panel border turns red and a staleness warning is shown. Default False.

Returns: rich.panel.Panel.

Example:

from market.slots import get_slot_actions
from display.tables import render_slots
from rich.console import Console

actions, source, stale = get_slot_actions()
Console().print(render_slots(actions, n_free=3, source_note=source, is_stale=stale))

render_buy_candidates

Description: Build the Buy Candidates panel with entry price, units, cost, margin, and expected GP/day.

Arguments:

  • candidates (list[BuyCandidate]): Candidates to display (pre-sliced to desired length).
  • capital (float): Capital in GP (gold pieces; shown in panel title).

Returns: rich.panel.Panel. Returns an empty-state panel if candidates is empty.


render_opportunities

Description: Build a detailed Opportunities panel split into General (<5M/unit) and Expensive (≥5M/unit) price tiers.

Arguments:

  • candidates (list[BuyCandidate]): Full ranked candidate list (not pre-sliced).
  • top_n (int): Rows to show per tier. Default 10.

Returns: rich.panel.Panel.


render_study

Description: Build a Study panel with stats grid, ASCII sparkline, and external URLs for a single item.

Arguments:

  • s (StudyResult): Study result from market.study.get_study().

Returns: rich.panel.Panel.

Example:

from market.study import get_study
from display.tables import render_study
from rich.console import Console

result = get_study("dragon bones")
Console().print(render_study(result))

render_header

Description: Build the one-line status header showing time, capital, and free slot count.

Arguments:

  • capital (float): Capital in GP.
  • n_free (int): Free slot count.
  • total_slots (int): Total slot count.
  • now (datetime): Current time.

Returns: rich.text.Text.


render_countdown

Description: Build the countdown footer showing time until the next refresh.

Arguments:

  • next_run (float): Unix timestamp of the next scheduled fetch.

Returns: rich.text.Text.