import pandas as pd
import numpy as np
from pandas_datareader import data as web
start = '2015-03-02'
end = '2015-03-31'
ssec2015 = web.get_data_yahoo('000001.SS', start, end)
from matplotlib.dates import DateFormatter,WeekdayLocator, DayLocator,MONDAY,date2num
from datetime import datetime
ssec2015.date=[date2num(datetime.strptime(date,"%Y-%m-%d")) for date in ssec2015.date]
ssec15 = ssec2015.iloc[:,:4]
ssec15['date']=ssec15.index
ssec15list= list()
for i in range (len(ssec15)):
ssec15list.append(ssec15.iloc[i,:])
import datetime
import matplotlib.pyplot as plt
import mpl_finance
from mpl_finance import candlestick_ohlc
import jqdatasdk
ax=plt.subplot()
mondays=WeekdayLocator(MONDAY)
weekFormatter = DateFormatter('%y-%m-%d')
ax.xaxis.set_major_locator(mondays)
ax.xaxis.set_minor_locator(DayLocator())
ax.xaxis.set_major_formatter(weekFormatter)
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus']=False
ax.set_title("上证综指2015年3月份K线图")
candlest
#记录 K线
最新推荐文章于 2021-01-31 19:06:28 发布
本文介绍如何利用Python编程抓取并分析2012年上证综指日交易数据,聚焦于识别'早晨之星'的K线形态。通过计算收盘价与开盘价差值,确定绿色实体、十字星和红色实体,并定义下跌趋势,最终自动检测出'早晨之星'组合。
摘要由CSDN通过智能技术生成