Greetings,

I'm finding some interesting behavior when using contractPrint() and findContract(). My goal is to find a contract that is near the money and close to TRADE_ENTRY_DTE days from expiration.

Consider the following simple script which loads options chains, iterates through the contracts and prints the contract records to a CSV file.

Code
void run() 
{

	StartDate = 20120101;
	EndDate = 20181231;
	BarPeriod = 1440;

	// optimized parameters
	var TRADE_ENTRY_DTE = 6*7; // days to expiration to enter trade

	History = "*.t8";
	assetList("AssetsOptions");
	asset("RUT");
		
	Multiplier = 100;
	
	// get the underlying closing price
	var p = priceClose();
	
	// load today's contract chain
	if(!contractUpdate(Asset,0,CALL|PUT)) return;
	printf("\n%s Asset=%s, contractsFound=%i",strdate(YMD,ldate(ET,0)),Asset,NumContracts);
	
	int i;
	for (i=0; i < NumContracts; i++)
	{
		CONTRACT* C = &Contracts[i];
		contract(C);
		print(TO_CSV,"\nRecord=%i; Time=%s, Type=%i; Expiry=%i; Strike=%f; Bid=%f; Ask=%f; Vol=%f; Unl=%f; Delta=%f;",i,strdate(YMD,ldate(ET,0)),ContractType,ContractExpiry,ContractStrike,ContractBid,ContractAsk,ContractVol,ContractUnl,ContractVal);
	}

	CONTRACT* initCall = contractFind(CALL,TRADE_ENTRY_DTE,p,6);
	
}


In the output CSV, I filter on 2011-09-08 trading day, call option strike=700 (near the underlying) and expiration 2011-10-21 (43 days to expiration). This contract is highlighted in the screenshot 1.PNG.

When I replace the print statement with contractPrint(C, TO_WINDOW), there is a slight variation in what is being printed. For example the fVal is not printed but otherwise the data is populated which should allow me to select the contract. See screenshot 2.PNG.

When I call contractFind as such

Code
CONTRACT* initCall = contractFind(CALL,TRADE_ENTRY_DTE,p,6);


No contract is ever found even though given 6*7=42 is sufficiently close to the minimum life in days (ie 43) and the strike is within 5.10 of the strike.

Why is contractFind not finding my contract?

Attached Files 1.PNG2.PNG