def test_macd_rsi_adx_atr_obv_bb(self): tickers = ["TSLA", "SNAP"] strategies = [StrategyCII()] manager = \ StrategyManager( strategies=strategies, tickers=tickers ) stocks_per_strategy = manager.stocks_per_strategy for stock_per_strategy in stocks_per_strategy: for stock in stocks_per_strategy[stock_per_strategy]: print(stock.price_info) plotter = Plotter(period=1000) plotter.plot_stock(stock, collapse_indicators=False) print("Analysis has been run") if DEVELOPMENT == True: plt.show() test_date = "14/07/2020" test_df = stocks_per_strategy[StrategyCII.name][0].price_info ticker = "TSLA" values = [318.0, 286.2, 311.2, 303.359, 117090500.0] i = 0 for metric in ["High", "Low", "Open", "Close", "Volume"]: value = TestIndicators.truncate(test_df[ticker][metric].loc[ test_df[ticker][metric].index == datetime.datetime.strptime( test_date, "%d/%m/%Y")].iloc[0]) assert value == TestIndicators.truncate(values[i]), value i += 1
def test_legend(self): plotter = Plotter() assert plotter.get_legend_position() == "upper left" assert plotter.get_legend_position() == "upper center" assert plotter.get_legend_position() == "upper right" assert plotter.get_legend_position() == "center left" assert plotter.get_legend_position() == "lower left" assert plotter.get_legend_position() == "lower center" assert plotter.get_legend_position() == "lower right" assert plotter.get_legend_position() == "center right" assert plotter.get_legend_position() == "center" assert plotter.get_legend_position() == "right" assert plotter.get_legend_position() == "upper left" assert plotter.get_legend_position() == "upper center"
from datetime import datetime from plotter.DataProcessor import DataProcessor from plotter.Database import Database from plotter.Plotter import Plotter if __name__ == "__main__": database = Database() plotter = Plotter() processor = DataProcessor(database) # plotter.save_bar('All tweets count', processor.process_count()) # # for category in database.find_all_categories(): # line, bar = processor.process_sentiment_for_category(category) # plotter.save_line_and_bar(category, 'Sentiment', 'Total count', line, bar) # # comparisons = [('democratic', 'republican'), ('Trump', 'Clinton')] # for comparison in comparisons: # data = processor.process_sentiment_for_categories(comparison) # legend = [d[0] for d in data] # lines = [d[1] for d in data] # bars = [d[2] for d in data] # plotter.save_many_lines_and_bars('{0} vs {1}'.format(comparison[0], comparison[1]), 'Sentiment', 'Total count', legend, lines, bars) START_DATE = datetime(2015, 10, 01) END_DATE = datetime(2015, 11, 11) users = ['realDonaldTrump', 'HillaryClinton', 'JebBush', 'tedcruz', 'BernieSanders'] for user in users: line, bar = processor.process_sentiment_for_user(user, START_DATE, END_DATE) plotter.save_line_and_bar(user, 'Sentiment', 'Total count', line, bar)