예제 #1
0
    def test_buy_put_contract(self):
        proposal = tu.proposal_call_put(symbol=self.symbol,
                                        contract_type="PUT",
                                        duration=self.duration,
                                        duration_unit=self.duration_unit)

        expected_longcode = 'Win payout if {0} is strictly lower than entry spot at close on {1}.' \
                            .format(self.symbol_name, self.end_date)

        self.assert_longcode(proposal, expected_longcode)
예제 #2
0
    def test_buy_put_contract(self):
        proposal = tu.proposal_call_put(symbol=self.symbol,
                                        contract_type="PUT",
                                        duration=self.duration,
                                        duration_unit=self.duration_unit)
        expected_longcode = 'Win payout if {0} is strictly lower than entry spot at {1} ' \
                            'after contract start time.' \
            .format(self.symbol_name, self.contract_duration)

        self.assert_longcode(proposal, expected_longcode)
예제 #3
0
    def assert_valid_proposal(self, symbol, contract_type, duration,
                              duration_unit):
        if not tu.trading_day(symbol):
            self.skipTest("Skipped test due to weekend")
        else:
            proposal = tu.proposal_call_put(symbol=symbol,
                                            contract_type=contract_type,
                                            duration=duration,
                                            duration_unit=duration_unit)

            tu.print_if_error(proposal)
            self.assertTrue('error' not in proposal)
예제 #4
0
    def assert_invalid_parameter(self, symbol, contract_type, duration,
                                 duration_unit, error_code):
        if not tu.trading_day(symbol):
            self.skipTest("Skipped test due to weekend")
        else:
            proposal = tu.proposal_call_put(symbol=symbol,
                                            contract_type=contract_type,
                                            duration=duration,
                                            duration_unit=duration_unit)

            self.assertTrue('error' in proposal)

            if error_code != proposal["error"]["code"]:
                tu.print_if_error(proposal)
            self.assertEqual(error_code, proposal["error"]["code"])