Snapshot
Snapshot is a present stock, future, option info. It contain open, high, low, close, change price, average price, volume, total volume, buy price, buy volume, sell price, sell volume and yestoday volume.
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
)
]
To 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): Contract id.
exchange (Exchange): Attributes of industry.
open (float): open
high (float): high
low (float): low
close (float): close
tick_type (TickType): Close is buy or sell price.
{None, Buy, Sell}
change_price (float): change price.
change_rate (float): change rate.
change_type (ChangeType):
{LimitUp, Up, Unchanged, Dowm, LimitDown}
avgerage_price (float): avgerage of price.
volume (int): volume.
total_volume (int): total volume.
amount (int): Deal amount.
total_amount (int): Total deal amount.
yestoday_volume (float): Volume of yestoday.
buy_price (float): Price of buy.
buy_volume (float): Volume of sell.
sell_price (float): Price of sell.
sell_volume (int): Volume of sell.
volume_ratio (float): total_volume/yestoday_volume.