Hi firecrest, I have installed the RQuantlib package and connected it to Zorro platform via the zorro.ini file. I have been able to use the contractVal and contractVol functions mostly with no problems, except for what I discuss below.

Jcl, I completely overlooked the Quandl key! I have added the key to the zorro.ini thanks.

However, the bug remains, and I believe its to do with the CALL option contract pointer and using the contractVol function to get the implied volatility of the very same contract.

This can be seen when you change the TYPE variable in the code below between CALL and PUT. The script below creates an ATM option contract based on the TYPE variable, calculates the value of the contract (con_value) and the Implied Volatility (current_IV), and displays the values using the watch function:

Code:
// The script is not set to enter any trades, just solely to observe what is retrieved from the
// contractval and contractvol functions

#include <r.h>
#include <contract.c>

void run() 
{
	BarPeriod = 1440;
	assetList("assetsIB");
	assetHistory("SPY",FROM_YAHOO|UNADJUSTED);
	asset("SPY");
	if(is(INITRUN)){
		initRQL();
		dataLoad(1,"SPY_Options.t8",9);
	}
	
	Multiplier = 100;
	contractUpdate("SPY",1,CALL|PUT);	
	int Type = PUT; // Then change to CALL to see difference ******
	var delta_check = 0;
	var strike_price = 0; 
	var con_value;
	var current_IV;
	var Dividend = 0.02;
	var HistVolOV = VolatilityOV(20);
	var Interest = 0.01*yield();

	strike_price = priceClose();
	CONTRACT* dtest = contract(Type,30,strike_price); 
	con_value = contractVal(dtest,priceClose(),HistVolOV,Dividend,Interest,&delta_check);
	current_IV = contractVol(dtest,priceClose(),HistVolOV,con_value,Dividend,Interest);

	watch("!S_$",strike_price,"C_V",con_value,"D",delta_check,"IV",current_IV);	}



When TYPE is set to PUT, I get the following results as I continue to click step (where S_$ - strike value, C_V - contract value, D - delta, IV - Implied Vol):

Quote:

Test: call_iv SPY 2012..2017
Assets assetsIB
!S_$ 127.70 C_V 2.26712 D -0.45836 IV 0.17091
!S_$ 128.04 C_V 4.04538 D -0.54228 IV 0.21022
!S_$ 127.71 C_V 2.95047 D -0.46340 IV 0.20079
!S_$ 128.02 C_V 2.77781 D -0.50093 IV 0.17576
!S_$ 129.13 C_V 3.20197 D -0.55500 IV 0.17292
!S_$ 129.20 C_V 3.04057 D -0.55369 IV 0.16776
!S_$ 129.51 C_V 3.10393 D -0.53217 IV 0.16602
!S_$ 128.84 C_V 2.39040 D -0.45350 IV 0.16774
!S_$ 129.34 C_V 2.68262 D -0.48154 IV 0.18155
!S_$ 130.77 C_V 2.42929 D -0.45620 IV 0.17985


However, when I change the TYPE to CALL, I get the following results every time I click step

Quote:

Assets assetsIB
!S_$ 127.70 C_V 0.00000 D 0.00000 IV 0.00000
!S_$ 128.04 C_V 0.00000 D 0.00000 IV 0.00000
!S_$ 127.71 C_V 0.00000 D 0.00000 IV 0.00000
!S_$ 128.02 C_V 0.00000 D 0.00000 IV 0.00000
!S_$ 129.13 C_V 0.00000 D 0.00000 IV 0.00000
!S_$ 129.20 C_V 0.00000 D 0.00000 IV 0.00000
!S_$ 129.51 C_V 0.00000 D 0.00000 IV 0.00000
!S_$ 128.84 C_V 0.00000 D 0.00000 IV 0.00000
!S_$ 129.34 C_V 0.00000 D 0.00000 IV 0.00000
!S_$ 130.77 C_V 0.00000 D 0.00000 IV 0.00000
!S_$ 131.46 C_V 0.00000 D 0.00000 IV 0.00000



When I comment out the current_IV=contractVol... line in the script, the script will correctly display the contract value and delta values for the CALL option contracts, but displays zeroes (as shown above) when uncommented.

Hope this helps explain the problem.