Ejemplo n.º 1
0
def cal(code):
	try:
		a=gc.getData(code)
	except:
		print('{} is wrong'.format(code))	
	else:	
		print('{} is running'.format(code))
		if a is not None and len(a)>60:
			global total
			total=total+1
			a.sort_index(inplace=True)
			gc.ma(a,'close',[5,10,15,20,25])
			MA_column=a.columns[-5:]
			a['Diff']= 100 * ((a[MA_column].max(axis=1) - a[MA_column].min(axis=1))/a[MA_column].max(axis=1))
			b=a[-65:-5]['Diff'].mean()
			if b<2 and a[-65:-5]['Diff'].max()<10:
				good.append(code)
				global can_try
				can_try=can_try+1
				# print('{},{}'.format(a[-2:-1].index.values[0],a[-1:].index.values[0]))
				diff=test.test(code,a[-6:-5].index.values[0],a[-1:].index.values[0])
				diff_list.append(diff)
				if diff>0:
					global test_try
					test_try=test_try+1	
Ejemplo n.º 2
0
def fiveLine(code):
	try:
		a=gc.getData(code)
	except:
		print('{} is wrong'.format(code))	
	else:	
		print('{} is running'.format(code))
		if a is not None:
			a.sort_index(inplace=True)
			gc.ma(a,'close',[15,30,60,90,120])
			return a
Ejemplo n.º 3
0
def boll(code):
	try:
		a=gc.getData(code)
	except:
		print('{} is wrong'.format(code))	
	else:	
	    if a is not None:
		    a.sort_index(inplace=True)
		    a['std20']=pd.rolling_std(a.ma20,20)
		    a['boll_up']=a.close+2*a.std20
		    a['boll_down']=a.close-2*a.std20
		    a['boll_range']=(pd.rolling_max(a.boll_up,20)-pd.rolling_min(a.boll_down,20))/pd.rolling_mean(a.ma20,20)
		    a['boll_range_p']=a.boll_range.pct_change()
		    a['boll_range_p20']=a.boll_range.pct_change(periods=20)
		    return a
Ejemplo n.º 4
0
def get_low(code):
	try:
		a=gc.getData(code)
	except:
		print('{} is wrong'.format(code))	
	else:	
		print('{} is running'.format(code))
		if a is not None:
			a.sort_index(inplace=True)
			gc.ma(a,'close',[15,30,60,90,120])
			MA_column=a.columns[-5:]
			a['Diff']=100 * ((a[MA_column].max(axis=1) - a[MA_column].min(axis=1))/a[MA_column].max(axis=1))
			a['Min']= a[MA_column].min(axis=1)
			b=a[-2:-1]
			if b['Min'].values[0] == b['MA_15'].values[0] and b['Diff'].values[0] > 40:
				good.append(code)
Ejemplo n.º 5
0
def test_rsi(code):
	global let_test
	global let_try
	global let_safe
	try:
		a=gc.getData(code)
	except:
		print('{} is wrong'.format(code))	
	else:	
	    if a is not None:
		    a.sort_index(inplace=True)
		    a['rsi']=rsi(a)
		    a['after_7']=a.shift(-7).close
		    a['is_ok']=	(a.after_7-a.close)/a.after_7>0.1
		    a['is_safe']=a.after_7>a.close
		    tmp=a[a.rsi<20]
		    let_try=let_try+len(tmp)
		    let_test=let_test+np.sum(tmp.is_ok)
		    let_safe=let_safe+np.sum(tmp.is_safe)
		    if len(tmp)==np.sum(tmp.is_ok):
		    	good.append({'name':code,'time':len(tmp)})
		    print(code)