Created
February 1, 2019 03:39
-
-
Save dear983604/8ab94ae26dd8aa0f80e8a6e834424a45 to your computer and use it in GitHub Desktop.
Modify KD parameter and evaluate the results
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#導入套件 | |
%matplotlib inline | |
import datetime | |
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
#專門做『技術分析』的套件 | |
from talib import abstract | |
#專門抓台股的套件 | |
import twstock | |
#設定爬蟲股票代號 | |
sid = '2330' | |
data=twstock.Stock(sid) | |
#用fetch_from抓取資料,指定日期放入dataframe裡 | |
df = pd.DataFrame(data.fetch_from(2018,1)) | |
#設定index | |
df.set_index('date', inplace = True) | |
#畫技術指標-KD值 | |
abstract.STOCH(df).plot(figsize=(16,8)) | |
#顯示KD裡的資料內容 | |
abstract.STOCH(df).tail(10) | |
#查詢指標內的參數預設值 | |
print(abstract.STOCH) | |
#修改參數數值 | |
abstract.STOCH(df,fastk_period=9, slowk_period=3,slowd_period=3).tail(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment