Пример #1
0
def addFixings():
    print '\n\n'

    curve = p.py_BuildCfetsCurve(curveName,
                                 anchorDate,
                                 indexName,
                                 tenors,
                                 rates,
                                 method,
                                 discCurveName=discCurveName)
    print 'Curve created: %s' % curve

    #   Create a swap to get the index object
    att = {
        'endDateTenor': '5Y',
        'notional': 50000000.0,
        'fixedRate': 0.035,
        'discCurveId': curveName,
        'fwdCurveId': curveName
    }
    p.py_CreateIRSwap(swapId, {'PredefinedConvention': 'CNY_REPO_7D'},
                      anchorDate, **att)

    fixings = readPilotScopeIndexFixings("../../data/fr007_fixing.csv")
    print '%s fixings loaded' % len(fixings)

    rc = p.py_IndexAddFixings(indexId, fixings.keys(), fixings.values())
    print 'Fixings added to %s' % rc

    rc = p.py_IndexFixings(indexId, [datetime.date(2017, 12, 18)],
                           fwdCurveId=curveName)
    print rc
Пример #2
0
    def _addFR007IndexFixings(self,
                              indexId,
                              fixingfileName="../../data/fr007_fixing.csv"):
        fixings = self.readPeakIndexFixings(fixingfileName)
        #         print '\n\n%s fixings loaded' % len(fixings)

        rc = p.py_IndexAddFixings(indexId, fixings.keys(), fixings.values())
Пример #3
0
    def _addShiborFixings(self,
                          indexId,
                          fixingfileName="../../data/shb3m_fixing.csv"):
        #         p.py_CreateIRSwap(dummyId, {'PredefinedConvention':'CNY_SHIBOR_3M'}, startDate, **att)
        fixings = self.readPeakIndexFixings(fixingfileName)
        #         print '\n\n%s fixings loaded' % len(fixings)

        rc = p.py_IndexAddFixings(indexId, fixings.keys(), fixings.values())
Пример #4
0
def runIMMDates():
    rc = p.py_IMMSymbolToDate(['F18', 'Z23'],
                              datetime.date(2017, 1, 25),
                              rule='CFFEXLT')
    print 'F18, Z23 IMM date: ', rc

    rc = p.py_IMMNextDates(startDate=datetime.date(2018, 1, 5),
                           numOfDates=20,
                           datePref='1m',
                           endDate=None)  #numOfDates has no effect
    print '\n1M IMM dates: ', rc

    p.py_IndexAddFixings(
        '_FR007', [datetime.date(2018, 1, 22),
                   datetime.date(2018, 1, 23)], [0.033, 0.034])
    print '\nIndex fixings added'

    dates = (datetime.date(2017, 12,
                           22), datetime.date(2018, 1,
                                              23), datetime.date(2018, 12, 24))
    fixings = p.py_IndexFixings('_CNY_REPO_7D', dates, fwdCurveId=curveName)
    print '\nFixings for ', dates, ': ', fixings
Пример #5
0
    def _addFR007IndexFixings(self):
        # create a dummy contract, just to get the index object
        att = {
            'endDateTenor': '1Y',
            'notional': 50000000.0,
            'fixedRate': 0.035
        }
        dummyId = '_dummy'
        startDate = datetime.date(2017, 12, 1)
        p.py_CreateIRSwap(dummyId, {'PredefinedConvention': 'CNY_REPO_7D'},
                          startDate, **att)
        info = p.py_SwapInfo([dummyId], 0, startDate)
        indexId = info['']['IndexObjectID']
        #         print '\n\nIndex object Id: %s' % indexId
        self.indexId = indexId

        fixings = self.readPeakIndexFixings("../../data/fr007_fixing.csv")
        #         print '\n\n%s fixings loaded' % len(fixings)

        rc = p.py_IndexAddFixings(indexId, fixings.keys(), fixings.values())
Пример #6
0
def runSwapInfo():

    # create a dummy swap, just to get the index object
    att = {'endDateTenor': '5Y', 'notional': 50000000.0, 'fixedRate': 0.035}
    dummyId = '_dummy'
    p.py_CreateIRSwap(dummyId, {'PredefinedConvention': 'CNY_REPO_7D'},
                      startDate, **att)
    rc = p.py_SwapInfo([dummyId], 0, startDate)
    print '\n\nSwap Info:'
    pprint.pprint(rc, width=1000)
    indexId = rc['']['IndexObjectID']
    print '\n\nIndex object Id: %s' % indexId

    fixings = readPeakIndexFixings("../../data/fr007_fixing.csv")
    print '\n\n%s fixings loaded' % len(fixings)

    rc = p.py_IndexAddFixings(indexId, fixings.keys(), fixings.values())
    print '\nFixings added to %s' % rc

    d = datetime.date(2017, 12, 18)
    rc = p.py_IndexFixings(indexId, [d])
    print '\nFixings without curve for %s is %s' % (d, rc)

    rc = p.py_CreateIRSwap(swapId, {'PredefinedConvention': 'CNY_REPO_7D'},
                           startDate, **att)
    rc = p.py_SwapInfo([swapId], 0, anchorDate)
    print '\n\nSwapInfo:'
    pprint.pprint(rc, width=1000)

    curve = p.py_BuildCfetsCurve(curveName,
                                 anchorDate,
                                 indexName,
                                 tenors,
                                 rates,
                                 method,
                                 discCurveName=discCurveName)
    print '\n\nCurve created: %s' % curve

    d1 = startDate + datetime.timedelta(days=7)
    df = p.py_YieldTSDiscount(curveName, [startDate, d1],
                              allowExtrapolation=True)
    print 'Discount factor for %s is %s' % ([startDate, d1], df)

    rc = p.py_IndexFixings(indexId, [d], fwdCurveId=curveName)
    print '\nFixings with curve for %s is %s' % (d, rc)

    npv = p.py_SwapLegNPV([swapId],
                          curveName,
                          discCurveName,
                          anchorDate,
                          True,
                          debugLevel=2)
    print '\nSwap NPV = %s' % npv

    rc = p.py_SwapLegAnalysis(swapId,
                              0,
                              afterDate=datetime.date(2018, 1, 25),
                              forwardCurveId=curveName,
                              discountCurveId='',
                              afterDateInclusive=False,
                              forecastTodaysFixing=True,
                              useSqlFriendlyColHeaders=True,
                              selectedColumns='All',
                              toDate=datetime.date(2100, 12, 31))
    print '\nSwapLegAnalysis:'
    pprint.pprint(rc, width=1000)

    rc = p.py_IndexName(indexId)
    print '\nIndex Name "%s"' % rc