ppf/core/generate_observables.py
def generate_fixed_coupon_observables(
   start
 , end
 , roll_period = 6
 , roll_duration = ppf.date_time.months
 , reset_currency = "USD"
 , coupon_holiday_centres = None
 , coupon_shift_method = ppf.date_time.shift_convention.modified_following
 , coupon_rate = 0.05
 , *arguments
 , **keywords):
  '''Generate a sequence of fixed coupons.
  
  >>> from ppf.date_time import *
  >>> observables = generate_fixed_coupon_observables(
  ...     start  = date(2007, Jun, 29)
  ...   , end  = date(2017, Jun, 29)
  ...   , roll_period = 6
  ...   , coupon_shift_method = shift_convention.modified_following
  ...   , coupon_rate = 0.045)
  >>> for obs_per_flow in observables:
  ...  for obs in obs_per_flow:
  ...   print obs
  "0.000000", "0.000000", "USD", "0.045000", 
  "1.000000", "0.000000", "USD", "0.045000", 
  "2.000000", "0.000000", "USD", "0.045000", 
  "3.000000", "0.000000", "USD", "0.045000", 
  "4.000000", "0.000000", "USD", "0.045000", 
  "5.000000", "0.000000", "USD", "0.045000", 
  "6.000000", "0.000000", "USD", "0.045000", 
  "7.000000", "0.000000", "USD", "0.045000", 
  "8.000000", "0.000000", "USD", "0.045000", 
  "9.000000", "0.000000", "USD", "0.045000", 
  "10.000000", "0.000000", "USD", "0.045000", 
  "11.000000", "0.000000", "USD", "0.045000", 
  "12.000000", "0.000000", "USD", "0.045000", 
  "13.000000", "0.000000", "USD", "0.045000", 
  "14.000000", "0.000000", "USD", "0.045000", 
  "15.000000", "0.000000", "USD", "0.045000", 
  "16.000000", "0.000000", "USD", "0.045000", 
  "17.000000", "0.000000", "USD", "0.045000", 
  "18.000000", "0.000000", "USD", "0.045000", 
  "19.000000", "0.000000", "USD", "0.045000", 
  '''

  from ppf.date_time import days
  shift = ppf.date_time.shift

  flow_id = 0
  day = 0
  all_observables = []
  while day < end:
    roll_start = start + roll_duration(flow_id*roll_period)
    roll_end = start + roll_duration((flow_id+1)*roll_period)
    reset_id = 0
    observables = []
    reset_date = shift(roll_start, coupon_shift_method, coupon_holiday_centres)
    observables.append(fixed_coupon(None, flow_id, reset_currency, reset_date, coupon_rate) )
    day = roll_end
    all_observables.append(observables)
    flow_id += 1
  
  return all_observables
Generate a sequence of fixed coupons.
  
  >>> from ppf.date_time import *
  >>> observables = generate_fixed_coupon_observables(
  ...     start  = date(2007, Jun, 29)
  ...   , end  = date(2017, Jun, 29)
  ...   , roll_period = 6
  ...   , coupon_shift_method = shift_convention.modified_following
  ...   , coupon_rate = 0.045)
  >>> for obs_per_flow in observables:
  ...  for obs in obs_per_flow:
  ...   print obs
  "0.000000", "0.000000", "USD", "0.045000", 
  "1.000000", "0.000000", "USD", "0.045000", 
  "2.000000", "0.000000", "USD", "0.045000", 
  "3.000000", "0.000000", "USD", "0.045000", 
  "4.000000", "0.000000", "USD", "0.045000", 
  "5.000000", "0.000000", "USD", "0.045000", 
  "6.000000", "0.000000", "USD", "0.045000", 
  "7.000000", "0.000000", "USD", "0.045000", 
  "8.000000", "0.000000", "USD", "0.045000", 
  "9.000000", "0.000000", "USD", "0.045000", 
  "10.000000", "0.000000", "USD", "0.045000", 
  "11.000000", "0.000000", "USD", "0.045000", 
  "12.000000", "0.000000", "USD", "0.045000", 
  "13.000000", "0.000000", "USD", "0.045000", 
  "14.000000", "0.000000", "USD", "0.045000", 
  "15.000000", "0.000000", "USD", "0.045000", 
  "16.000000", "0.000000", "USD", "0.045000", 
  "17.000000", "0.000000", "USD", "0.045000", 
  "18.000000", "0.000000", "USD", "0.045000", 
  "19.000000", "0.000000", "USD", "0.045000", 
  
