예제 #1
0
    def test_some_closes(self, mocker):
        trade = TradeFactory()
        close_mock1 = mocker.Mock(spec=TradeClose)
        close_mock1.quantity = 3
        close_mock2 = mocker.Mock(spec=TradeClose)
        close_mock2.quantity = 2
        trade.closes = [close_mock2, close_mock1]

        assert trade.closed_quantities == 5
예제 #2
0
    def test_nominal(self, mocker):

        trade = TradeFactory()

        close_mock1 = mocker.Mock(spec=TradeClose)
        close_mock1.result = 65.89
        close_mock2 = mocker.Mock(spec=TradeClose)
        close_mock2.result = -34.91
        trade.closes = [close_mock2, close_mock1]

        assert trade.closed_result == (65.89 - 34.91)
예제 #3
0
    def test_nominal(self, mocker):
        mocker.patch(
            f"{CLASS_TRADE_DEFINITION_PATH}.closed_quantities",
            new_callable=PropertyMock(return_value=3),
        )

        trade = TradeFactory()

        close_mock1 = mocker.Mock(spec=TradeClose)
        close_mock1.result = 65.89
        close_mock2 = mocker.Mock(spec=TradeClose)
        close_mock2.result = -34.91
        trade.closes = [close_mock2, close_mock1]

        assert trade.closed_result_avg == round((65.89 - 34.91) / 3, 2)