Exemple #1
0
 def test_none(self):
     res = watcher.watch({
         'US.GOOG': {
             'upper': None,
             'lower': 8000
         },
         'US.FB': {
             'upper': 4,
             'lower': None
         }
     })
     self.assertEqual(len(res), 2)
     self.assertTrue(res['US.GOOG']['price'] < 8000)
     self.assertTrue(res['US.FB']['price'] > 4)
Exemple #2
0
 def test_happy(self):
     res = watcher.watch({
         'US.GOOG': {
             'upper': 9000,
             'lower': 8000
         },
         'US.FB': {
             'lower': 120
         },
         'US.MSFT': {
             'upper': 100
         }
     })
     self.assertTrue(res['US.GOOG']['price'] < 8000)
Exemple #3
0
 def test_inflate(self):
     monthAgo = datetime.now() - relativedelta.relativedelta(months=1)
     ticker = 'US.GOOG'
     quote = quoter.quote([ticker])[ticker]
     inflate = inflater.inflate({'date': monthAgo, 'factor': 0.18})
     res = watcher.watch({
         ticker: {
             'lower': quote,
             'upper': quote * 1.8,
             'date': monthAgo,
             'factor': 0.18
         },
     })
     self.assertEqual(len(res), 1)
     self.assertEqual(res[ticker]['inflate'], inflate['inflate'])
     self.assertTrue(res[ticker]['adjLower'] > res[ticker]['lower'])
     self.assertTrue(res[ticker]['adjUpper'] > res[ticker]['upper'])
Exemple #4
0
 def test_inflateNone(self):
     monthAgo = datetime.now() - relativedelta.relativedelta(months=1)
     ticker = 'US.GOOG'
     quote = quoter.quote([ticker, 'US.MSFT'])[ticker]
     print(quote)
     inflate = inflater.inflate({'date': monthAgo, 'factor': 0.18})
     print(inflate)
     conf = {
         ticker: {
             'lower': None,
             'upper': None,
             'date': monthAgo,
             'factor': 0.18
         },
     }
     res = watcher.watch(conf)
     self.assertEqual(conf[ticker]['inflate'], inflate['inflate'])
     self.assertFalse('adjLower' in conf[ticker])
     self.assertFalse('adjUpper' in conf[ticker])
Exemple #5
0
 def test_partition(self):
     conf = {'SH.600004': {}, 'SH.600276': {}, 'US.GOOG': {}}
     res = watcher.watch(conf)
     self.assertTrue(conf['SH.600004']['price'] > 0)
     self.assertTrue(conf['SH.600276']['price'] > 0)
     self.assertTrue(conf['US.GOOG']['price'] > 0)
Exemple #6
0
 def test_empty(self):
     self.assertEqual(watcher.watch({}), {})
Exemple #7
0
 def test_sideEffect(self):
     conf = {'US.GOOG': {'upper': 90000, 'lower': 1}}
     res = watcher.watch(conf)
     self.assertEqual(res, {})
     self.assertTrue(conf['US.GOOG']['price'] > 0)
Exemple #8
0
 def test_unhappy(self):
     res = watcher.watch({'unhappy': None})
     self.assertEqual(res, {})