def testStrat4(ticker): ticker = ticker.upper() a = main.Trade(ticker) startAmount = 1000000 buyAndHold = a.calc_buy_and_hold(startAmount) - startAmount strat1 = a.test_strategy(algo.strategy4, startAmount) - startAmount strat1Info = a.get_more_info() return render_template("lines.html", DATABASE=strat1Info, strategy="Strategy 4", balance='{:,.2f}'.format(startAmount), stock=ticker.upper())
<p align="center"> <img src ="static/strat5_{1}.png"> </p> <p align="center"> <img src ="static/strat6_{1}.png"> </p> <p align="center"> <img src ="static/strat7_{1}.png"> </p> # """ ticker = raw_input("Ticker: ").upper() a = main.Trade(ticker) company = main.get_company_by_ticker(ticker) startAmount = 1000000 stockMentionRanking = main.calc_stock_ranking(ticker) + 1 print(stockMentionRanking) totalCount = main.get_total_count_by_ticker(ticker) print(totalCount) sentiment = main.get_sentiment_by_ticker(ticker) print(sentiment) mentionsByDay = main.get_weekday_by_ticker(ticker) stockFirstMentioned = main.get_first_comment_with_ticker(ticker) #print stockFirstMentioned table = ''' |Strategy Name|Total Trades|Return Percentage|Return|Alpha| | ------------- |:-------:|:-------:|:-------:|:-------:|''' buyAndHold = a.calc_buy_and_hold(startAmount) - startAmount
def strategy2(tradeClass): dayDelay = 14 for i in range(dayDelay, len(tradeClass.modified_dates)): indicatorDay = tradeClass.modified_dates[i - dayDelay] tradeDay = tradeClass.modified_dates[i] if indicatorDay in tradeClass.historical_data: pass if __name__ == '__main__': infoz = {'buyAndHold': 0} for stock in main.STOCK_TICKERS: try: if main.get_total_count_by_ticker(stock) > 1000: a = main.Trade(stock) startAmount = 1000000 buyAndHold = a.calc_buy_and_hold(startAmount) - startAmount strat1 = a.test_strategy(strategy1, startAmount) - startAmount strat3 = a.test_strategy(strategy3, startAmount) - startAmount strat4 = a.test_strategy(strategy4, startAmount) - startAmount strat5 = a.test_strategy(strategy5, startAmount) - startAmount strat6 = a.test_strategy(strategy6, startAmount) - startAmount strat7 = a.test_strategy(strategy7, startAmount) - startAmount print("{} | Returns from buy and hold: ${:,.2f}".format( stock, buyAndHold)) print("{} | Returns from Strategy 1: ${:,.2f}".format( stock, strat1)) print("{} | Returns from Strategy 3: ${:,.2f}".format( stock, strat3)) print("{} | Returns from Strategy 4: ${:,.2f}".format(