예제 #1
0
def media_simple(valor, tiempo, tipo, data):
	# cortes de una media simple
	titulo = "SMA"
	importes_operaciones = []
	for periodo in range(5,200):
		# print ("Calculando media {}".format(periodo)),
		# calculo la sma de un periodo con datos de cierre
		array_data = fb.get_sma_periodo(periodo, data['close'])
	
		# devuelve array LARGO, CORTO por cada elemento del array
		cruces = fb.get_cortes(array_data, data['close'])
		
		# devuelve un array con pares de posiciones de inicio fin del corte 
		# de un array de cruces
		# un array para posiciones largas y otro para cortas (12, 16)
		largos,cortos = fb.get_pares_corte(cruces)
		numero_operaciones = len(largos)+len(cortos)
		# devuelve un array con fecha inicio, fin, e importe 
		# de las operaciones ('2018-02-14', '2018-02-27', 99.0),
		l,c = fb.get_simulacion_importes(data,largos,cortos)	
		
		
		# suma los importes de un array devuelto por get_simulacion_importes
		imp_l = fb.sumar_importes(l)
		imp_c = fb.sumar_importes(c)
		
		# anado elemento al array
		importes_operaciones.append((periodo, numero_operaciones, imp_l + imp_c, imp_l, imp_c))
	
	importes_operaciones.sort(key=lambda (a,b,c,d,e):c, reverse=True)
	(periodo, numero_operaciones, total, largos, cortos) = importes_operaciones[0]
	return (valor, tiempo, tipo, titulo, periodo, numero_operaciones, total, largos, cortos)
예제 #2
0
def sar_parabolico(valor, tiempo, tipo, data, parabolic_sar_bull):
	# cortes del sar parabolico
	titulo = "SAR PARABOLICO"
	cruces = fb.get_cortes_sar(parabolic_sar_bull,data['close'])
	
	largos,cortos = fb.get_pares_corte(cruces)
	numero_operaciones = len(largos)+len(cortos)
	l,c = fb.get_simulacion_importes(data,largos,cortos)	
	imp_l = fb.sumar_importes(l)
	imp_c = fb.sumar_importes(c)
	total = imp_l + imp_c
	# importes_operaciones = (imp_l + imp_c, imp_l, imp_c)

	return (valor, tiempo, tipo, titulo, 0, numero_operaciones, imp_l + imp_c, imp_l, imp_c)
예제 #3
0
def macd(valor, tiempo, tipo, data):
	# cortes del MACD
	titulo = "MACD"
	cruces = fb.get_cortes_macd(data['macd_histograma'])
	
	largos,cortos = fb.get_pares_corte(cruces)
	numero_operaciones = len(largos)+len(cortos)
	l,c = fb.get_simulacion_importes(data,largos,cortos)	
	imp_l = fb.sumar_importes(l)
	imp_c = fb.sumar_importes(c)
	total = imp_l + imp_c
	# importes_operaciones = (imp_l + imp_c, imp_l, imp_c)
	
	return (valor, tiempo, tipo, titulo, 0, numero_operaciones, imp_l + imp_c, imp_l, imp_c)
예제 #4
0
def media_exponencial(valor, tiempo, tipo, data):
	titulo = "EMA"
	importes_operaciones = []
	for periodo in range(5,200):
		array_data = fb.get_ema_periodo(periodo, data['close'])
		cruces = fb.get_cortes(array_data, data['close'])
		
		largos,cortos = fb.get_pares_corte(cruces)
		numero_operaciones = len(largos)+len(cortos)
		l,c = fb.get_simulacion_importes(data,largos,cortos)	
		imp_l = fb.sumar_importes(l)
		imp_c = fb.sumar_importes(c)
		importes_operaciones.append((periodo, numero_operaciones, imp_l + imp_c, imp_l, imp_c))
			
	importes_operaciones.sort(key=lambda (a,b,c,d,e):c, reverse=True)
	(periodo, numero_operaciones, total, largos, cortos) = importes_operaciones[0]
	return (valor, tiempo, tipo, titulo, periodo, numero_operaciones, total, largos, cortos)