Esempio n. 1
0
 def test_sanitize_order_default_quantity(self):
     """
     If no quantity is given, quantity is 1
     """
     market = Market(None)
     self.assertEqual(market.sanitize_order(
         {'direction':BUY, 'agent': None})['quantity'], 1)
Esempio n. 2
0
 def test_sanitize_order_quantity(self):
     """
     If quantity in raw desire, use it
     """
     market = Market(None)
     self.assertEqual(market.sanitize_order(
         {'direction':SELL, 'quantity':200, 'agent': None})['quantity'], 200)
Esempio n. 3
0
 def test_sanitize_order_price(self):
     """
     If price in raw order, use it
     """
     market = Market(None)
     self.assertAlmostEqual(market.sanitize_order(
         {'direction':SELL, 'price':3.85, 'agent': None})['price'], 3.85, 2)
Esempio n. 4
0
 def test_sanitize_order_default_price(self):
     """
     If no price is given, price is best limit
     """
     market = Market(None)
     self.assertEqual(market.sanitize_order(
         {'direction':BUY, 'agent': None})['price'], 'unset sellbook')
     self.assertEqual(market.sanitize_order(
         {'direction':SELL, 'agent': None})['price'], 'unset buybook')
Esempio n. 5
0
 def test_sanitize_order_default_quantity(self):
     """
     If no quantity is given, quantity is 1
     """
     market = Market(None)
     self.assertEqual(
         market.sanitize_order({
             'direction': BUY,
             'agent': None
         })['quantity'], 1)
Esempio n. 6
0
 def test_sanitize_order_quantity(self):
     """
     If quantity in raw desire, use it
     """
     market = Market(None)
     self.assertEqual(
         market.sanitize_order({
             'direction': SELL,
             'quantity': 200,
             'agent': None
         })['quantity'], 200)
Esempio n. 7
0
 def test_sanitize_order_price(self):
     """
     If price in raw order, use it
     """
     market = Market(None)
     self.assertAlmostEqual(
         market.sanitize_order({
             'direction': SELL,
             'price': 3.85,
             'agent': None
         })['price'], 3.85, 2)
Esempio n. 8
0
 def test_sanitize_order_default_price(self):
     """
     If no price is given, price is best limit
     """
     market = Market(None)
     self.assertEqual(
         market.sanitize_order({
             'direction': BUY,
             'agent': None
         })['price'], 'unset sellbook')
     self.assertEqual(
         market.sanitize_order({
             'direction': SELL,
             'agent': None
         })['price'], 'unset buybook')
Esempio n. 9
0
 def test_sanitize_order_direction(self):
     """
     No direction in order shoud raise MissingParameter
     """
     market = Market(None)
     self.assertRaises(MissingParameter, market.sanitize_order, {
         'price': 3,
         'agent': None
     })
Esempio n. 10
0
 def __init__(self, parameters=None):
     Market.__init__(self, parameters)
Esempio n. 11
0
 def test_output_file_default_value(self):
     """
     Outputfile default value is sys.stdout
     """
     market = Market(None)
     self.assertEqual(market.outputfile, sys.stdout)
Esempio n. 12
0
 def __init__(self, parameters=None):
     Market.__init__(self, parameters)
Esempio n. 13
0
 def test_is_valid_not_implemented(self):
     """
     Market.is_valid() method should be implemented in subclasses
     """
     market = Market(None)
     self.assertRaises(NotImplementedError, market.is_valid, None, None)