Skip to content

briskapi.connect

Python · CLI

Start a live feed and make it the default source for Ticker and Market, from a site, as brisk live --site does. site="demo" is the public BRiSK Next demo: not a live connection but a recording of 27 September 2021 that the demo site serves as files, downloaded, checked against pinned hashes and replayed at its recorded pace; cache=DIR replays a copy of those files downloaded before. site="sbi", "e-shiten", "matsui", "monex" or "smbcnikko" is your broker's live BRiSK (below). A complete session is uploaded to your private archive unless you opt out; output also keeps it on disk. On the command line: brisk live (see Recording).

Parameters

site str required

"demo", or "sbi", "e-shiten", "matsui", "monex" or "smbcnikko": your broker's live BRiSK, signing in as login does unless it already has.

codes list[str] | None optional

Securities to decode (default: the whole market).

history bool optional = False

Keep every update and trade, for Ticker.history() and .trades().

upload bool | None optional

False uploads nothing; None follows your choice (on by default).

output str | Path | None optional

Also keep each recording here (a broker's day comes as several), as SOURCE_YYYYMMDD_FROM-TO.

on_day Callable | None optional

Called with each recording's result (kept, uploaded).

gateway bool optional = False

Also serve the feed to briskapi.Live() on this computer (brisk live does by default).

timeout float | None optional

Seconds to wait for the initial state (default 60, or 120 for a broker; a broker feed with no session to join waits for the next trading day's).

cache str | Path | None optional

The demo from a copy of its files downloaded before (default: download them).

speed float optional = 1

The demo's replay speed: 1 is the recorded pace, 0 as fast as possible.

limit_frames int | None optional

Stop the demo after this many frames (a partial replay is never uploaded).

trace_protocol bool optional = False

A broker's connection steps on stderr, tokens redacted.

profile dict | None optional

A broker connection's unverified Socket.IO parameters.

upload_market_data bool | None optional

False uploads a broker session's timing summary but not its market recording.

Returns

Feed

A Feed, already holding every selected security's state.

API method
briskapi.connect(
    *,
    site: str,                              # "demo", or a broker: "sbi", ...
    codes: list[str] | None = None,
    history: bool = False,
    upload: bool | None = None,
    output: str | Path | None = None,
    on_day: Callable | None = None,
    gateway: bool = False,
    timeout: float | None = None,
    node: str = "node",
    cache: str | Path | None = None,        # the demo
    speed: float = 1,                       # the demo
    limit_frames: int | None = None,        # the demo
    trace_protocol: bool = False,           # a broker
    profile: dict | None = None,            # a broker
    upload_market_data: bool | None = None,  # a broker
) -> Feed
Example usage
1
2
3
4
5
6
import briskapi

feed = briskapi.connect(site="demo", codes=["7203"], upload=False)
print(feed)
print(briskapi.Ticker("7203").quote()["indicative_price"])
feed.close()
brisk live --site demo --codes 7203 --no-upload --quotes   # one JSON line per quote update
Example response (Python)Captured from the demo
Feed(status='running', seq=0)
10150.0