コード例 #1
0
ファイル: test_trade.py プロジェクト: cimourdain/estrade
    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
ファイル: test_trade.py プロジェクト: cimourdain/estrade
    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
ファイル: test_trade.py プロジェクト: cimourdain/estrade
    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)