-
Notifications
You must be signed in to change notification settings - Fork 0
/
getStock2CSV.py
37 lines (25 loc) · 1 KB
/
getStock2CSV.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 13 21:39:24 2016
@author: Administrator
"""
import tushare as ts
import pandas as pd
import numpy as np
from pandas import DataFrame,Series
zz500s = ts.get_zz500s()
#==============================================================================
# for stock in zz500s['code']:
# hisdata = ts.get_hist_data(stock,start ='20140101' )
# hisdata.to_csv('D:\\pythonTest\\stockfile\\'+ stock + '.csv' )
#==============================================================================
stocklist = []
for stock in zz500s['code']:
hisdata = ts.get_hist_data(stock,start ='2016-04-01')
if (abs(hisdata['close']-hisdata['ma5'])/hisdata['ma5']<0.02).all() \
and (hisdata['ma5'] > hisdata['ma10']).all() \
and (hisdata['ma10'] > hisdata['ma20']).all() \
and (abs(hisdata['high']-hisdata['close'])/hisdata['close']<0.02).all():
stocklist.append(stock)
print stock
print stocklist