def observadorRelog(self): while (True): time.sleep(1) now = datetime.now() hora_actual = now.strftime('%H:%M:%S') print(hora_actual) if hora_actual == '16:42:00': i = Indicadores() print(i.trm()) if hora_actual == '16:42:30': l = LeerExcel() l.leerExcelFuncion() exit()
from Indicadores import * valor = float(input('ingrese el valor que dolares que quiere convertir: ')) i = Indicadores() resultado = float(i.indicadoresEconomicos()) * valor print(resultado)
def createTrainsDataCedears(self, dateToStart): DAYS = 30 date_time = datetime.fromisoformat(dateToStart) xTrains = [] yTrains = [] yTest = [] xTest = [] trainOrTest = True for NroCedear in tqdm(range(30)): if NroCedear == 27: continue cedearTicket = self.cedears[NroCedear] prom = tools.getInfoFewDaysAgo(1, date_time + timedelta(days=1), cedearTicket, 10) if type(prom) != type("") : prom = [prom["open"][0], prom["close"][0], prom["high"][0], prom["low"][0]] prom = np.mean(prom) data = tools.getInfoFewDaysAgo(DAYS, date_time, cedearTicket, 10) Bands = indicator.getBollingerBands(data) xQuantity = Bands.size heatMap = np.zeros((100, xQuantity)) for xPos in range(5, xQuantity): yPos = tools.acotation(np.max(data['high']), np.min(data['low']), Bands['BBM_5_2.0'][xPos]) yPosClose = tools.acotation(np.max(data['high']), np.min(data['low']), data['close'][xPos]) yPosOpen = tools.acotation(np.max(data['high']), np.min(data['low']), data['open'][xPos]) if yPos >= 100: yPos = 99 if yPosClose >= 100: yPosClose = 99 if yPosOpen >= 100: yPosOpen = 99 if yPosOpen < yPosClose: heat = 100 plus = 80 / (yPosClose - yPosOpen) for y in range(yPosOpen, yPosClose): heatMap[y][xPos] = int(heat) heat += plus elif yPosClose < yPosOpen: heat = 180 substrac = 80 / (yPosOpen - yPosClose) for y in range(yPosClose, yPosOpen): heatMap[y][xPos] = int(heat) heat -= substrac heatMap[yPos][xPos] = 255 acotationVar = tools.acotation(np.max(data["high"]), np.min(data["low"]), prom) if acotationVar >= 100: acotationVar = 99 elif acotationVar < 0: acotationVar = 0 if trainOrTest: yTrains.append(acotationVar) xTrains.append(heatMap.copy()) else: yTest.append(acotationVar) xTest.append(heatMap.copy()) trainOrTest = not trainOrTest plt.imshow(heatMap, cmap='hot', interpolation='nearest') plt.show() xTrains = np.array(xTrains) yTrains = np.array(yTrains) xTest = np.array(xTest) yTest = np.array(yTest) return xTrains, yTrains, xTest, yTest
{'User-agent' : 'Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5'} jonathan campos lozano16:32 from Indicadores import * i = Indicadores() i.indicadoresEconomicos()
class Form: inid = Indicadores() def __init__(self): self.root = Tk() self.calculadora = Calculadora() self.dorlares = StringVar() self.n1 = StringVar() self.n2 = StringVar() self.resultado = StringVar() self.formulario() def sumar(self): self.resultado.set( self.calculadora.suma(float(self.n1.get()), float(self.n2.get()))) self.borrar() def restar(self): self.resultado.set( self.calculadora.resta(float(self.n1.get()), float(self.n2.get()))) self.borrar() def multiplicar(self): self.resultado.set( self.calculadora.multiplicacion(float(self.n1.get()), float(self.n2.get()))) self.borrar() def dividir(self): self.resultado.set( self.calculadora.divicion(float(self.n1.get()), float(self.n2.get()))) self.borrar() def borrar(self): self.n1.set("") self.n2.set("") def divisas(self): trm = self.inid.trm() self.resultado.set(round(float(trm) * float(self.dorlares.get()), 3)) def formulario(self): self.root.config(bd=20) Label(self.root, text="VALOR EN DOLARES").pack() Entry(self.root, textvariable=self.dorlares).pack() Label(self.root, text="NUMERO 1").pack() Entry(self.root, textvariable=self.n1).pack() Label(self.root, text="NUMERO 2").pack() Entry(self.root, textvariable=self.n2).pack() Label(self.root, text="RESULTADO").pack() Entry(self.root, textvariable=self.resultado, state="disabled").pack() Button(self.root, text="+", command=self.sumar).pack(side="left") Button(self.root, text="-", command=self.restar).pack(side="left") Button(self.root, text="*", command=self.multiplicar).pack(side="left") Button(self.root, text="/", command=self.dividir).pack(side="left") Button(self.root, text="Valor en Pesos", command=self.divisas).pack(side="left") self.root.mainloop()
from BaseDeDatos import BaseDeDatos import Indicadores as Indicator import Herramientas as tool MyBase = BaseDeDatos("mongodb://localhost:27017/", "Market", "ticketsCedears", "cedearPureData") MyBase.updateTicketsCedears() MyBase.subirIndicesYDatosDelDia() TICKET = "BPAT.BA" DAYS = 30 data = tool.getInfoFewDaysAgo(DAYS, datetime.now(), TICKET, 10) stochData = Indicator.getStochasticIndicator(data) ADXData = Indicator.getADXIndicator(data) bBand = Indicator.getBollingerBands(data) print(stochData) print("-----------------------------") print(ADXData) print("-----------------------------") print(bBand) print("-----------------------------") """ #save in database for mapAndResult in range(len(xTrains)): mydict = { "heatmap": binary.Binary(pickle.dumps(xTrains[mapAndResult], protocol=2)),
def subirIndicesYDatosDelDia(self): ticketNro = 0 total = self.MTickets.find().count() for ticket in self.MTickets.find(): ticketNro += 1 if ticketNro == 21: a = 1 print("ticket nro: " + str(ticketNro) + " de: " + str(total)) data = tool.getInfoFewDaysAgo(20, datetime.now(), ticket["TicketName"], 10) if type(data) != type(""): bbans = indicator.getBollingerBandsToday(data) stoch = indicator.getStochasticToday(data) adx = indicator.getADXToday(data) dataToday = data.iloc[-1] cantidad = self.MData.find({"ticket": ticket["TicketName"]}).count() actionCursor = self.MData.find({"ticket": ticket["TicketName"]}) for action in actionCursor: if cantidad > 0: subirFecha = action["fechas"] if subirFecha[-1] != datetime.now().strftime("%m/%d/%Y"): subirFecha.append(datetime.now().strftime("%m/%d/%Y")) #Indicadores indicadoresGuardados = action["indicadores"] indicadoresGuardados[0]["curvas"]["slowk"].append(stoch["STOCHk_5"]) indicadoresGuardados[0]["curvas"]["slowd"].append(stoch["STOCHd_3"]) indicadoresGuardados[1]["curvas"]["adx"].append(adx["ADX_14"]) indicadoresGuardados[1]["curvas"]["di_plus"].append(stoch["DMP_14"]) indicadoresGuardados[1]["curvas"]["di_minus"].append(stoch["DMN_14"]) indicadoresGuardados[2]["curvas"]["BBUp"].append(bbans["BBU_5_2.0"]) indicadoresGuardados[2]["curvas"]["BBMed"].append(stoch["BBM_5_2.0"]) indicadoresGuardados[2]["curvas"]["BBLow"].append(stoch["BBL_5_2.0"]) #Datos datosGuardados = action["datos"] datosGuardados["open"].append(dataToday["open"]) datosGuardados["close"].append(dataToday["close"]) datosGuardados["high"].append(dataToday["high"]) datosGuardados["low"].append(dataToday["low"]) else: subirFecha[-1] = datetime.now().strftime("%m/%d/%Y") #Indicadores indicadoresGuardados = action["indicadores"] indicadoresGuardados[0]["curvas"]["slowk"][-1] = stoch["STOCHk_5"] indicadoresGuardados[0]["curvas"]["slowk"][-1] = stoch["STOCHd_3"] indicadoresGuardados[1]["curvas"]["adx"][-1] = adx["ADX_14"] indicadoresGuardados[1]["curvas"]["di_plus"][-1] = adx["DMP_14"] indicadoresGuardados[1]["curvas"]["di_minus"][-1] = adx["DMN_14"] indicadoresGuardados[2]["curvas"]["BBUp"][-1] = bbans["BBU_5_2.0"] indicadoresGuardados[2]["curvas"]["BBMed"][-1] = bbans["BBM_5_2.0"] indicadoresGuardados[2]["curvas"]["BBLow"][-1] = bbans["BBL_5_2.0"] #Datos datosGuardados = action["datos"] datosGuardados["open"][-1] = dataToday["open"] datosGuardados["close"][-1] = dataToday["close"] datosGuardados["high"][-1] = dataToday["high"] datosGuardados["low"][-1] = dataToday["low"] self.MData.update_one({"ticket": ticket["TicketName"]}, {"$set": {"indicadores": indicadoresGuardados, "datos": datosGuardados}}) else: jsonIndicadoresASubir = { "tipo_activo": "cedear", "activo": "", "ticket": ticket["TicketName"], "fechas": [datetime.now().strftime("%m/%d/%Y")], "indicadores": [ { "indicador": "STOCH", "curvas": { "slowk": [stoch["STOCHk_5"]], "slowd": [stoch["STOCHd_3"]], }, "lineas_punteadas": [ { "nombre": "80", "posicion_y": 80 }, { "nombre": "20", "posicion_y": 20 } ], "etiquetas": [ { "nombre": "", "posiciones": [] } ] }, { "indicador": "DMI", "curvas": { "adx": [adx["ADX_14"]], "di_plus": [adx["DMP_14"]], "di_minus": [adx["DMN_14"]] } }, { "indicador": "BollingerBands", "curvas": { "BBUp": [bbans["BBU_5_2.0"]], "BBMed": [bbans["BBM_5_2.0"]], "BBLow": [bbans["BBL_5_2.0"]] } } ], "datos": { "open":[dataToday["open"]], "close":[dataToday["close"]], "high":[dataToday["high"]], "low":[dataToday["low"]] } } self.MData.insert_one(jsonIndicadoresASubir)