exponenta event banner

removeInstrument

Изъять инструмент из портфеля инструментов

Описание

пример

outPort = removeInstrument(inPort,inInst) удаляет объект прибора (inInst) из портфеля инструментов (inPort), ранее созданный с помощью finportfolio.

Примеры

свернуть все

Использовать addInstrument чтобы добавить инструменты в пустой портфель, а затем удалить инструмент из портфеля с помощью removeInstrument.

Создать FixedBond Объекты КИП

Использовать fininstrument для создания двух FixedBond объекты КИП.

FixB1 = fininstrument("FixedBond", 'Maturity',datetime(2022,9,15),'CouponRate',0.045,'Name',"fixed_bond1")
FixB1 = 
  FixedBond with properties:

                  CouponRate: 0.0450
                      Period: 2
                       Basis: 0
                EndMonthRule: 1
                   Principal: 100
    DaycountAdjustedCashFlow: 0
       BusinessDayConvention: "actual"
                    Holidays: NaT
                   IssueDate: NaT
             FirstCouponDate: NaT
              LastCouponDate: NaT
                   StartDate: NaT
                    Maturity: 15-Sep-2022
                        Name: "fixed_bond1"

FixB2 = fininstrument("FixedBond", 'Maturity',datetime(2022,9,15),'CouponRate',0.035,'Name',"fixed_bond2")
FixB2 = 
  FixedBond with properties:

                  CouponRate: 0.0350
                      Period: 2
                       Basis: 0
                EndMonthRule: 1
                   Principal: 100
    DaycountAdjustedCashFlow: 0
       BusinessDayConvention: "actual"
                    Holidays: NaT
                   IssueDate: NaT
             FirstCouponDate: NaT
              LastCouponDate: NaT
                   StartDate: NaT
                    Maturity: 15-Sep-2022
                        Name: "fixed_bond2"

Создать ratecurve Объект

Создать ratecurve объект с использованием ratecurve.

Settle = datetime(2018,9,15);
Type = 'zero';
ZeroTimes = [calmonths(6) calyears([1 2 3 4 5 7 10 20 30])]';
ZeroRates = [0.0052 0.0055 0.0061 0.0073 0.0094 0.0119 0.0168 0.0222 0.0293 0.0307]';
ZeroDates = Settle + ZeroTimes;
 
myRC = ratecurve('zero',Settle,ZeroDates,ZeroRates)
myRC = 
  ratecurve with properties:

                 Type: "zero"
          Compounding: -1
                Basis: 0
                Dates: [10x1 datetime]
                Rates: [10x1 double]
               Settle: 15-Sep-2018
         InterpMethod: "linear"
    ShortExtrapMethod: "next"
     LongExtrapMethod: "previous"

Создать Discount Объект Pricer для FixedBond Инструменты

Использовать finpricer для создания Discount pricer object и используйте ratecurve объект для 'DiscountCurve' аргумент пары имя-значение.

DiscountPricer = finpricer("Discount",'DiscountCurve',myRC)
DiscountPricer = 
  Discount with properties:

    DiscountCurve: [1x1 ratecurve]

Добавить приборы в finportfolio Объект

Создать пустой finportflio объект с использованием finportfolio а затем использовать addInstrument для добавления двух FixedBond инструменты к портфелю.

f1 = finportfolio;
f1 = addInstrument(f1,FixB1)
f1 = 
  finportfolio with properties:

    Instruments: [1x1 fininstrument.FixedBond]
        Pricers: [0x1 finpricer.FinPricer]
    PricerIndex: NaN
       Quantity: 1

f1 = addInstrument(f1,FixB2)
f1 = 
  finportfolio with properties:

    Instruments: [2x1 fininstrument.FixedBond]
        Pricers: [0x1 finpricer.FinPricer]
    PricerIndex: [2x1 double]
       Quantity: [2x1 double]

Удалить прибор из finportfolio Объект

Использовать removeInstrument для удаления первого FixedBond инструмент из портфеля.

f1 = removeInstrument(f1,1)
f1 = 
  finportfolio with properties:

    Instruments: [1x1 fininstrument.FixedBond]
        Pricers: [0x1 finpricer.FinPricer]
    PricerIndex: NaN
       Quantity: 1

Установить цену для портфеля

Использовать setPricer для установки Discount прайсер для портфеля, а затем использовать pricePortfolio для расчета цены и чувствительности для одного инструмента в портфеле.

f1 = setPricer(f1,DiscountPricer)
f1 = 
  finportfolio with properties:

    Instruments: [1x1 fininstrument.FixedBond]
        Pricers: [1x1 finpricer.Discount]
    PricerIndex: 1
       Quantity: 1

[PortPrice,InstPrice,PortSens,InstSens] = pricePortfolio(f1)
PortPrice = 110.0749
InstPrice = 110.0749
PortSens=1×2 table
    Price       DV01  
    ______    ________

    110.07    0.041629

InstSens=1×2 table
                   Price       DV01  
                   ______    ________

    fixed_bond2    110.07    0.041629

Входные аргументы

свернуть все

finportfolio объект, указанный как скаляр finportfolio объект.

Типы данных: object

Инструмент для удаления из finportfolio объект, указанный как скалярный объект инструмента, строка для объекта инструмента 'Name' или значение индекса для позиции инструмента в finportfolio объект.

Типы данных: object | double | string

Выходные аргументы

свернуть все

Обновлено finportfolio, возвращено как finportfolio объект.

Представлен в R2020a