Stocks Module Reference

New in version 0.0.6.

Control the macOS Stocks application using JXA-like syntax.

Classes:

XAStocksApplication(properties)

A class for managing and interacting with Stocks.app.

XAStocksSavedStock(properties)

A class for interacting with stocks in Stocks.app.

XAStocksSavedStockList(properties[, filter])

A wrapper around a list of stocks.

class PyXA.apps.Stocks.XAStocksApplication(properties)[source]

Bases: XAApplication

A class for managing and interacting with Stocks.app.

New in version 0.0.6.

Methods:

go_back()

Clicks the 'back' button (from a new article when viewed in the Stocks app).

new_tab()

Opens a new tab.

saved_stocks()

Gets a list of stocks.

show_business_news()

Shows the 'Business News' tab in the front stock window.

show_symbol(ticker)

Displays the page for the specified ticker symbol.

Attributes:

sidebar_showing

Whether the sidebar is currently showing.

go_back() XAStocksApplication[source]

Clicks the ‘back’ button (from a new article when viewed in the Stocks app).

Returns:

A reference to the application object

Return type:

XAStocksApplication

New in version 0.0.6.

new_tab()[source]

Opens a new tab.

New in version 0.0.6.

saved_stocks() XAStocksSavedStockList[source]

Gets a list of stocks.

Returns:

The list of stocks

Return type:

XAStocksStockList

New in version 0.0.6.

show_business_news() XAStocksApplication[source]

Shows the ‘Business News’ tab in the front stock window.

Returns:

A reference to the application object

Return type:

XAStocksApplication

New in version 0.0.6.

show_symbol(ticker: str) XAStocksApplication[source]

Displays the page for the specified ticker symbol.

Parameters:

ticker (str) – The ticker symbol for the desired stock

Returns:

A reference to the application object

Return type:

XAStocksApplication

New in version 0.0.6.

property sidebar_showing: bool

Whether the sidebar is currently showing.

class PyXA.apps.Stocks.XAStocksSavedStock(properties)[source]

Bases: XAObject, XAClipboardCodable

A class for interacting with stocks in Stocks.app.

New in version 0.0.6.

Attributes:

change

The percentage or point change of the stock in the current trading session.

name

The name of the stock (The company name).

price

The current price of the stock.

properties

All properties of the stock.

selected

Whether the stock is the currently selected stock.

symbol

The symbol for the stock.

Methods:

get_clipboard_representation()

Gets a clipboard-codable representation of the stock.

show()

Shows the stock's tab in the front stock window.

property change: str

The percentage or point change of the stock in the current trading session.

get_clipboard_representation() list[str | NSURL][source]

Gets a clipboard-codable representation of the stock.

When the clipboard content is set to a saved stock, the stocks’s name, price, and stocks URI are added to the clipboard.

Returns:

The stock’s name, price, and stocks URI

Return type:

list[Union[str, NSURL]]

New in version 0.0.8.

property name: str

The name of the stock (The company name).

property price: float

The current price of the stock.

property properties: dict

All properties of the stock.

property selected: bool

Whether the stock is the currently selected stock.

show()[source]

Shows the stock’s tab in the front stock window.

New in version 0.0.6.

property symbol: str

The symbol for the stock.

class PyXA.apps.Stocks.XAStocksSavedStockList(properties: dict, filter: dict | None = None)[source]

Bases: XAList, XAClipboardCodable

A wrapper around a list of stocks.

New in version 0.0.6.

Methods:

change()

get_clipboard_representation()

Gets a clipboard-codable representation of each stock in the list.

name()

price()

properties()

selected()

symbol()

change() list[str][source]
get_clipboard_representation() list[str | NSURL][source]

Gets a clipboard-codable representation of each stock in the list.

When the clipboard content is set to a list of saved stocks, each stocks’s name, price, and stocks URI are added to the clipboard.

Returns:

Each stock’s name, price, and stocks URI

Return type:

list[Union[str, NSURL]]

New in version 0.0.8.

name() list[str][source]
price() list[str][source]
properties() list[str][source]
selected() list[str][source]
symbol() list[str][source]