Exemple #1
0
        def test_datetime(self, mock_trade_close_init):
            trade = TradeFactory()

            trade.close(close_value=100, datetime="test")

            assert mock_trade_close_init.call_count == 1
            assert mock_trade_close_init.call_args_list[0][1][
                "datetime"] == "test"
Exemple #2
0
        def test_close_value(self, mock_trade_close_init):
            trade = TradeFactory(quantity=2)

            trade.close(close_value=100, datetime=arrow.utcnow())

            assert mock_trade_close_init.call_count == 1
            assert mock_trade_close_init.call_args_list[0][1][
                "close_value"] == 100
Exemple #3
0
        def test_kwargs(self, mock_trade_close_init):
            trade = TradeFactory(quantity=2)

            trade.close(close_value=100,
                        datetime=arrow.utcnow(),
                        random_arg="test")

            assert mock_trade_close_init.call_args_list[0][1][
                "random_arg"] == "test"
Exemple #4
0
        def test_append_to_closes(self, mocker):
            mocker.patch(f"{CLASS_TRADE_CLOSE_DEFINITION_PATH}",
                         return_value="new_close")

            trade = TradeFactory()

            trade.close(close_value=100, datetime="test")

            assert trade.closes == ["new_close"]
Exemple #5
0
        def test_quantities(self, mock_trade_close_init, quantity,
                            expected_quantity):
            trade = TradeFactory(quantity=5)

            trade.close(close_value=100,
                        datetime=arrow.utcnow(),
                        quantity=quantity)

            assert mock_trade_close_init.call_count == 1
            assert (mock_trade_close_init.call_args_list[0][1]["quantity"] ==
                    expected_quantity)
Exemple #6
0
        def test_return_close(self, mocker):
            mocker.patch(f"{CLASS_TRADE_CLOSE_DEFINITION_PATH}",
                         return_value="new_close")

            trade = TradeFactory()

            response = trade.close(close_value=100, datetime="test")

            assert response == "new_close"