24 registered (Ch40zzC0d3r, Hredot, Dico, DriftWood, DesixStudios, jumpman, Hlopetz, alibaba, Denn15, 2 invisible),
472
Guests and
11
Spiders online. 
Key:
Admin,
Global Mod,
Mod



#466000  05/19/17 14:40
Re: Trading options with Zorro: How to calculate Delta
[Re: GreenBoat]

Junior Member
Registered: 11/06/16
Posts: 55

I am trying to calculate delta as mentioned, but unfortunately the result is not as expected.
Few examples (from Interactive Brokers platform):
SPY, expiration today, PUTs:
Strike 237, PUT midpoint price 0.835, Delta 0.696 Strike 236, PUT midpoint price 0.44, Delta 0.240 Premium price difference 0.395 is not near the deltas.
SPY, expiration in 28 days, PUTs:
Strike 237, PUT midpoint price 3.48, Delta 0.573 Strike 236, PUT midpoint price 3.08, Delta 0.513 Premium price difference 0.4 is not near the deltas.
DAX, expiration in 28 days, CALLs:
Strike 12650, CALL midpoint price 158.5, Delta 0.474 Strike 12700, CALL midpoint price 133, Delta 0.427 Premium price difference 25.5/50=0.51 is at least near the deltas, but it is not too precise.
I guess that the problem is, that with different strike not only Delta changes, but also Implied Volatility. So the calculation of Delta should be a bit more complex.
I think that I have to use contractVal.

Top




#466492  06/16/17 21:43
Re: Trading options with Zorro: How to calculate Delta
[Re: GreenBoat]

Junior Member
Registered: 11/06/16
Posts: 55

I finished a simple script for Delta calculation. Feel free to use it: #include <contract.c> // needed for options
function run()
{
BarPeriod = 1440; // 1 bar is 24 hours
BarZone = ET; // SPY is in New York
BarOffset = 15*60 + 50; // set the bar end to 15:50, 10 minutes before the market close
StartDate = 20161131;
EndDate = 20161231;
EndWeek = 52100;
LookBack = 256; // 256 = 1 year
set(PRELOAD+LOGFILE);
assetList("AssetsOnlyFew");
//assetHistory("SPY",FROM_YAHOO);
asset("SPY");
if(is(INITRUN)) {
initRQL(); // run R
dataLoad(1,"SPY_Options.t8",9);
}
if(is(LOOKBACK)) return;
// load today's contract chain
int N = contractUpdate(Asset,1,CALLPUT);
Multiplier = 100;
if(!N) {
printf("#nNo contracts at bar %i",Bar);
return;
}
// determine the current underlying price (unadjusted)
var CurrentPrice = ifelse(is(TRADEMODE),priceClose(),Contracts>fUnl);
// Select contract and calculate delta and implied volatility
CONTRACT* CImp = contract(PUTONLYW3,1,CurrentPrice2);
contractPrint(CImp,TO_LOG); // print contract values to the log file
var OptionPrice = contractPrice(CImp); // bid/ask average price
var HistVolAnnual = VolatilityOV(20);
var Delta = 0;
var ImpliedVol = contractVol(CImp,CurrentPrice,HistVolAnnual,OptionPrice,0,0); // calculate Implied volatility
print(TO_LOG,"nImpliedVol %g",ImpliedVol);
// contractVal (CONTRACT*, var Price, var HistVol, var Dividend, var RiskFree, var* Delta, var* Gamma, var* Vega, var* Theta, var* Rho): var
var ThValue = contractVal (CImp,CurrentPrice,HistVolAnnual,0.02,0.02,&Delta);
print(TO_LOG,"nDelta = %g",Delta);
print(TO_LOG,"nTheoretical value (contractVal) = %g",ThValue);
}
I would like to compare the outputs with some other source(s), so I can be sure that the calculation is correct. I didn't bother to use the exact dividend and risk free rate for this first test. I believe that it's not that important (I use approximate fixed values). I have ThinkOrSwim free account (it's probably the nicest platform for options trading and they have historical data with Greeks) and I am trying to compare my values with this source. If you know about any other source, I'll be happy to try it. Bid and Ask prices are exactly the same from both data sources (I have historical data from IVolatility), so there shouldn't be any problem there. There might be some problem with historical volatility, because I can see that ThinkOrSwim doesn't have exactly the same underlying prices as I can see in Zorro log file. However, the differences are very small, like 219.57 (ThinkOrSwim) and 219.73 (Zorro). It looks that the calculated implied volatility is (most of the time) almost exactly the same like in the ThinkOrSwim platform. Only Deltas are a bit too different in my opinion and I am thinking what might be the reason. The question is, if it means that I need to improve my script. Maybe that ThinkOrSwim has some specific Delta calculation and I shouldn't use it for comparison at all. Few examples: Zorro log file: 20161201,Put,20161216,217.5000,219.7300,1.8700,1.8400,9576 ImpliedVol 0.159051 Delta = 0.310674 ThinkOrSwim: ImpliedVol 15.33 Delta 0.37 Zorro log file: 20161206,Put,20161216,219.5000,221.5900,1.0500,1.0200,12594 ImpliedVol 0.129566 Delta = 0.283869 ThinkOrSwim: ImpliedVol 12.82 Delta 0.32 Zorro log file: 20161213,Put,20161216,226.0000,227.8600,0.8800,0.8400,12904 ImpliedVol 0.196424 Delta = 0.243288 ThinkOrSwim: ImpliedVol 16.83 Delta 0.32 Zorro log file: 20161215,Put,20161216,225.0000,226.8700,0.3600,0.3500,43434 ImpliedVol 0.217107 Delta = 0.130342 ThinkOrSwim: ImpliedVol 15.23 Delta 0.24 Zorro log file: 20160701,Put,20160715,208.0000,210.0300,1.1600,1.1500,73349 ImpliedVol 0.122174 Delta = 0.426875 ThinkOrSwim: ImpliedVol 11.79 Delta 0.34 Zorro log file: 20160722,Put,20160819,215.0000,217.0800,1.6700,1.6400,104783 ImpliedVol 0.106583 Delta = 0.394118 ThinkOrSwim: ImpliedVol 10.76 Delta 0.36 Zorro log file: 20160817,Put,20160819,216.5000,218.4000,0.2000,0.1900,25813 ImpliedVol 0.126256 Delta = 0.156243 ThinkOrSwim: ImpliedVol 10.33 Delta 0.18

Top




#466686  06/27/17 15:21
Re: Trading options with Zorro: How to calculate Delta
[Re: jcl]

Junior Member
Registered: 11/06/16
Posts: 55

I compared:  numerically computed Deltas  ThinkOrSwim (options' platform with historical data) Deltas  Deltas calculated by Zorro Both numerically computed Deltas and ThinkOrSwim Deltas are almost the same. But the Deltas from Zorro are different, the difference is sometimes as high as 10 Delta points. The closer to the expiration date, the higher is the difference, which is weird. Zorro calculates the Delta like this: Delta = Rd("Option$delta"); Option$delta is RQuantlib function. I didn't find information about this function Any hint where can I find RQuantLib Delta formula?

Top




