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
t = pd.DataFrame({'a': range(0, 10000), 'b': range(10000, 20000)}) | |
B = [] | |
C = [] | |
A = time.time() | |
for i,r in t.iterrows(): | |
C.append((r['a'], r['b'])) | |
B.append(time.time()-A) | |
C = [] | |
A = time.time() |
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
tushare 数据规整画图 | |
from matplotlib.pylab import date2num | |
import datetime | |
# 对tushare获取到的数据转换成candlestick_ohlc()方法可读取的格式 | |
data_list = [] | |
hist_data = ts.get_hist_data('600199') | |
for dates,row in hist_data.iterrows(): | |
# 将时间转换为数字 | |
date_time = datetime.datetime.strptime(dates,'%Y-%m-%d') |
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
import pandas as pd | |
from pandas import DataFrame | |
fro WindPy import * | |
w.start | |
### | |
t1=w.wset('sectorconstituent','date=20170501;sector=全部A股') | |
a=DataFrame({'code':t1.Data[1],'name':t1.Data[2]}) | |
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
>>> keys = ['a', 'b', 'c'] | |
>>> values = [1, 2, 3] | |
>>> dictionary = dict(zip(keys, values)) | |
>>> print(dictionary) | |
{'a': 1, 'b': 2, 'c': 3} |
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
from WindPy import * | |
import pandas as pd | |
from pandas import DataFrame | |
w.start() | |
all_data={} | |
a=w.weqs('tp') | |
for ticker in a.Data[0]: | |
all_data[ticker]=w.wsd(ticker,'close','20170101') | |
price=DataFrame({tic:data.Data[0] for tic,data in all_data.items()},index=all_data[next(iter(all_data))].Times) # next (iter(my_dict))get firt key of a dict |
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
import WindPy | |
from WindPy import * | |
import pandas as pd | |
from pandas import DataFrame | |
w.start() | |
all_data={} | |
a=w.weqs('tp') | |
for ticker in a.Data[0]: | |
all_data[ticker]=w.wsd(ticker,'close','20170101') |
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
#coding:utf-8 | |
import tushare as ts | |
import pynance as pn | |
ticker=input('input your ticker:') | |
t=ts.get_k_data(ticker) | |
x=t.set_index('date')#设置日期为索引 | |
x.index=x.index.to_datetime()#将索引转为日期格式 | |
x.index.names=['Date']#为索引指定名称 |
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
# -*- coding:utf-8 -*- | |
# Author:jqzhang | |
# Editdate:2015-12-21 | |
from WindPy import w | |
import pymssql | |
from datetime import datetime | |
server = 'WIND-PUB010\SQLEXPRESS' | |
user = 'jqzhang' | |
password = 'wind' |
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
import pandas as pd | |
import matplotlib.pyplot as plt | |
import matplotlib | |
matplotlib.style.use('ggplot') ## 采用ggplot格式 |
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亿之间的个股 |
OlderNewer