コード例 #1
0
    def test(self):

        result = True
        self.assertEqual(result, True, "OH NO!")

        # Get the data
        #         mkt = Market("Test-bitcoin-SuperTrend")
        mkt = Market.fromTesting(test_file)
        mkt_data = mkt.readMarketDataCSV(p_testing=True)

        # Create the Indicator
        p_wma_period = 90
        p_wma_column = "Close"
        p_fast_st_multiplier = 3
        p_fast_st_period = 15
        p_slow_st_multiplier = 3.5
        p_slow_st_period = p_fast_st_period
        stc = SuperTrendCross(p_wma_period, p_wma_column, p_fast_st_multiplier,
                              p_fast_st_period, p_slow_st_multiplier,
                              p_slow_st_period)

        print()
        print()
        print()
        print("=== Super Trend Cross Calc === === === === === ")
        print()
        print()
        print()
        print("=== Original market ================")
        print(mkt_data.head(0))
        print(mkt_data.tail(5))

        # Calculate the indicator
        stc.calculate(mkt_data)

        # Print Results
        print()
        print()
        print()
        print("=== Super Trend Cross Calc === === === === === ")
        print(mkt_data.head(5))
        print(mkt_data.tail(10))

        #         xlApp=win32com.client.Dispatch("Excel.Application")
        #         wb = xlApp.Workbooks.Open(Filename="C:\Full Location\To\excelsheet.xlsm")

        #         # WRITE IN DATA FRAME TO SHEET 5
        writer = ExcelWriter(settings.testing_file_path + 'Test Results.xlsx')
        mkt_data.to_excel(writer, 'Results')
        writer.save()
コード例 #2
0
    def test(self):

        # Test Parameters
        output_info = True
        target_file = "Results-bitcoin-SuperTrend"
        test_file = "bitcoin_TEST"
        target_columns = [
            "Date", "H-L", "H-PC", "L-PC", "True_Range", "ATR_15", "basic_ub",
            "basic_lb", "final_ub", "final_lb", "Super_Trend"
        ]
        test_columns = [
            "Date", "H-L", "H-PC", "L-PC", "True_Range", "ATR_15", "basic_ub",
            "basic_lb", "final_ub", "final_lb", "Super_Trend"
        ]
        # ["Date","H-L","H-PC","L-PC","TR","ATR","BUB","BLB","FUB","FLB","ST"]
        st_period = 15
        st_multiplier = 3
        st_name_extension = ""

        # Output Headings
        print("This is a test of SUPERTREND")
        print("Test Data: " + test_file + "    Target Data: " + target_file)
        print("Columns: " + str(test_columns))
        print("Parameters: period: " + str(st_period) + "   Multiplier: " +
              str(st_multiplier))

        # Get the data
        mkt = Market.fromTesting(test_file)
        mkt_data = mkt.readMarketDataCSV(p_testing=True)

        # Calcualte the Indicators
        supertrend = SuperTrend(st_period, st_multiplier, st_name_extension)
        mkt_data = supertrend.calculate(mkt_data)

        # Read in the target results
        target_data = self.readTargetResults(target_file, target_columns)

        # Format boolean columns
        # None                       # convert to boolean

        # Output the Testing Results
        if output_info:
            print()
            print()
            print()
            print("=== Target_data . head  === === === === === ")
            print(target_data.head(16))
            print()
            print("=== Target_data . tail === === === === === ")
            print(target_data.tail(5))

            print()
            print()
            print()
            print("=== Market data Results . head === === === === === ")
            print(mkt_data.head(16))  #[test_columns]
            print()
            print("=== Market data Results . tail === === === === === ")
            print(mkt_data.tail(5))  # [test_columns]

        # Assertions
        if output_info:
            print()
            print("=== Series Equal DATE === === === === === ")
            #             assert_series_equal( mkt_data["Date"], target_data["Date"])
            print("PASS")
コード例 #3
0
        data = [1, 1, 2, 3, 5, 8, 13, 21, 34]

        #         plt.figure
        #         plt.title('mike', size = 'xx-large')
        #         plt.plot(data)
        #         plt.show()
        #         %matplotlib inline
        plt.ion()
        plt.plot(data)
        pylab.show()


if __name__ == "__main__":

    mkt_name = "Bitcoin_Test"
    mkt = Market.fromTesting(mkt_name)
    mkt_data = mkt.readMarketDataCSV(p_testing=True)

    graph = GraphCandlestick2()
    quotes = mkt_data.iloc[0:3, :4]
    print("quotes")
    print(quotes.head(5))
    #graph.graph_data(quotes)
    graph.testGraph()

    plt.switch_backend("macosx")
    plt.plot([1, 2, 3, 4])
    plt.ylabel('some numbers')
    plt.show()
    print("plotted")
コード例 #4
0
    def test(self):
        print("This is a test of CROSSES")

        # Test Parameters
        output_info = False
        target_file = "Results-bitcoin-Crosses"
        test_file = "bitcoin_TEST"
        target_columns = ["Date", "MA_15", "MA_30", "Crossesdiff", "Crosses"
                          ]  # ["Date","MA_15","MA_30","TGT_DIFF","TGT_CROSS"]
        test_columns = ["Date", "MA_15", "MA_30", "Crossesdiff", "Crosses"]

        # Get the data
        mkt = Market.fromTesting(test_file)
        mkt_data = mkt.readMarketDataCSV(p_testing=True)

        # Calcualte the Indicators
        mkt_data = MovingAverage(15, "Close").calculate(mkt_data)
        mkt_data = MovingAverage(30, "Close").calculate(mkt_data)
        crosses = Crosses("MA_15", "MA_30", "Up")
        mkt_data = crosses.calculate(mkt_data)

        # Read in the target results
        target_data = self.readTargetResults(target_file, target_columns)

        # Format boolean columns
        target_data[
            "Crosses"] = target_data["Crosses"] == 1  # convert to boolean

        # Output the Testing Results
        if output_info:
            print()
            print()
            print()
            print("=== Target_data . head  === === === === === ")
            print(target_data.head(16))
            print()
            print("=== Target_data . tail === === === === === ")
            print(target_data.tail(5))

            print()
            print()
            print()
            print("=== Market data Results . head === === === === === ")
            print(mkt_data[test_columns].head(16))
            print()
            print("=== Market data Results . tail === === === === === ")
            print(mkt_data[test_columns].tail(5))

        # Assertions
        if output_info:
            print()
            print("=== Series Equal DATE === === === === === ")
            assert_series_equal(mkt_data["Date"], target_data["Date"])
            print("PASS")
            print()
            print("=== Series Equal MA_15 === === === === === ")
            assert_series_equal(mkt_data["MA_15"], target_data["MA_15"])
            print("PASS")
            print()
            print("=== Series Equal MA_30 === === === === === ")
            assert_series_equal(mkt_data["MA_30"], target_data["MA_30"])
            print("PASS")
            print()
            print("=== Series Equal Crossesdiff === === === === === ")
            assert_series_equal(mkt_data["Crossesdiff"],
                                target_data["Crossesdiff"])
            print("PASS")
            print()
            print("=== Series Equal Crosses === === === === === ")
            print(mkt_data[mkt_data["Crosses"] == True].count())
            print(target_data[target_data["Crosses"] == True].count())
            assert_series_equal(mkt_data["Crosses"], target_data["Crosses"])
            print("PASS")
        print()
        print("=== DataFrame Equal === === === === === ")
        assert_frame_equal(mkt_data[test_columns], target_data)
        print("PASS")