Example #1
0
    def test_generate_test_instructions_nothing_to_do(self):
        portfolio = Portfolio.from_dict(self.base_portfolio)
        broker = Broker()
        (sell_list, buy_list) = broker._generate_trade_instructions(
            self.base_positions, portfolio)

        self.assertListEqual(sell_list, [])
        self.assertListEqual(buy_list, [])
Example #2
0
    def test_generate_test_instructions_no_positions(self):
        portfolio = Portfolio.from_dict(self.base_portfolio)
        broker = Broker()
        (sell_list, buy_list) = broker._generate_trade_instructions({},
                                                                    portfolio)

        self.assertListEqual(sell_list, [])
        self.assertListEqual(buy_list, ['BA', 'GE', 'XOM'])
Example #3
0
    def test_generate_test_instructions_with_buys(self):
        positions = deepcopy(self.base_positions)
        del positions['equities']['GE']
        del positions['equities']['XOM']

        portfolio = Portfolio.from_dict(self.base_portfolio)

        broker = Broker()
        (sell_list,
         buy_list) = broker._generate_trade_instructions(positions, portfolio)

        self.assertListEqual(sell_list, [])
        self.assertListEqual(buy_list, ['GE', 'XOM'])
Example #4
0
    def test_generate_test_instructions_with_sells(self):
        portfolio = deepcopy(self.base_portfolio)
        del portfolio['current_portfolio']['securities'][2]
        del portfolio['current_portfolio']['securities'][1]

        portfolio = Portfolio.from_dict(portfolio)

        broker = Broker()
        (sell_list, buy_list) = broker._generate_trade_instructions(
            self.base_positions, portfolio)

        self.assertListEqual(sell_list, [('GE', 1), ('XOM', 1)])
        self.assertListEqual(buy_list, [])