Ejemplo n.º 1
0
def computeVarAndStatus(df, historyData, refDay=1, percentVarNeg=-0.05, percentVarPos=0.05):
    for ind in range(len(df)):
        historyData = getStockData(df.iloc[ind]['stockname'])
        df.loc[df['stockname'] == df.iloc[ind]['stockname'], 'var1Neg'] = checkVarNeg(df.iloc[ind], historyData, refDay, percentVarNeg)
        df.loc[df['stockname'] == df.iloc[ind]['stockname'], 'var1Pos'] = checkVarPos(df.iloc[ind], historyData, refDay, percentVarPos)
        df.loc[df['stockname'] == df.iloc[ind]['stockname'], 'var1day'] = computeVar(df.iloc[ind], historyData, refDay)
    return df
Ejemplo n.º 2
0
def graphEvolutionTitre(stockname):
    data = loadStocks('mystocks.json')
    histData = getStockData(stockname)
    histDataIntra = getStockIntradayData(stockname)
    listData = [getValueDays(stockname, histData, 30 * months) for months in [12, 6, 3, 1, 1/30, 0]]
    listData = (np.array(listData) - listData[-2]) / listData[-2] * 100
    dataFig = []
    dataFig.append({
            'x': ['1 year ago', 'six months ago', 'three months ago', 'last month', 'yesterday', 'now'],
            'y': listData,
            'type': 'bar',
    })
    fig = go.Figure(data=dataFig, layout={'title': stockname + ' Progression du titre sur 1 an'})
    fig.update_layout(template="plotly_dark", xaxis_rangeslider_visible=False, showlegend=False)
    return fig
Ejemplo n.º 3
0
def graphDataForStock(stockname, freq=1, unit='D', histoDepth=timedelta(days=60)):
    df = loadStocks('mystocks.json')
    if unit in ['T', 'H']:
        historyData = getStockIntradayData(stockname)
    else:
        historyData = getStockData(stockname)
    historyData = updateOHLC(historyData, freq=freq, unit=unit)
    startDate=datetime.now() - histoDepth
    startDate = startDate.replace(hour=0)
    if len(historyData) > 0 and len(historyData[historyData.index > startDate]) > 0:
        timestampStart = historyData.index.get_loc(historyData[historyData.index > startDate].iloc[0].name)
        historyData = historyData.iloc[timestampStart - ((52 + 27)):]
        histo = computeIchimoku(historyData)
        histo = histo[histo.index > startDate]
        histo.index = histo.index + pd.DateOffset(hours=1)
        return graphGenericStock(df[(df['stockname'] == stockname) & (df['boughtDate'] > datetime.now() - histoDepth)], histo, stockname=stockname)
    else:
        return None
Ejemplo n.º 4
0
 def test_getStockData(self):
     getStockData('SO.PA')
     self.assertTrue(True)
Ejemplo n.º 5
0
 def test_computeVarAndStatus(self):
     computeVarAndStatus(pd.DataFrame([{'stockname': 'SO.PA'}]), getStockData('SO.PA'), refDay=1, percentVarNeg=-0.05, percentVarPos=0.05)
     self.assertTrue(True)
Ejemplo n.º 6
0
 def test_checkVarNeg(self):
     checkVarNeg(pd.Series({'stockname': 'SO.PA'}), getStockData('SO.PA'), refDay=1, percentVar=-0.05)
     self.assertTrue(True)
Ejemplo n.º 7
0
 def test_computeVar(self):
     computeVar(pd.Series({'stockname': 'SO.PA'}), getStockData('SO.PA'), refDay=1)
     self.assertTrue(True)
Ejemplo n.º 8
0
 def test_getValueDays(self):
     getValueDays('SO.PA', getStockData('SO.PA'), 0)
     getValueDays('SO.PA', getStockData('SO.PA'), 1)
     getValueDays('SO.PA', getStockData('SO.PA'), 2)
     getValueDays('SO.PA', getStockData('SO.PA'), 3)
     self.assertTrue(True)
Ejemplo n.º 9
0
 def test_computeIchimoku(self):
     computeIchimoku(getStockData('SO.PA'))
     self.assertTrue(True)