Пример #1
0
    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
Пример #2
0
 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"