Gamestudio Links
Zorro Links
Newest Posts
file_write var array ?
by laz. 10/22/19 16:00
SAV_STATS
by MatPed. 10/22/19 13:57
Instrument Price Zorro Chart
by jcl. 10/22/19 10:39
Accessing All Historical Price Data
by jcl. 10/22/19 10:37
Calculating with price series
by AndrewAMD. 10/21/19 14:31
Error E355: Startup failure
by Dooley. 10/21/19 06:47
Today real live account blown - my experience
by Clifford_B. 10/19/19 17:09
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
14 registered members (JamesHH, AndrewAMD, alibaba, jenGs, FLD, jyd, MatPed, Dalla, 3 invisible), 672 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
VillageTalkies, line7, Shutch, Clifford_B, Paulius
18310 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Greeks from IB return zeros #477546
07/05/19 11:54
07/05/19 11:54
Joined: Jul 2019
Posts: 2
S
Steve2019 Offline OP
Guest
Steve2019  Offline OP
Guest
S

Joined: Jul 2019
Posts: 2
Hi, I've created a simple script to retrieve the greeks of an /ES option from Interactive Brokers. The script finds the option contract and prints the premium, however the greeks always print as 0.0000. I am subscribed to the options and futures data feeds.

Code

#include <contract.c>

var* Greeks[5]; 

void run()
{
	Verbose = 7|DIAG;
	set(LOGFILE);
	SaveMode = 0;
	NumYears = 1;
	assetList("OptionsIB");
	BarPeriod = 1; //mins
	NumYears = 1;
	LookBack = 0;
		
	asset("ES");
	contractUpdate ("ES-FOP-20191220",1,PUT|FUTURE);
	printf("\nPut chain loaded. Found: %d",NumContracts);
	CONTRACT* CImp = contract (PUT,160,2500);	
	contract (CImp); //sets the tradeable object, enabling the option variables..
	printf("\nStrike %f", ContractStrike); 

	var OptionPrice = contractPrice(CImp); // bid/ask average price
	printf("\nPremium %f",OptionPrice);
	
	brokerCommand(GET_GREEKS,Greeks);
	printf("\nBroker Delta is %f",Greeks[1]);	
	printf("\nBroker Theta is %f",Greeks[4]);		
}



The log from the script is

Code

Login 0 IB..
!Open IB Socket 2.01
!Account  xxxxxx at UTC 07-05 11:38
Load OptionsIB
!ES-FUT-20191220-ES-GLOBEX: 2996.50000 0.50000 1
!Get Future Option Chain ES-FOP-20191220-0----USD
Chain of 542 ES-FOP-20191220 contracts
Put chain loaded. Found: 542
Strike 2500.000000
!ES-FOP-20191220-2500-P-ES-GLOBEX: 19.75000 0.50000 1
Premium 19.500000
Broker Delta is 0.000000
Broker Theta is 0.000000



Any help would be greatly appreciated.

Thanks,

Steve.

Re: Greeks from IB return zeros [Re: Steve2019] #477547
07/05/19 13:36
07/05/19 13:36
Joined: Sep 2003
Posts: 861
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 861
Be happy that it was zeros, your code can even crash. Its "var Greeks", not "var* Greeks", "var*" would be an array of pointers in C.

Re: Greeks from IB return zeros [Re: Steve2019] #477549
07/05/19 13:43
07/05/19 13:43
Joined: Jul 2019
Posts: 2
S
Steve2019 Offline OP
Guest
Steve2019  Offline OP
Guest
S

Joined: Jul 2019
Posts: 2
Thanks Spirit, that's fixed it.


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1