Example #1
0
def add_selection_button():
    is_unique = True
    elements = listbox.get(0, listbox.size())
    for i in elements:
        if i == variable.get():
            is_unique = False
    if is_unique:
        listbox.insert(END, names1.get(names1.curselection()))
        instrumentID = backend.getInstrumentId(
            names1.get(names1.curselection()))
        instrument = backend.getInstrumentById(instrumentID)
        symbol = instrument["symbol"]

        global time_frame
        time_frame = s.get()
        instrument_data = backend.getMarketData(instrumentID, time_frame)
        global plot_graph
        plot_graph.append(
            a.plot(
                list(
                    range((instrument_data["currentEpoch"]) + 1 -
                          len(instrument_data["price"]),
                          instrument_data["currentEpoch"] + 1)),
                instrument_data["price"]))

        title.append(names1.get(names1.curselection()) + '[' + symbol + ']')
        a.set_title(', '.join(title))

        dataPlot.draw()
        color = plot_graph[listbox.size() - 1][0].get_color()
        listbox.itemconfig(listbox.size() - 1, {'bg': color})
    change_time_frame()
Example #2
0
def change_time_frame():
    global time_frame
    global plot_graph
    elements = listbox.get(0, listbox.size())
    count = 0
    for i in elements:
        plot_graph[count][0].remove()
        instrumentID = backend.getInstrumentId(i)
        time_frame = s.get()
        instrument_data = backend.getMarketData(instrumentID, time_frame)
        color = plot_graph[count][0].get_color()
        plot_graph[count] = (a.plot(list(
            range((instrument_data["currentEpoch"]) + 1 -
                  len(instrument_data["price"]),
                  instrument_data["currentEpoch"] + 1)),
                                    instrument_data["price"],
                                    color=color))
        count += 1
    a.set_xlim(instrument_data['currentEpoch'] - time_frame,
               instrument_data['currentEpoch'])
    maxvalue = 0
    minvalue = 10000
    for i in plot_graph:
        if max(i[0].get_ydata()) > maxvalue:
            maxvalue = max(i[0].get_ydata())
        if min(i[0].get_ydata()) < minvalue:
            minvalue = min(i[0].get_ydata())
        if len(plot_graph) > 1:
            a.set_ylim(minvalue - (minvalue * 0.05),
                       maxvalue + (maxvalue * 0.05))
        else:
            a.set_ylim(minvalue, maxvalue)
    dataPlot.draw()
Example #3
0
def expo_moving_avg_button():
    if 'selected' in b212.state():
        index = backend.getInstrumentId(names1.get(names1.curselection()))
        market_data = backend.getMarketData(index, time_frame)
        expo_moving_avg = backend.expMovingAverage(market_data, 1)
        plot_graph.append(
            a.plot(
                list(
                    range((market_data["currentEpoch"]) + 1 -
                          len(expo_moving_avg),
                          market_data["currentEpoch"] + 1)), expo_moving_avg))
    else:
        plot_graph[2].pop(0).remove()
    dataPlot.draw()
Example #4
0
def expo_correlation_pair_button():
    if 'selected' in b242.state():
        index = backend.getInstrumentId(names1.get(names1.curselection()))
        market_data = backend.getMarketData(index, time_frame)
        expo_moving_avg = backend.expRollingCorrelation(
            ["Blank River", "Dew Iceberg"], time_frame)
        plot_graph.append(
            a.plot(
                list(
                    range((market_data["currentEpoch"]) + 1 -
                          len(expo_moving_avg),
                          market_data["currentEpoch"] + 1)), expo_moving_avg))
    else:
        plot_graph[8].pop(0).remove()
    dataPlot.draw()
Example #5
0
def expo_standard_deviation_button():
    if 'selected' in b222.state():
        index = backend.getInstrumentId(names1.get(names1.curselection()))
        market_data = backend.getMarketData(index, time_frame)
        expo_moving_avg = backend.expMovingStdDev(market_data, 1)
        plot_graph.append(
            a.plot(
                list(
                    range((market_data["currentEpoch"]) + 1 -
                          len(expo_moving_avg),
                          market_data["currentEpoch"] + 1)), expo_moving_avg))
        a.set_ylim(0, 10)
    else:
        plot_graph[4].pop(0).remove()
    dataPlot.draw()
Example #6
0
def autocorrelation_button():
    if 'selected' in b231.state():
        index = backend.getInstrumentId(names1.get(names1.curselection()))
        market_data = backend.getMarketData(index, time_frame)
        expo_moving_avg = backend.rangeAutocorrelation(market_data, 10)
        print(expo_moving_avg)
        a.set_ylim(-1, 1)
        a.set_xlim(4321, 4334)
        plot_graph.append(
            a.plot(
                list(
                    range((market_data["currentEpoch"]) + 1 -
                          len(expo_moving_avg),
                          market_data["currentEpoch"] + 1)), expo_moving_avg))
    else:
        plot_graph[5].pop(0).remove()
    dataPlot.draw()