question

Upvotes
1 0 1 0

Eikonn AdfinXAnalytics volatility error

Hello :

Im trying to calculate a volatility using Interop.AdfinXAnalytics with one of the exercise in the developer's book in c#

When i try to Attach the Volatility to the Asset object

i get the following error:

System.Runtime.InteropServices.COMException: 'Undefined error : missing or invalid resource'

i can't figure out my mistake, the code was written originally in vba so i re write the code to c#

can anyone help me out

	    EikonDesktopDataAPI.EikonDesktopDataAPI sdk;           
	    IAdxOption Option ;
            Option = sdk.CreateAdxOption();// new AdxOption();
            IAdxAsset Asset; //AdxAsset Asset;
            Asset = sdk.CreateAdxAsset();//new AdxAsset();
            IAdxRateModel RateModel;
            RateModel = sdk.CreateAdxRateModel();//new AdxRateModel();
            IAdxVolatilityModel VolatilityModel;
            VolatilityModel = sdk.CreateAdxVolatilityModel();//= new AdxVolatilityModel();
            IAdxCalcMethod CalcMethod;// AdxCalcMethod 
            CalcMethod = sdk.CreateAdxCalcMethod();//new AdxCalcMethod();


            string OptionStructure;
            string UnderlyingStructure;
            string RateStructure;
            string CalcStructure;
            string CalcDate;
            double SpotPrice;
            double Volatility;
            double RiskFreeRate;
            string ExpiryDate;
            double StrikePrice;
            double Premium;

            //Set Asset attributes and parameters
            SpotPrice = 134;
            UnderlyingStructure = "UI:SEC";
            Asset.Init(UnderlyingStructure);
            Asset.SetAttribute (AdxAttrAsset.ADX_ATTR1F_ASSET_PRICE, SpotPrice);
         
            //Set VolatilityModel attributes
            VolatilityModel.ErrorMode = AdfinXAnalyticsObjects.AdxErrorMode.DIALOGBOX;
            Volatility = 0.18;
            VolatilityModel.Init("IM:CUBS");
            VolatilityModel.SetAttribute(AdxAttrVolatilityModel.ADX_ATTR1R_VOLATILITY, Volatility);


            //ERROR (1)
            //Attach the Volatility to the Asset object
           Asset.AttachModel(40965,VolatilityModel); //AdxAttrAsset.ADX_PTR_MODEL_DIVIDEND


eikoneikon-data-apieikon-com-apiadfin
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Upvotes
4.1k 4 8 12

Go to Debug->Exceptions and use the Find option to locate System.Runtime.InteropServices.COMException. Tick option to break when it is thrown and then debug.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.