Exemplo n.º 1
0
 def test_calculate_mixed_long_call_end_two_year_after(self):
     ds = datetime(2010, 1, 1, 21, 30, 0, tzinfo=pytz.UTC)
     de = datetime(2012, 1, 2, 6, 30, 0, tzinfo=pytz.UTC)
     cp = CallPrice(started_at=ds, ended_at=de)
     expected = (
         Decimal('0.36')  # call
         + (60 * Decimal('0.09'))  # first and last day
         + (2 * 365 * 16 * 60 * Decimal('0.09'))  # two years
     )
     self.assertEqual(cp.calculate(), expected)
Exemplo n.º 2
0
 def test_calculate_mixed_long_call_ending_day_after_as_standard(self):
     ds = datetime(2010, 1, 1, 21, 30, 0, tzinfo=pytz.UTC)
     de = datetime(2010, 1, 2, 6, 30, 0, tzinfo=pytz.UTC)
     cp = CallPrice(started_at=ds, ended_at=de)
     expected = Decimal('0.36') + (2 * (30 * Decimal('0.09')))
     self.assertEqual(cp.calculate(), expected)
Exemplo n.º 3
0
 def test_calculate_mixed_long_call_pass_midnight(self):
     ds = datetime(2010, 1, 1, 21, 30, 0, tzinfo=pytz.UTC)
     de = datetime(2010, 1, 2, 2, 30, 0, tzinfo=pytz.UTC)
     cp = CallPrice(started_at=ds, ended_at=de)
     expected = Decimal('0.36') + (30 * Decimal('0.09'))
     self.assertEqual(cp.calculate(), expected)
Exemplo n.º 4
0
 def test_calculate_standard_short_call(self):
     ds = datetime(2010, 1, 1, 20, 30, 0, tzinfo=pytz.UTC)
     de = datetime(2010, 1, 1, 20, 33, 0, tzinfo=pytz.UTC)
     cp = CallPrice(started_at=ds, ended_at=de)
     expected = Decimal('0.36') + (3 * Decimal('0.09'))
     self.assertEqual(cp.calculate(), expected)
Exemplo n.º 5
0
 def test_calculate_equal_values_return_zero(self):
     ds = de = datetime(2011, 11, 11, 2, 2, 2, tzinfo=pytz.UTC)
     cp = CallPrice(started_at=ds, ended_at=de)
     self.assertEqual(cp.calculate(), Decimal('0.00'))
Exemplo n.º 6
0
 def set_price(self):
     '''Set's the call price when completed.
     '''
     if self.is_completed:
         call_price = CallPrice(*self._date_range())
         self.price = call_price.calculate()