Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Trading Journey
by howardR. 04/24/24 20:04
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Ayumi, AndrewAMD), 822 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Getting Implied Volatility from contractVol #466184
05/29/17 19:23
05/29/17 19:23
Joined: Nov 2016
Posts: 66
GreenBoat Offline OP
Junior Member
GreenBoat  Offline OP
Junior Member

Joined: Nov 2016
Posts: 66
I am trying to get implied volatility from the function contractVol.

I don't understand the specification of the function contractVol.

From the manual:
contractVol (CONTRACT*, var Price, var HistVol, var Value, var Dividend, var RiskFree): var

What is Price and Value? If Price is the price of the option, then what is Value?

Re: Getting Implied Volatility from contractVol [Re: GreenBoat] #466185
05/29/17 20:06
05/29/17 20:06
Joined: Feb 2017
Posts: 369
D
Dalla Offline
Senior Member
Dalla  Offline
Senior Member
D

Joined: Feb 2017
Posts: 369
My guess would be that Price is the price of the underlying asset, and Value is the value of the option.

Re: Getting Implied Volatility from contractVol [Re: Dalla] #466188
05/29/17 22:53
05/29/17 22:53
Joined: Nov 2016
Posts: 66
GreenBoat Offline OP
Junior Member
GreenBoat  Offline OP
Junior Member

Joined: Nov 2016
Posts: 66
Of course! Why didn't I think of that laugh
Thanks!

Re: Getting Implied Volatility from contractVol [Re: GreenBoat] #466192
05/30/17 10:44
05/30/17 10:44
Joined: Nov 2016
Posts: 66
GreenBoat Offline OP
Junior Member
GreenBoat  Offline OP
Junior Member

Joined: Nov 2016
Posts: 66
I can't make it work.

This is my script:
Code:
#include <contract.c> // needed for options
#include <r.h>

/* Test of R */

function run()
{
	BarPeriod = 1440; // 1 bar is 24 hours
	StartDate = 20060101;
	EndDate = 20061231;
	set(PRELOAD|LOGFILE|PLOTNOW);
	PlotHeight1 = 1024; // height of the chart with results
	PlotWidth = 1700;

	assetList("AssetsIB");
	assetHistory("SPY",FROM_YAHOO); // ticker
	asset("SPY");
	if(is(INITRUN)) {
		initRQL();	// run R
		dataLoad(1,"SPY_Options.t8",9);
	}

// load today's contract chain
	contractUpdate(Asset,1,CALL|PUT);
	Multiplier = 100;

// prices
	vars Price = series(price());
	vars Close = series(priceClose());
  	vars Vol = series(Volatility(Price,20));
  	if(is(LOOKBACK)) return;
	
// determine the current underlying price (unadjusted)
	var CurrentPrice = Contracts->fUnl;
	
// choose contract
	CONTRACT* CImp = contract(PUT|ONLYW3,20,CurrentPrice);

// Implied Volatility test
  	var OptionPrice = contractPrice(CImp); // bid/ask average price
	var ImpliedVol = contractVol(CImp,CurrentPrice,Vol[0],OptionPrice,0,0); // calculate Implied volatility
	printf("#nImpliedVol %i ",ImpliedVol);
}



Log file:
Code:
[85: Tue 06-01-10 00:00] (128.3900)
ImpliedVol 0 

[86: Wed 06-01-11 00:00] (129.0200)
ImpliedVol 0 

[87: Thu 06-01-12 00:00] (129.0800)
ImpliedVol 0 

[88: Fri 06-01-13 00:00] (128.5700)
ImpliedVol 0



I am not sure if the problem is with RQuantLib or wrong function inputs.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1