Live feed¶
import briskapi
feed = briskapi.connect(site="demo", codes=["7203", "6758"]) # returns once initial state is in
toyota = briskapi.Ticker("7203")
toyota.quote() # current quote, updated as each frame arrives
toyota.auction() # indicative price/volume and market-order imbalance
feed.on_quote(lambda q: print(q["code"], q["indicative_price"]), codes="6758")
for q in feed.quotes("7203"): # one item per update; ends with the session
if q["last_price"]:
print("opened at", q["last_price"], q["time"])
break
briskapi.Market().imbalances(top=10).to_pandas()
feed.wait() # or feed.close(); `with briskapi.connect(...) as feed:` also works
briskapi.connect() takes a site, as brisk live --site does:
site="demo": the public BRiSK Next demo. It isn't a live connection: the demo site serves a recording of 27 September 2021 as files (BRiSK's decoder, the master, a snapshot and the stream), which are downloaded, checked against pinned hashes and replayed at their recorded pace (speed:1real time,0as fast as possible;limit_framesstops early).cache=DIRreplays a copy of those files downloaded before instead.site="sbi","e-shiten","matsui","monex"or"smbcnikko": your broker's live BRiSK (below).
Other options: codes, history=True (keep updates for Ticker.history()), upload,
output, on_day and gateway. Callbacks and iterators
first receive each security's current quote, then every update in order. A slow
consumer slows the feed instead of losing updates.