Generate a sequence of fixed coupons.
Generate a sequence of fixed coupons .
def generate_fixed_coupon_observables(
   start
 , end
 , roll_period = 6
 , roll_duration = ppf.date_time.months
 , reset_currency = "USD"
 , coupon_holiday_centres = None
 , coupon_shift_method = ppf.date_time.shift_convention.modified_following
 , coupon_rate = 0.05
 , *arguments
 , **keywords):
  from ppf.date_time import days
  shift = ppf.date_time.shift
  flow_id = 0
  day = 0
  all_observables = []
  while day < end:
    roll_start = start + roll_duration(flow_id*roll_period)
    roll_end = start + roll_duration((flow_id+1)*roll_period)
    reset_id = 0
    observables = []
    reset_date = shift(roll_start, coupon_shift_method, coupon_holiday_centres)
    observables.append(fixed_coupon(None, flow_id, reset_currency, reset_date, coupon_rate) )
    day = roll_end
    all_observables.append(observables)
    flow_id += 1
  return all_observables
def generate_fixed_coupon_observables ( start , end , roll_period = 6 , roll_duration = ppf . date_time . months , reset_currency = "USD" , coupon_holiday_centres = None , coupon_shift_method = ppf . date_time . shift_convention . modified_following , coupon_rate = 0.05 , * arguments , ** keywords ) : from ppf . date_time import days shift = ppf . date_time . shift flow_id = 0 day = 0 all_observables = [ ] while day < end : roll_start = start + roll_duration ( flow_id * roll_period ) roll_end = start + roll_duration ( ( flow_id + 1 ) * roll_period ) reset_id = 0 observables = [ ] reset_date = shift ( roll_start , coupon_shift_method , coupon_holiday_centres ) observables . append ( fixed_coupon ( None , flow_id , reset_currency , reset_date , coupon_rate ) ) day = roll_end all_observables . append ( observables ) flow_id += 1 return all_observables
Generate a sequence of fixed coupons.
Generate a sequence of fixed coupons .
'''Generate a sequence of fixed coupons.
  
  >>> from ppf.date_time import *
  >>> observables = generate_fixed_coupon_observables(
  ...     start  = date(2007, Jun, 29)
  ...   , end  = date(2017, Jun, 29)
  ...   , roll_period = 6
  ...   , coupon_shift_method = shift_convention.modified_following
  ...   , coupon_rate = 0.045)
  >>> for obs_per_flow in observables:
  ...  for obs in obs_per_flow:
  ...   print obs
  "0.000000", "0.000000", "USD", "0.045000", 
  "1.000000", "0.000000", "USD", "0.045000", 
  "2.000000", "0.000000", "USD", "0.045000", 
  "3.000000", "0.000000", "USD", "0.045000", 
  "4.000000", "0.000000", "USD", "0.045000", 
  "5.000000", "0.000000", "USD", "0.045000", 
  "6.000000", "0.000000", "USD", "0.045000", 
  "7.000000", "0.000000", "USD", "0.045000", 
  "8.000000", "0.000000", "USD", "0.045000", 
  "9.000000", "0.000000", "USD", "0.045000", 
  "10.000000", "0.000000", "USD", "0.045000", 
  "11.000000", "0.000000", "USD", "0.045000", 
  "12.000000", "0.000000", "USD", "0.045000", 
  "13.000000", "0.000000", "USD", "0.045000", 
  "14.000000", "0.000000", "USD", "0.045000", 
  "15.000000", "0.000000", "USD", "0.045000", 
  "16.000000", "0.000000", "USD", "0.045000", 
  "17.000000", "0.000000", "USD", "0.045000", 
  "18.000000", "0.000000", "USD", "0.045000", 
  "19.000000", "0.000000", "USD", "0.045000", 
  '''
start
end
roll_period
roll_duration
reset_currency
coupon_holiday_centres
coupon_shift_method
coupon_rate