예제 #1
0
    def get_events_maturity(self, new_security, old_security):
        maturity_events = []

        maturity_date = new_security.get('MaturityDate')

        if maturity_date:
            if events_booking_utils.is_new_event(new_security, old_security,
                                                 ['MaturityDate']):
                # This is to handle if the date is saved as '0001-01-01T00:00:00Z'
                if not events_booking_utils.is_valid_datetime_fields(
                        maturity_date):
                    return []
                event_maturity = {
                    'Date':
                    maturity_date,
                    'Security':
                    new_security['Key'],
                    'EventType':
                    'CDSMaturity',
                    'Status':
                    1,
                    'Description':
                    '[Maturity CDS] Maturity date {}'.format(
                        events_booking_utils.get_date_display_fmt(
                            maturity_date)),
                    'Username':
                    '******'
                }
                self._logger.info('Maturity event returned')
                maturity_events.append(event_maturity)
        else:
            self._logger.warning(
                'The security {} does not have a maturity date'.format(
                    new_security['Key']))
        return maturity_events
예제 #2
0
    def get_events_coupon(self, new_security, old_security):
        coupon_events = []

        coupon_dates_ls = new_security.get('CouponDateList')
        coupon_rate = new_security.get('Coupon', 0)

        if coupon_dates_ls:
            if events_booking_utils.is_new_event(new_security, old_security,
                                                 ['CouponDateList', 'Coupon']):
                for cpd in coupon_dates_ls:
                    event_cpn = {
                        'Date':
                        cpd,
                        'Security':
                        new_security['Key'],
                        'EventType':
                        'CDSCouponPayment',
                        'CouponRate':
                        coupon_rate,
                        'Status':
                        1,
                        'Description':
                        '[CouponPayment CDS] Rate - {} Coupon date {}'.format(
                            coupon_rate,
                            events_booking_utils.get_date_display_fmt(cpd)),
                        'Username':
                        '******'
                    }
                    coupon_events.append(event_cpn)
                self._logger.info('{} coupon events returned'.format(
                    len(coupon_events)))

        return coupon_events
    def get_events_conversion(self, new_security, old_security):
        convertible_events = []

        convertible_date = new_security.get('LastConvertibleDate')
        underlying = new_security.get('Underlying')
        conversion_ratio = int(new_security.get('ConversionRatio'))

        if convertible_date and underlying and conversion_ratio:
            if events_booking_utils.is_new_event(new_security, old_security, ['LastConvertibleDate', 'Underlying', 'ConversionRatio']):
                # This is to handle if the date is saved as '0001-01-01T00:00:00Z'
                if not events_booking_utils.is_valid_datetime_fields(convertible_date):
                    return []
                event_conversion = {
                    'Date': convertible_date,
                    'Security': new_security['Key'],
                    'EventType': 'BondConversion',
                    'Status': 1,
                    'Description': '[Conversion Bond] Convertible date {}'.format(
                        events_booking_utils.get_date_display_fmt(convertible_date)),
                    'Underlying': new_security['Underlying'],
                    'ConversionRatio': new_security['ConversionRatio'],
                    'ConversionPrice': new_security['ConversionPrice'],
                    'Username': '******'
                }
                self._logger.info('Bond convertible event returned')
                convertible_events.append(event_conversion)
        else:
            self._logger.warning(
                'Convertible bond security {} does not have convertible date, underlying or conversion ratio'.format(new_security['Key']))
        return convertible_events
예제 #4
0
    def get_events_expiry(self, new_security, old_security):
        expiry_events = []

        expiry_date = new_security.get('ExpiryDateTime')

        if expiry_date:
            if events_booking_utils.is_new_event(new_security, old_security, ['ExpiryDateTime']):
                # This is to handle if the date is saved as '0001-01-01T00:00:00Z'
                if not events_booking_utils.is_valid_datetime_fields(expiry_date):
                    return []
                event_expiry = {
                    'Date': expiry_date,
                    'Security': new_security['Key'],
                    'EventType': 'FutureExpiry',
                    'Status': 1,
                    'Description': '[Expiry Future] Expiry date: {}'.format(
                        events_booking_utils.get_date_display_fmt(expiry_date)),
                    'AssetClass': new_security['AssetClass'],
                    'Underlying': new_security['Underlying'],
                    'Name': new_security['Name'],
                    'Username': '******'
                }
                self._logger.info('Expiry event returned')
                expiry_events.append(event_expiry)
        else:
            self._logger.warning(
                'The Futures {} does not have a expiry date'.format(new_security['Key']))
        return expiry_events
    def get_events_callable_puttable(self, new_security, old_security, put_call):
        events = []
        schedule_property = put_call + 'Schedule'
        event_type = put_call + 'Date'
        schedule_dates_ls = new_security.get(schedule_property)

        if schedule_dates_ls:
            if events_booking_utils.is_new_event(new_security, old_security, [schedule_property]):
                for schedule_date in schedule_dates_ls:
                    event_date = {
                        'Date': schedule_date['Date'],
                        'Security': new_security['Key'],
                        'EventType': event_type,
                        'Status': 'Active',
                        'PutCallPrice': schedule_date['Price'],
                        'Description': '[{}] {} @ {}'.format(event_type, new_security['Name'], schedule_date['Price']),
                        'Username': '******'
                    }
                    events.append(event_date)
                self._logger.info(
                    '{} {} date events returned'.format(len(events), put_call))

        return events
    def get_events_expiry(self, new_security, old_security):
        expiry_events = []

        expiry_date = new_security.get('ExpiryDateTime')
        put_call_flag = new_security.get('PutCallFlag')
        settlement_type = new_security.get('SettlementType')
        strike = new_security.get('Strike')
        underlying = new_security.get('Underlying')

        if not expiry_date:
            self._logger.warning(
                'Equity Option {} does not have a expiry date'.format(
                    new_security['Key']))
        else:
            if events_booking_utils.is_new_event(new_security, old_security, [
                    'ExpiryDateTime', 'PutCallFlag', 'SettlementType',
                    'Strike', 'Underlying'
            ]):
                # This is to handle if the date is saved as '0001-01-01T00:00:00Z'
                if not events_booking_utils.is_valid_datetime_fields(
                        expiry_date):
                    return []
                if not put_call_flag:
                    self._logger.warning(
                        'The Equity Option {} has an invalid put/call flag {}. Please check'
                        .format(new_security['Key'], put_call_flag))
                if not settlement_type:
                    self._logger.warning(
                        'The Equity Option {} has an invalid settlement type {}. Please check'
                        .format(new_security['Key'], settlement_type))
                if not strike:
                    self._logger.warning(
                        'The Equity Option {} has an invalid strike {}. Please check'
                        .format(new_security['Key'], strike))
                if not underlying:
                    self._logger.warning(
                        'The Equity Option {} has an invalid underlying {}. Please check'
                        .format(new_security['Key'], underlying))
                event_expiry = {
                    'Date':
                    expiry_date,
                    'Security':
                    new_security['Key'],
                    'EventType':
                    'OptionExpiry',
                    'Status':
                    1,
                    'Description':
                    '[Expiry Equity Option] Expiry date: {}, [Name] Name: {}, [PutCallFlag] Put Call flag: {}, [SettlementTYpe] Settlement type: {}, [Strike] Strike: {}, [Underlying] Underlying: {}'
                    .format(
                        events_booking_utils.get_date_display_fmt(expiry_date),
                        new_security.get('Name'), put_call_flag,
                        settlement_type, strike, underlying),
                    'AssetClass':
                    new_security.get('AssetClass'),
                    'Name':
                    new_security.get('Name'),
                    'PutCallFlag':
                    put_call_flag,
                    'SettlementType':
                    settlement_type,
                    'Strike':
                    strike,
                    'Underlying':
                    underlying,
                    'Username':
                    '******'
                }
                self._logger.info('Expiry event returned')
                expiry_events.append(event_expiry)
        return expiry_events