快照

當下證券、期貨及選擇權資訊。包含開盤價、最高價、最低價、收盤價、變動價、均價、成交量、總成交量、委買價、委買量、委賣價、委賣量和昨量。

In

contracts = [api.Contracts.Stocks['2330'],api.Contracts.Stocks['2317']]
snapshots = api.snapshots(contracts)
snapshots

Out

[
    Snapshot(
        ts=1589801466456000000, 
        code='2330', 
        exchange='TSE', 
        open=291.0, 
        high=293.5, 
        low=290.5, 
        close=292.5, 
        tick_type=<TickType.Buy: 'Buy'>, 
        change_price=-5.5, 
        change_rate=-1.84, 
        change_type=<ChangeType.Dowm: 'Dowm'>, 
        average_price=291.71, 
        volume=1, 
        total_volume=50850, 
        amount=292500, 
        total_amount=14833373000, 
        yesterday_volume=42298.0, 
        buy_price=292.0, 
        buy_volume=898.0, 
        sell_price=292.5, 
        sell_volume=1549, 
        volume_ratio=1.2
    ), 
    Snapshot(
        ts=1589801463015000000, 
        code='2317', 
        exchange='TSE', 
        open=76.6, 
        high=76.6, 
        low=74.9, 
        close=75.8, 
        tick_type=<TickType.Buy: 'Buy'>, 
        change_price=-1.3, 
        change_rate=-1.69, 
        change_type=<ChangeType.Dowm: 'Dowm'>, 
        average_price=75.68, 
        volume=2, 
        total_volume=39714, 
        amount=151600, 
        total_amount=3005477400, 
        yesterday_volume=46575.0, 
        buy_price=75.7, 
        buy_volume=185.0, 
        sell_price=75.8, 
        sell_volume=472, 
        volume_ratio=0.85
    )
]

轉成Dataframe

In

import pandas as pd
contracts = [api.Contracts.Stocks['2330'],api.Contracts.Stocks['2317']]
snapshots = api.snapshots(contracts)
df = pd.DataFrame(s.__dict__ for s in snapshots)
df

Out

ts code exchange open high low close tick_type change_price change_rate change_type avgerage_price volume total_volume amount total_amount yestoday_volume buy_price buy_volume sell_price sell_volume volume_ratio
0 2020-03-17 09:38:41.673000 2317 TSE 70.1 72.8 70 71.8 Sell 0.7 0.98 Up 71.13 16 21019 1148800 1495047800 65223 71.8 79 71.9 38 0.32
1 2020-03-17 09:38:41.045000 2330 TSE 265 276.5 265 273.5 Sell -3 -1.08 Dowm 269.39 32 38154 8752000 10278416500 103873 273.5 123 274 130 0.37

Attributes:

ts (int): 取得資訊timestamp.
code (str): 商品代碼
exchange (Exchange): 交易所.
open (float): 開盤價
high (float): 最高價
low (float): 最低價
close (float): 收盤價
tick_type (TickType): 收盤買賣別 {None, Buy, Sell}
change_price (float): 漲跌
change_rate (float): 漲跌幅
change_type (ChangeType): 漲跌 {LimitUp, Up, Unchanged, Dowm, LimitDown}
avgerage_price (float): 均價
volume (int): 單量
total_volume (int): 成交量
amount (int): 單量成交金額
total_amount (int): 成交金額
yestoday_volume (float): 昨量
buy_price (float): 委買價
buy_volume (float): 委買量
sell_price (float): 賣出價
sell_volume (int): 委賣量
volume_ratio (float): 昨量比