In [25]:
# -*- coding:utf-8 -*-
import tushare as ts
import matplotlib.pyplot as plt
#import matplotlib.finance as mpf
import mpl_finance as mpf
import matplotlib.ticker as ticker

import datetime
import numpy as np
import pandas as pd
import time
from pyecharts import Kline

def n_days_ago(n):
	#now=datetime.now()
	today=datetime.date.today()
	#print("Now:\n"+str(today))
	ndays_ago=today-datetime.timedelta(n)
	#print(str(n)+" days ago:\n"+str(ndays_ago))
	return str(ndays_ago)

In [26]:
start_date = '2018-07-01'
now = int(time.time())
timeArray = time.localtime(now)
Time = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
end_date =  Time 
start_date = n_days_ago(90)
stock_selected = '600487'

In [27]:
df = ts.get_k_data(stock_selected,start_date,end_date)
array_df = np.array(df[['open','close','high','low']])
v_kline = np.array(df[['open','close','high','low']])
date_kline = []
for i,j in enumerate(np.array(df[['date']])):
    #print(j)
    temp_str = str(j[0]).replace('-0','/')
    date_kline.append(temp_str.replace('-','/'))

In [37]:
kline = Kline("K 线图示例")
kline.add("日K",
          date_kline,
          v_kline,
          mark_point=["max",'min'],
          mark_line=["max"],
          is_datazoom_show=True,)
#kline.render()


Out[37]:

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]: