Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Nymphodora, Quad), 919 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Deselect contract and trade with the underlying #466499
06/18/17 12:01
06/18/17 12:01
Joined: Nov 2016
Posts: 66
GreenBoat Offline OP
Junior Member
GreenBoat  Offline OP
Junior Member

Joined: Nov 2016
Posts: 66
I need to deselect the option contract and trade with the underlying.

I found this in the manual:

--------- MANUAL -------------
contract (int Type, int Expiry, var Strike): CONTRACT*
...Calling asset, contractUpdate, or contract(0) deselects the contract and allows again trading with the underlying.
--------- MANUAL END ---------

However, when I use "contract(0);", Zorro says "wrong number of parameters". When I use "contract(0,0,0);", then it says Invalid contract parameters and the last contract is not deselected.

The second option, calling contractUpdate, also doesn't deselect the contract.

So I tried to use asset("SPY"); and it works, but I am not sure it's the best way.

How should I call contract(0) or contractUpdate to deselect the contract?

Re: Deselect contract and trade with the underlying [Re: GreenBoat] #466511
06/19/17 07:49
06/19/17 07:49
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
You're right, the manual description was wrong. asset("SPY") deselects the contract, or alternatively this line:

g->contract = 0;

We'll implement deselecting the contract by contract(0,0,0) in the next update.

Re: Deselect contract and trade with the underlying [Re: jcl] #466543
06/20/17 10:29
06/20/17 10:29
Joined: Nov 2016
Posts: 66
GreenBoat Offline OP
Junior Member
GreenBoat  Offline OP
Junior Member

Joined: Nov 2016
Posts: 66
Indeed, I tried g->contract = 0; and it deselects the contract, exactly like asset("SPY").

Re: Deselect contract and trade with the underlying [Re: GreenBoat] #466544
06/20/17 11:01
06/20/17 11:01
Joined: Nov 2016
Posts: 66
GreenBoat Offline OP
Junior Member
GreenBoat  Offline OP
Junior Member

Joined: Nov 2016
Posts: 66
I have a problem which might be connected to deselecting the contract.

I have a script which sales options. There is always only one option contract opened.

When I trade only options, the log file looks like this:
Code:
[1002: Fri 15-01-02 20:50] (206.38)
[SPY::SP0201] Write 1 Put 20150220 207.0 100@5.2200  at 20:50:00

[1003: Mon 15-01-05 20:50] +0 -2 0/1  (204.17)
[1004: Tue 15-01-06 20:50] +0 -209 0/1  (202.09)
[1005: Wed 15-01-07 20:50] +0 -365 0/1  (201.42)
[1006: Thu 15-01-08 20:50] +0 -179 0/1  (204.01)
[1007: Fri 15-01-09 20:50] +0 +41 1/0  (206.40)
[1008: Mon 15-01-12 20:50] +0 -61 0/1  (204.41)
[1009: Tue 15-01-13 20:50] +0 -141 0/1  (204.12)
[1010: Wed 15-01-14 20:50] +0 -193 0/1  (199.6500)
[1011: Thu 15-01-15 20:50] +0 -249 0/1  (201.63)
[1012: Fri 15-01-16 20:50] +0 -395 0/1  (198.7700)
[1013: Tue 15-01-20 20:50] +0 -208 0/1  (202.40)
[1014: Wed 15-01-21 20:50] +0 -155 0/1  (201.50)
[1015: Thu 15-01-22 20:50] +0 -69 0/1  (203.99)
[1016: Fri 15-01-23 20:50] +0 +131 1/0  (205.79)
[1017: Mon 15-01-26 20:50] +0 +79 1/0  (204.71)
[1018: Tue 15-01-27 20:50] +0 +165 1/0  (202.97)
[1019: Wed 15-01-28 20:50] +0 -3 0/1  (204.17)
[1020: Thu 15-01-29 20:50] +0 -308 0/1  (200.38)
[1021: Fri 15-01-30 20:50] +0 -75 0/1  (200.57)
[1022: Mon 15-02-02 20:50] +0 -306 0/1  (200.05)
[1023: Tue 15-02-03 20:50] +0 -65 0/1  (203.00)
[1024: Wed 15-02-04 20:50] +0 +124 1/0  (203.92)
[1025: Thu 15-02-05 20:50] +0 +40 1/0  (204.86)
[1026: Fri 15-02-06 20:50] +0 +216 1/0  (206.56)
[1027: Mon 15-02-09 20:50] +0 +214 1/0  (204.77)
[1028: Tue 15-02-10 20:50] +0 +154 1/0  (205.88)
[1029: Wed 15-02-11 20:50] +0 +295 1/0  (206.61)
[1030: Thu 15-02-12 20:50] +0 +328 1/0  (207.89)
[1031: Fri 15-02-13 20:50] +0 +425 1/0  (209.07)
[1032: Tue 15-02-17 20:50] +0 +457 1/0  (209.40)
[1033: Wed 15-02-18 20:50] +0 +471 1/0  (209.66)
[1034: Thu 15-02-19 20:50] +0 +485 1/0  (209.41)
[SPY::SP0201] Cover 1 Put 20150219 207.0 100@0.08000: +491$ at 20:50:00

[1035: Fri 15-02-20 20:50] +491 +0 1/0  (209.48)
[SPY::SP3502] Write 1 Put 20150320 211.0 100@3.1000  at 20:50:00

[1036: Mon 15-02-23 20:50] +491 -2 1/1  (210.94)
[1037: Tue 15-02-24 20:50] +491 +12 2/0  (211.12)
[1038: Wed 15-02-25 20:50] +491 +63 2/0  (211.66)
[1039: Thu 15-02-26 20:50] +491 +55 2/0  (211.52)
[1040: Fri 15-02-27 20:50] +491 +54 2/0  (211.26)


And that's correct.

The problem starts when I try to trade also with the underlying.

When I add these simple lines of code at the end of the script:
Code:
g->contract = 0;
	enterLong(1);


The log file looks like this:
Code:
[1002: Fri 15-01-02 20:50] (206.38)
[SPY::SP0201] Write 1 Put 20150220 207.0 100@5.2200  at 20:50:00
[SPY::SP0201] Cover 1 Put 20150102 207.0 100@5.2200: -2.00 at 20:50:00
[SPY::L0202] Long 1@205.38  at 20:50:00

[1003: Mon 15-01-05 20:50] -2 -4 0/2  (204.17)
[SPY::SP0303] Write 1 Put 20150220 202.0 100@4.6900  at 20:50:00
[SPY::SP0303] Cover 1 Put 20150105 202.0 100@4.6900: -2.00 at 20:50:00
[SPY::L0304] Long 1@201.67  at 20:50:00

[1004: Tue 15-01-06 20:50] -4 -7 0/4  (202.09)
[SPY::SP0405] Write 1 Put 20150220 200.0 100@4.9200  at 20:50:00
[SPY::SP0405] Cover 1 Put 20150106 200.0 100@4.9200: -2.00 at 20:50:00
[SPY::L0406] Long 1@199.8421  at 20:50:00


And that's wrong. Apparently, Zorro closes the option trade by Cover every time Long trade is made with the underlying. But it shouldn't.

When I change the trade with the underlying to enterShort, the result is right. Option trades stay the same, but every day one underlying stock is sold. Log file looks like this:
Code:
[1002: Fri 15-01-02 20:50] (206.38)
[SPY::SP0201] Write 1 Put 20150220 207.0 100@5.2200  at 20:50:00
[SPY::S0202] Short 1@205.38  at 20:50:00

[1003: Mon 15-01-05 20:50] +0 +2 1/1  (204.17)
[SPY::S0303] Short 1@201.67  at 20:50:00

[1004: Tue 15-01-06 20:50] +0 -202 2/1  (202.09)
[SPY::S0404] Short 1@199.8421  at 20:50:00

[1005: Wed 15-01-07 20:50] +0 -365 1/3  (201.42)
[SPY::S0505] Short 1@202.35  at 20:50:00


As you can see, one option contract is opened and one underlying stock is sold, the trades are separate as they should be.

But why doesn't the same thing happen with enterLong?

And there is more... I can turn it around and when I buy PUTs and then buy underlying, it works right. But when I buy option + sell underlying, it doesn't work.

Re: Deselect contract and trade with the underlying [Re: GreenBoat] #466549
06/20/17 16:35
06/20/17 16:35
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Can you contact support and send them the script? They'll look into it.

Re: Deselect contract and trade with the underlying [Re: jcl] #466561
06/21/17 07:31
06/21/17 07:31
Joined: Nov 2016
Posts: 66
GreenBoat Offline OP
Junior Member
GreenBoat  Offline OP
Junior Member

Joined: Nov 2016
Posts: 66
Support answered and solved the problem:

The variable Hedge has to be set to 2. This solves the problem with trading options together with the underlying and the script works fine.

However the result chart is not usable, unfortunately. The result's picture looks like there are hundreds of positions opened and that they are closed at the end of the whole trading period. So it's full of lines, all of them ending at one point. The result pictures are nice for publishing online articles and making Zorro famous! laugh Very important laugh

Re: Deselect contract and trade with the underlying [Re: GreenBoat] #466601
06/22/17 17:19
06/22/17 17:19
Joined: Nov 2016
Posts: 66
GreenBoat Offline OP
Junior Member
GreenBoat  Offline OP
Junior Member

Joined: Nov 2016
Posts: 66
Hedge=2 means, that I have to use exitLong and exitShort, not enterLong and enterShort as usual, for all trades.

But there is some bug with partial filling of exitLong/Short when trading underlying and options. It will be fixed in the next update.

Re: Deselect contract and trade with the underlying [Re: GreenBoat] #466636
06/24/17 18:43
06/24/17 18:43
Joined: Nov 2016
Posts: 66
GreenBoat Offline OP
Junior Member
GreenBoat  Offline OP
Junior Member

Joined: Nov 2016
Posts: 66
Zorro team corrected the bug at the speed of light.

With Heding=2, it's working perfectly.


Moderated by  Petra 

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