Created
May 16, 2017 07:15
-
-
Save adxrgh/df585071ade232fd316599e52d408aaf to your computer and use it in GitHub Desktop.
[pn.ts.selected candles chart]
This file contains 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 matplotlib.pyplot as plt | |
import numpy as np | |
import pandas as pd | |
import tushare as ts | |
import pynance as pn | |
from pandas import DataFrame,Series | |
a=ts.get_today_all() | |
b=a[(a.nmc>5e+5)&(a.nmc<15e+5)&(a.changepercent>5)&(a.turnoverratio>2)]# 涨幅大于5%且自由流通市值在50到150亿之间的个股 | |
c=b.sort_values('changepercent',ascending=False)#按照涨跌幅排序 | |
all_data={} | |
x=[] | |
for ticker in c.code: | |
all_data[ticker]=ts.get_k_data(ticker,start='2017-01-01',end='2017-05-15') | |
for i in range(len(all_data)): | |
t=all_data.values()[i].set_index('date') | |
t.index=t.index.to_datetime() | |
t.index.names=['Date'] | |
t.volume=t.volume.astype(int) | |
t.rename(columns={'volume':'Volume'},inplace=True) | |
x.append(t) | |
for o in range(len(x)): | |
n=x[o][['open','high','low','close','Volume']] | |
pn.chart.candlestick(n,title=x[o]['code'][0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment