Ejemplo n.º 1
0
    def perform_financial_analysis(self, newsId, company_name, sentiment,
                                   sentiment_score):
        # Stubbing dummy quote, but ideally get hold of the right stock and lookup price

        #before
        for i in range(8):

            if i == 0:

                current_price = ystockquote.get_price(company_name)

            #print newsId,company_name,strftime("%Y-%m-%d %H:%M:%S", gmtime()),sentiment,sentiment_score,current_price
            #Sleeping for some time before recording the time again
            time.sleep(STOCK_GUAGE_TIME_INTERVAL_DIFFERENCE)
            #after
            new_price = ystockquote.get_price(company_name)

            logger.info('[DATA] : %s,%s,%s,%s,%s,%s,%s', str(newsId),
                        str(company_name), str(time.ctime()), str(sentiment),
                        str(sentiment_score), str(current_price),
                        str(new_price))
            with open("../Stock-Predictor.log", "a") as f:
                f.write(
                    str(newsId) + " " + str(company_name) + " " +
                    str(time.ctime()) + " " + str(sentiment) + " " +
                    str(sentiment_score) + " " + str(current_price) + " " +
                    str(new_price) + "\n")
Ejemplo n.º 2
0
    def perform_financial_analysis(self, newsId, company_name, sentiment,
                                   sentiment_score):
        # Currently Dummy Quote is in Place. Need to make this so when user types into web app and hits a search button, this will update the python code in that location.

        for i in range(8):

            if i == 0:

                current_price = ystockquote.get_price(company_name)

            #Prints out relevant data regarding data scraping information (Date, Time ,Etc...)
            time.sleep(STOCK_TIME_SCRAPE_INTERVAL)

            new_price = ystockquote.get_price(company_name)

            logger.info('[DATA] : %s,%s,%s,%s,%s,%s,%s', str(newsId),
                        str(company_name), str(time.ctime()), str(sentiment),
                        str(sentiment_score), str(current_price),
                        str(new_price))
            with open("../Stock-Predictor.log", "a") as f:
                f.write(
                    str(newsId) + " " + str(company_name) + " " +
                    str(time.ctime()) + " " + str(sentiment) + " " +
                    str(sentiment_score) + " " + str(current_price) + " " +
                    str(new_price) + "\n")
Ejemplo n.º 3
0
def call_sentiment_analysis():
    alchemyObj = AlchemyAPI.AlchemyAPI()
    # Load the API key from disk.
    alchemyObj.loadAPIKey("api_key.txt");
    # Extract sentiment from a web URL.
    result = alchemyObj.URLGetTextSentiment("http://www.reuters.com/article/2012/11/30/us-china-apple-iphone-idUSBRE8AT06G20121130?type=companyNews");
    
    
    # Stubbing dummy quote, but ideally get hold of the right stock and lookup price
    print ystockquote.get_price('GOOG')
    
    # Kick off another thread that will fetch the price of the same quote after 5 mins.
    print result    
Ejemplo n.º 4
0
def call_sentiment_analysis():
    alchemyObj = AlchemyAPI.AlchemyAPI()
    # Load the API key from disk.
    alchemyObj.loadAPIKey("api_key.txt")
    # Extract sentiment from a web URL.
    result = alchemyObj.URLGetTextSentiment(
        "http://www.reuters.com/article/2012/11/30/us-china-apple-iphone-idUSBRE8AT06G20121130?type=companyNews"
    )

    # Stubbing dummy quote, but ideally get hold of the right stock and lookup price
    print ystockquote.get_price('GOOG')

    # Kick off another thread that will fetch the price of the same quote after 5 mins.
    print result
Ejemplo n.º 5
0
    def perform_financial_analysis(self, newsId, company_name, sentiment, sentiment_score):
        # Stubbing dummy quote, but ideally get hold of the right stock and lookup price

       
        #before
        for i in range(1):
            
            if i ==0:
                
                current_price = ystockquote.get_price(company_name)
            
            #print newsId,company_name,strftime("%Y-%m-%d %H:%M:%S", gmtime()),sentiment,sentiment_score,current_price
            #Sleeping for some time before recording the time again
            time.sleep(STOCK_GUAGE_TIME_INTERVAL_DIFFERENCE)
            #after
            new_price = ystockquote.get_price(company_name)
            
            logger.info('[DATA] : %s,%s,%s,%s,%s,%s,%s',str(newsId),str(company_name), str(time.ctime()), str(sentiment), str(sentiment_score), str(current_price), str(new_price))
Ejemplo n.º 6
0
    def perform_financial_analysis(self, newsId, company_name, sentiment, sentiment_score):
        # Currently Dummy Quote is in Place. Need to make this so when user types into web app and hits a search button, this will update the python code in that location.

       
        for i in range(8):
            
            if i == 0:
                
                current_price = ystockquote.get_price(company_name)
            
            #Prints out relevant data regarding data scraping information (Date, Time ,Etc...)
            time.sleep(STOCK_TIME_SCRAPE_INTERVAL)
            
            new_price = ystockquote.get_price(company_name)
            
            logger.info('[DATA] : %s,%s,%s,%s,%s,%s,%s', str(newsId), str(company_name), str(time.ctime()), str(sentiment), str(sentiment_score), str(current_price), str(new_price))
            with open("../Stock-Predictor.log", "a") as f:
                f.write(str(newsId) + " " + str(company_name) + " " + str(time.ctime()) + " " + str(sentiment) + " " + str(sentiment_score) + " " + str(current_price) + " " + str(new_price) + "\n")