Skip to main content

台灣上市股票價格擷取(Fetch TWSE stock data)含即時盤、台灣時間轉換、開休市判斷。

Project description

主要開發擷取台灣股市(TWSE)股價資料,資料來源 證券交易所網站

版本資訊

Authors:

Toomore Chiang

Version:

0.0.1x of 2012/03/18

Python Version:

Python 2.6-2.7

Report Issue or get involved

Web Demo

Quick Start

簡單計算

from grs import stock

g = stock(2618)        # 擷取長榮航股價
print g.MA(5)          # 計算五日均價與持續天數
print g.MAV(5)         # 計算五日均量與持續天數

擷取 12 個月份資料

g = stock(2618, 12)

輸出 CSV 檔

g.out_putfile('/dev/shm/2618.csv')

其他功能

顯示台灣時間:TWTime

適用於其他時區查詢台灣當地時間。

from grs import TWTime

t = TWTime()
t.now                   # 顯示台灣此刻時間
t.localtime             # 顯示當地此刻時間

判斷台灣股市是否開市:twseopen

from grs import twseopen
from datetime import datetime

t = twseopen()

t.Dday(datetime.today())        # 判斷今天是否開市,回傳 True or False
t.Dday(datetime(2012, 12, 22))  # 判斷 2012/12/22 是否開市

各股即時盤資訊:rt_stock

from grs import rt_stock

rl = rt_stock(2618)       # 擷取長榮航即時股價
rl.raw                    # 原始資料
rl.real                   # 回傳 type: dict(如下表)
name:

股票名稱 Unicode

no:

股票代碼

range:

漲跌價

ranges:

漲跌判斷 True, False

time:

取得時間

max:

漲停價

min:

跌停價

unch:

昨日收盤價

pp:

漲跌幅 %

o:

開盤價

h:

當日最高價

l:

當日最低價

c:

成交價/收盤價

value:

累計成交量

pvalue:

該盤成交量

top5buy:

最佳五檔買進價量資訊

top5sell:

最佳五檔賣出價量資訊

crosspic:

K線圖 by Google Chart

大盤即時盤資訊:rt_weight

from grs import rt_weight

w = rt_weight()            # 擷取即時大盤資訊
w.raw                      # 原始檔案
w.real                     # 回傳 type: dict(如下表)

原始檔案包含其他資訊請參閱 對照表

no:

編號

date:

日期

time:

時間

c:

加權指數

value:

成交金額(億)

range:

漲跌指數

ud:

回傳漲(True)、跌(False)

單日倒數時間:Countdown

適用於設定 cache 時間。

from grs import Countdown

c = Countdown(h=14, m=30)  # 預設為 14:30
c.nextday                  # 下一個 14:30 日期
c.countdown                # 到數秒數
c.exptime                  # 下一個 14:30 日期時間(type: datetime)
c.lastmod                  # 前一個 14:30 日期時間(type: datetime)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grs-0.0.1a0318.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

grs-0.0.1a0318-py2.7.egg (19.7 kB view details)

Uploaded Egg

File details

Details for the file grs-0.0.1a0318.tar.gz.

File metadata

  • Download URL: grs-0.0.1a0318.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for grs-0.0.1a0318.tar.gz
Algorithm Hash digest
SHA256 275264401cfffa5297d53c9217af4779176e93a4da074d05a159819ec892b344
MD5 e7c07c37c329f3e8e6042eba60cc92da
BLAKE2b-256 ac63d7632e9842230a5cf03fca1ca3d4179d2b83f3d50d51d2d25dbf8f3ecc14

See more details on using hashes here.

File details

Details for the file grs-0.0.1a0318-py2.7.egg.

File metadata

  • Download URL: grs-0.0.1a0318-py2.7.egg
  • Upload date:
  • Size: 19.7 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for grs-0.0.1a0318-py2.7.egg
Algorithm Hash digest
SHA256 e9a0158792b41a34ce2d48adbda946bdf7f8e9720cc1f6305091d9acdca80fb2
MD5 bfbb06793964d3447111cdf8dc753aa4
BLAKE2b-256 f2655333428bd92b04849b6fb85306bbcf2d7204d1ac221d59ede54bca6c2ccc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page