def test_get_request_return_None_when_balance_is_smaller_than_total_value( self): bnh = StrategyBuyAndHold() bnh.initialize(5000, 10) dummy_info = {} dummy_info["closing_price"] = 62000000 bnh.update_trading_info(dummy_info) bnh.balance = 10000 requests = bnh.get_request() self.assertEqual(requests, None)
def test_get_request_return_None_when_balance_is_smaller_than_min_price( self): bnh = StrategyBuyAndHold() bnh.initialize(900, 10) bnh.is_simulation = False dummy_info = {} dummy_info["closing_price"] = 20000 bnh.update_trading_info(dummy_info) bnh.balance = 9.5 requests = bnh.get_request() self.assertEqual(requests, None)
def test_get_request_use_balance_when_balance_is_smaller_than_target_budget( self): bnh = StrategyBuyAndHold() bnh.initialize(1000, 10) dummy_info = {} dummy_info["closing_price"] = 20000 bnh.update_trading_info(dummy_info) bnh.balance = 100 requests = bnh.get_request() self.assertEqual(requests[0]["price"], 20000) self.assertEqual(requests[0]["amount"], 0.005)
def test_get_request_return_turn_over_when_balance_is_smaller_than_min_price_at_simulation( self, ): bnh = StrategyBuyAndHold() bnh.initialize(900, 10) bnh.is_simulation = True dummy_info = {} dummy_info["date_time"] = "2020-02-25T15:41:09" dummy_info["closing_price"] = 20000 bnh.update_trading_info(dummy_info) bnh.balance = 9.5 requests = bnh.get_request() self.assertEqual(requests[0]["price"], 0) self.assertEqual(requests[0]["amount"], 0)