def resultsAlphaVsSP500(self):
        print("This needs to be redone such that a dict is created for the purchase dates and SP500 on that day")
        currentSP500 = -1
        startSP500 = -1
        currentSP500 = float(StockHelper.getSharePrice("%5EGSPC"))

        from datetime import date

        today = date.today()
        if (
            self.purchasedate.day == today.day
            and self.purchasedate.month == today.month
            and self.purchasedate.year == today.year
        ):
            gspcOpenPrice = StockHelper.getShareOpenPrice("^GSPC")
            if (
                gspcOpenPrice[0] != "N"
            ):  # check for na value, WEAK TEST could do a regex to see if the price contains a letter
                startSP500 = float(gspcOpenPrice)
            else:
                startSP500 = 0.1
        else:
            startSP500 = float(
                StockHelper.get_historical_price("^GSPC", (self.purchasedate.strftime("%Y%m%d")))
            )  # "%EGSPC",(self.purchasedate.strftime('%Y%m%d')))
        if startSP500 != 0 and self.totalpurchaseprice != 0 and self.currentWorth_func() != 0:
            return (
                (self.currentWorth_func() - (self.totalpurchaseprice * (1 + (currentSP500 - startSP500) / startSP500)))
                / (self.currentWorth_func())
                * 100
            )  # this returns the percentage over/under (alpha) of the current investment when compared to the SP500 index.; negative values are bad, positive are good
        else:
            return 0
    def resultsIfInvestedInX(self):
        print("This needs to be redone such that a dict is created for the purchase dates and TickerX on that day")
        currentTickerX = -1
        startTickerX = -1
        currentTickerX = float(StockHelper.getSharePrice(self.comparisonticker))

        # we need to check if this is the first day for this security, as we can't get historical data if this is the first day
        from datetime import date

        today = date.today()
        if (
            self.purchasedate.day == today.day
            and self.purchasedate.month == today.month
            and self.purchasedate.year == today.year
        ):
            startTickerX = float(StockHelper.getShareOpenPrice(self.comparisonticker))
        else:
            startTickerX = float(
                StockHelper.get_historical_price(self.comparisonticker, (self.purchasedate.strftime("%Y%m%d")))
            )
        if startTickerX != 0:

            return self.totalpurchaseprice * (1 + (currentTickerX - startTickerX) / startTickerX)
        else:
            return 0
 def __init__(self,data):
     self.ticker=data['ticker']
     temp=data["purchaseDate"].split('/')
     self.purchaseDate=datetime.datetime(int(temp[2]),int(temp[0]),int(temp[1]))
     self.totalPurchasePrice=data['totalPurchasePrice']
     self.commissionToBuy=data['commissionToBuy']
     #self.unitPriceAtPurchase=get_historical_prices_plus_one_day(self.ticker,(self.purchaseDate.strftime('%Y%m%d'))) #NO LONGER USING this version since IBD lists are published the night before their list date, so you could purchase at the open.
     self.unitPriceAtPurchase=StockHelper.get_historical_price(self.ticker,(self.purchaseDate.strftime('%Y%m%d')))
     self.unitPriceAtPresent=StockHelper.getSharePrice(self.ticker)
    def resultsIfInvestedInSP500(self):
        print("This needs to be redone such that a dict is created for the purchase dates and SP500 on that day")
        currentSP500=-1
        startSP500=-1
        currentSP500=float(StockHelper.getSharePrice("%5EGSPC"))

        #we need to check if this is the first day for this security, as we can't get historical data if this is the first day
        from datetime import date
        today = date.today()
        if ( self.purchasedate.day == today.day  and self.purchasedate.month == today.month and self.purchasedate.year == today.year):
            startSP500=float(StockHelper.getShareOpenPrice("^GSPC"))
        else:
            startSP500=float(StockHelper.get_historical_price("^GSPC",(self.purchasedate.strftime('%Y%m%d'))))
        if (startSP500 != 0):

            return (self.totalpurchaseprice*(1+(currentSP500-startSP500)/startSP500))
        else:
            return 0