Beispiel #1
0
def totalTogether(stockSymbol, Webster, currentInfo, Predict, Pointy,
                  Rsi):  #plots all the graphs together
    old_stdout = sys.stdout
    sys.stdout = open(os.devnull, "w")
    # Does not work in linux!!!
    temp = Webster.index
    temp = temp.tz_localize("UTC")

    figure = obj.Scatter(y=Webster.High,
                         x=temp,
                         line=dict(color=('rgb(0,50,100)')),
                         name="Past Data for " + stockSymbol)  #Past Data Line

    currentFigure = obj.Trace(y=currentInfo[0]['LastTradePrice'],
                              x=currentInfo[0]['LastTradeDateTime'],
                              line=dict(color=('rgb(0,0,0)')),
                              name='Current Data for ' +
                              stockSymbol)  #Current Point

    Predicts = obj.Scatter(y=Predict,
                           x=ArrayNCalc.getWorkDates(len(Predict)),
                           line=dict(color=('rgb(255,165,0)')),
                           name="Prediction " + stockSymbol)  #Prediction Line

    point = obj.Trace(y=Pointy,
                      x=datetime.now(pytz.utc) + timedelta(days=1),
                      line=dict(color=pointColorMaker(Pointy, currentInfo)),
                      name="Prediction " + stockSymbol)  #point of prediciton

    RSI = obj.Scatter(y=Rsi,
                      x=ArrayNCalc.getWorkDates(len(Rsi)),
                      line=dict(color=('rgb(0,0,0)')),
                      name="RSI for " + stockSymbol)  #Prediction Line

    fig = tools.make_subplots(rows=2, cols=1)

    #data=Data([figure,currentFigure,Predicts, point]) #Data Array of Figures
    data = Data([Predicts, point, currentFigure, figure])
    fig.append_trace(data[0], 1, 1)
    fig.append_trace(data[1], 1, 1)
    fig.append_trace(data[2], 1, 1)
    fig.append_trace(data[3], 1, 1)

    fig.append_trace(RSI, 2, 1)

    fig['layout']['yaxis1'].update(title='Dollars ($)', domain=[0, 0.7])
    fig['layout']['yaxis2'].update(title='RSI percentage (%)',
                                   range=[0, 100],
                                   domain=[0.8, 1])
    sys.stdout.close()
    sys.stdout = old_stdout
    return py.plot(fig, filename=stockSymbol + '_Line',
                   auto_open=False)  #Plot The Function
Beispiel #2
0
def getPointY(FinalM, date, prev, yahoorecent):

    i = ArrayNCalc.getWorkDates(45)
    i = len(i)

    prev = float(prev)
    Max = .25 * prev - prev  # Maximum
    Min = .25 * prev + prev  # Minimum

    x10 = float(FinalM.item(10, 0))  #Coeffcient 10
    x9 = float(FinalM.item(9, 0))  #Coeffcient 9
    x8 = float(FinalM.item(8, 0))  #Coeffcient 8
    x7 = float(FinalM.item(7, 0))  #Coeffcient 7
    x6 = float(FinalM.item(6, 0))  #Coeffcient 6
    x5 = float(FinalM.item(5, 0))  #Coeffcient 5
    x4 = float(FinalM.item(4, 0))  #Coeffcient 4
    x3 = float(FinalM.item(3, 0))  #Coeffcient 3
    x2 = float(FinalM.item(2, 0))  #Coeffcient 2
    x1 = float(FinalM.item(1, 0))  #Coeffcient 1
    xo = float(FinalM.item(0, 0))  #Coeffcient 0

    change = float(
        (x10 * pow(i, 10) + x9 * pow(i, 9) + x8 * pow(i, 8) + x7 * pow(i, 7) +
         x6 * pow(i, 6) + x5 * pow(i, 5) + x4 * pow(i, 4) + x3 * pow(i, 3) +
         x2 * pow(i, 2) + x1 * pow(i, 1) + xo * pow(i, 0)))
    if (yahoorecent < prev):
        change += yahoorecent + (Max - Min)  # Predicited Increase
    else:
        change = yahoorecent - change  # Predicted decrease
    return prev + (change / (Max - Min))
Beispiel #3
0
def getPointY(FinalM, date, prev, yahoorecent):

    i = ArrayNCalc.getWorkDates(45)
    i = len(i)
    prev = float(prev)
    Max = .25 * prev - prev
    Min = .25 * prev + prev
    x10 = float(FinalM.item(10, 0))
    x9 = float(FinalM.item(9, 0))
    x8 = float(FinalM.item(8, 0))
    x7 = float(FinalM.item(7, 0))
    x6 = float(FinalM.item(6, 0))
    x5 = float(FinalM.item(5, 0))
    x4 = float(FinalM.item(4, 0))
    x3 = float(FinalM.item(3, 0))
    x2 = float(FinalM.item(2, 0))
    x1 = float(FinalM.item(1, 0))
    xo = float(FinalM.item(0, 0))

    change = float(
        (x10 * pow(i, 10) + x9 * pow(i, 9) + x8 * pow(i, 8) + x7 * pow(i, 7) +
         x6 * pow(i, 6) + x5 * pow(i, 5) + x4 * pow(i, 4) + x3 * pow(i, 3) +
         x2 * pow(i, 2) + x1 * pow(i, 1) + xo * pow(i, 0)))
    if (yahoorecent < prev):
        change += yahoorecent + (Max - Min)
    else:
        change = yahoorecent - change
    return prev + (change / (Max - Min))
Beispiel #4
0
def makeXVals_Matrix(
    percision, startYear, DataSet
):  #Number of elements,percison what power of X do we want to go to. Returns One's Matrix

    i = len(ArrayNCalc.getWorkDates(45))
    matrixx = np.array(i - DataSet)

    matrixx = np.append(matrixx, 0)

    for q in range(2, percision + 1):

        matrixx = np.append(matrixx, pow(0, q))

        pass

    for x in range(int(i - DataSet + 1), int(i)):

        matrixx = np.append(matrixx, [1])

        for y in range(1, percision + 1):

            matrixx = np.append(matrixx, pow(x, y))

            pass

        pass

    return (np.reshape(matrixx, (DataSet, percision + 1)))
Beispiel #5
0
def rsiPlot(stockSymbol, Webster, Predict,
            startYear):  #plots all the graphs together
    old_stdout = sys.stdout
    sys.stdout = open(os.devnull, "w")
    figure = obj.Scatter(y=Webster.High,
                         x=Webster.index,
                         line=dict(color=('rgb(0,50,100)')),
                         name="Past Data for " + stockSymbol)  #Past Data Line

    Predicts = obj.Scatter(y=Predict,
                           x=ArrayNCalc.getWorkDates(len(Predict)),
                           line=dict(color=('rgb(255,165,0)')),
                           name="RSI for " + stockSymbol)  #Prediction Line

    fig = tools.make_subplots(rows=2, cols=1)

    fig.append_trace(figure, 1, 1)  # subplot positions
    fig.append_trace(Predicts, 2, 1)

    fig['layout']['xaxis2'].update(
        range=[datetime(int(startYear), 1, 1),
               datetime.now()])

    fig['layout']['yaxis1'].update(title='Dollars ($)')  # format the axes
    fig['layout']['yaxis2'].update(title='RSI percentage (%)', range=[0, 100])
    sys.stdout.close()
    sys.stdout = old_stdout
    return py.plot(fig, filename=stockSymbol + '_Line')