Пример #1
0
 def test_amend_futures_trade_with_fields(self):
     if self.trade_class == FuturesTrade:
         ft = FuturesTrade.get_trade_example()
         self.database.add_trade(ft)
         amend_dict = {"price": 1234.56, "num_contracts": 654321}
         self.database.amend_trade_with_fields(1, amend_dict)
         amended_trade_from_db = self.database.select_trade_from_id(1)
         self.assertTrue(amended_trade_from_db.price == 1234.56 and
                         amended_trade_from_db.num_contracts == 654321)
Пример #2
0
 def test_create_futures_trade_too_little_year(self):
     if self.trade_class == FuturesTrade:
         with self.assertRaises(ValueError):
             datetime_ = datetime.datetime(20, 9, 9, 9, 0, 0)
             FuturesTrade(-1, datetime_, "RX", 12, 2013, -15, 137.52, "pierre")
Пример #3
0
 def test_create_futures_trade(self):
     if self.trade_class == FuturesTrade:
         datetime_ = datetime.datetime(2013, 9, 9, 9, 0, 0)
         futures_trade = FuturesTrade(-1, datetime_, "RX", 12, 2013, -15, 137.52, "pierre")
         self.assertTrue(isinstance(futures_trade, self.trade_class))
Пример #4
0
 def test_amend_trade_with_incorrect_type(self):
     with self.assertRaises(TypeError):
         ft = FuturesTrade.get_trade_example()
         self.database.add_trade(ft)
         spotfxt = SpotFXTrade.get_trade_example()
         self.database.amend_trade_with_trade(1, spotfxt)
Пример #5
0
 def test_amend_futures_trade_with_incorrect_maturity(self):
     if self.trade_class == FuturesTrade:
         with self.assertRaises(ValueError):
             futures_trade = FuturesTrade.get_trade_example()
             self.database.add_trade(futures_trade)
             self.database.amend_trade_with_field(1, "year", 1999)