示例#1
0
def SimulacionEMA():
    symbols = input("Input a symbol or many separated by comma (Input ALL to Simulate for all symbols): ")
    if symbols.upper() == "ALL":
        symbols = DatabaseActions.getAll()
    else:
        symbols = symbols.split(",")
    for symbol in symbols:
        historico = DatabaseActions.getHistoric(symbol)
        SimulationEMA.simular(symbol,historico)
示例#2
0
def GraphicsTechnicalAnalysis():
    symbols = input("Input a symbol or many separated by comma(Input ALL to Calculate for all symbols): ")
    if symbols.upper() == "ALL":
        symbols = DatabaseActions.getAll()
    else:
        symbols = symbols.split(",")
    for symbol in symbols:    
        historic = DatabaseActions.getHistoric(symbol)
        TechnicalAnalysis.GraphicsStoch(historic, symbol, parameters)
示例#3
0
def historico():
    symbol = input("Input a symbol: ")
    historico = DatabaseActions.getHistoric(symbol)
    historicDF = {}
    for key in historico:
        historicDF[datetime.datetime.fromisoformat(key)] = historico[key]
    df = pd.DataFrame.from_dict(historicDF,
                                orient='index').tail(50).rename(columns={
                                    'o': 'Open',
                                    'h': 'High',
                                    'l': 'Low',
                                    'c': 'Close'
                                })

    op = input("¿Agregar RSI? S/N: ")
    if op.lower() == 's':
        titulo = 'RSI'
        periodo = int(input("Ingrese el periodo: "))
        RSI = RelativeStrengthIndex.RSI(historico, periodo)
        df[titulo] = df.index.to_series().map(RSI)

    op = input("¿Agregar EMA? S/N: ")
    while op.lower() == 's':
        titulo = input("Ingrese un titulo para la EMA: ")
        periodo = int(input("Ingrese el periodo: "))
        EMAS = ExponentialMovingAverage.EMA(historico, periodo)
        df[titulo] = df.index.to_series().map(EMAS)
        op = input("¿Agregar otra EMA? S/N: ")

    print(df)
    data = df.tail(30)
    columns = list(data.columns)[4:]
    fig = plt.figure()
    fig.set_size_inches((20, 16))
    ax_candle = fig.add_axes((0, 0.05, 1, 0.9))
    ax_candle.xaxis_date()
    if 'RSI' in columns:
        ax_candle = fig.add_axes((0, 0.30, 1, 0.7))
        ax_rsi = fig.add_axes((0, 0.05, 1, 0.2), sharex=ax_candle)
        ax_rsi.set_ylabel("(%)")
        ax_rsi.plot(data.index, [70] * len(data.index), label="overbought")
        ax_rsi.plot(data.index, [30] * len(data.index), label="oversold")
        ax_rsi.plot(data.index, data["RSI"], label="RSI")
        ax_rsi.legend(loc="center left")

    ohlc = []
    for date, row in data.iterrows():
        Open, High, Low, Close = row[:4]
        ohlc.append([date2num(date), Open, High, Low, Close])

    for column in columns:
        if column != 'RSI':
            ax_candle.plot(data.index, data[column], label=column)
    candlestick_ohlc(ax_candle, ohlc, colorup="g", colordown="r")
    ax_candle.legend()
    plt.show()