def DownloadAndGraphStocks(tickerList: list):
    for ticker in tickerList:
        prices = PricingData(ticker)
        print('Loading ' + ticker)
        if prices.LoadHistory(True):
            print('Calcualting stats ' + ticker)
            prices.NormalizePrices()
            prices.CalculateStats()
            prices.PredictPrices(2, 15)
            prices.NormalizePrices()
            prices.SaveStatsToFile(True)
            psnap = prices.GetCurrentPriceSnapshot()
            titleStatistics = ' 5/15 dev: ' + str(
                round(psnap.fiveDayDeviation * 100, 2)) + '/' + str(
                    round(psnap.fifteenDayDeviation * 100, 2)) + '% ' + str(
                        psnap.low) + '/' + str(
                            psnap.nextDayTarget) + '/' + str(
                                psnap.high) + ' ' + str(
                                    psnap.snapshotDate)[:10]
            print('Graphing ' + ticker + ' ' + str(psnap.snapshotDate)[:10])
            for days in [90, 180, 365, 2190, 4380]:
                prices.GraphData(None,
                                 days,
                                 ticker + '_days' + str(days) + ' ' +
                                 titleStatistics, (days < 1000),
                                 True,
                                 str(days).rjust(4, '0') + 'd',
                                 trimHistoricalPredictions=False)
예제 #2
0
def DownloadAndSaveStocksWithStats(tickerList: list):
    for ticker in tickerList:
        prices = PricingData(ticker)
        print('Loading ' + ticker)
        if prices.LoadHistory(requestedEndDate=GetTodaysDate()):
            print('Calcualting stats ' + ticker)
            prices.CalculateStats()
            prices.SaveStatsToFile(includePredictions=False, verbose=True)
def PlotPrediction(ticker: str = '^SPX',
                   predictionMethod: int = 0,
                   daysToGraph: int = 60,
                   daysForward: int = 5,
                   learnhingEpochs: int = 500):
    print('Plotting predictions for ' + ticker)
    prices = PricingData(ticker)
    if prices.LoadHistory(True):
        prices.NormalizePrices()
        prices.PredictPrices(predictionMethod, daysForward, learnhingEpochs)
        prices.NormalizePrices()
        prices.GraphData(None, daysToGraph,
                         ticker + ' ' + str(daysToGraph) + 'days', True, True,
                         str(daysToGraph) + 'days')
        prices.SaveStatsToFile(True)