Gamestudio Links
Zorro Links
Newest Posts
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 827 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
continue on interfacing with Python #476708
03/25/19 10:39
03/25/19 10:39
Joined: Mar 2019
Posts: 10
CA
N
nandv Offline OP
Newbie
nandv  Offline OP
Newbie
N

Joined: Mar 2019
Posts: 10
CA
(As mentioned before, my algo is mainly in Python (converted from Matlab..), so my questions are mainly focusing on Zorro/Python.

I tried the following simple code,
in .c, set Python vars with OHLC(and V) from the last bar, and the last bar time wdate(0) and call Python code.
This is on BarPeriod = 1 // 1-min bar

>>>
function run()
{
pySet("pO", priceOpen(0));
pySet("pH", priceHigh(0));
pySet("pL", priceLow(0));
pySet("pC", priceClose(0));
// pySet("pV", marketVol(0));
pySet("pV", 0); // FX no volume!
var wd = wdate(0);
pySet("pTf", wd);

pyX("rcode = Py2(pO,pH, pL,pC,pV, pTf)");
>>>
My question are:
1) Is the last closed bar timestamp best to use wdate(), or other better calls?
2) Some of the timestamps are not on minute edges, i.e.,
[276: Mon 19-03-25 09:58] (1.13190)
wdate = 190325 09:58:02, OHLC = [1.1319 1.1319 1.1319 1.1319]

This means, the bar closed at 9:58 is timestamped as 9:58:02 (2 sec extra?) --> I assume it's because the next tick *AFTER* 9:58 closes the 9:58 1-min bar?
If this is indeed the case I am concerned that, in after-market trading where trades might be sparse, say, between 9:57 and 9:58 there're ticks, but no ticks until 9:59:05, then the 9:58 1-min bar's 'closing time' is 9:59??

2) when the Python code gets big, it's extremely hard to debug with stand along Python (needs to write extra/complex Python drivers).
Is there a way to 'attach Python debugger(s) to the Zorro Python process for Python code debugging?

Thanks.

Re: continue on interfacing with Python [Re: nandv] #476737
03/27/19 07:13
03/27/19 07:13
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
Normally the timestamp should be exactly 09:58:00, but historical timestamps are just read from the broker's price server, mostly from FXCM, and are not checked or corrected. Python debuggers cannot be attached, so better debug Python functions externally before calling them from Zorro. Same for R.

Re: continue on interfacing with Python [Re: jcl] #476745
03/27/19 23:56
03/27/19 23:56
Joined: Mar 2019
Posts: 10
CA
N
nandv Offline OP
Newbie
nandv  Offline OP
Newbie
N

Joined: Mar 2019
Posts: 10
CA
Thanks for the note. But this is realtime quote from IB.
I will try other broker(s) too.

Re: continue on interfacing with Python [Re: nandv] #476746
03/28/19 06:26
03/28/19 06:26
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
Then it's not the timestamp, but the current bar end time. Are they constantly 2 seconds late or does it vary?

Re: continue on interfacing with Python [Re: jcl] #476748
03/29/19 00:43
03/29/19 00:43
Joined: Mar 2019
Posts: 10
CA
N
nandv Offline OP
Newbie
nandv  Offline OP
Newbie
N

Joined: Mar 2019
Posts: 10
CA
I've tested loading 1000 1-min real time bars on IB and FXCM.
IB is roughly 40% with either 1 or 2 secs after the minute edge, but max is 9sec! FXCM is all exactly on the minute!
Enclosed are two csv file of Python dump of each bar's OHCLV and Timestamp(unix epoch/second) from IB and FXCM.

This may reflects the poor IB data quality, but still the bar end time shouldn't be the timestamp of the tick *after* the bar edge.

Attached Files
r10.csv (46 downloads)
r1.csv (37 downloads)
Last edited by nandv; 03/29/19 00:55.
Re: continue on interfacing with Python [Re: nandv] #476751
03/29/19 07:54
03/29/19 07:54
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
wdate(0) is not a timestamp. It is the current time.

I think a bar won't end on the precise second on a normal PC and internet connection, due to background tasks. In your case, the connection to IB is obviously slower than to FXCM. If a request to IB takes 2 seconds, then the bar end is inaccurate by 2 seconds. Other processes on your PC might add to that time.

Has nothing to do with timestamps or poor data quality.

Re: continue on interfacing with Python [Re: jcl] #476754
03/29/19 09:42
03/29/19 09:42
Joined: Jul 2017
Posts: 784
Z
Zheka Offline
User
Zheka  Offline
User
Z

Joined: Jul 2017
Posts: 784
@nandv,

what are tcp connection latencies from your computer to IB and FXCM servers during data collection? Have a look at Win Resource monitor/Networking..

Re: continue on interfacing with Python [Re: Zheka] #476758
03/29/19 12:39
03/29/19 12:39
Joined: Mar 2019
Posts: 1
F
fragom Offline
Guest
fragom  Offline
Guest
F

Joined: Mar 2019
Posts: 1
Hello,

I am trying usin R with Zorro in Linux with Wine and it is no posible it work trough mt4r.dll. Some solution?
best regards

Re: continue on interfacing with Python [Re: fragom] #476759
03/29/19 12:43
03/29/19 12:43
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Originally Posted By: fragom
Hello,

I am trying usin R with Zorro in Linux with Wine and it is no posible it work trough mt4r.dll. Some solution?
best regards
This is a Python thread. You can discuss Zorro on Linux in this other established thread:
https://opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=474060

Re: continue on interfacing with Python [Re: jcl] #476763
03/29/19 15:22
03/29/19 15:22
Joined: Mar 2019
Posts: 10
CA
N
nandv Offline OP
Newbie
nandv  Offline OP
Newbie
N

Joined: Mar 2019
Posts: 10
CA
Originally Posted By: jcl
wdate(0) is not a timestamp. It is the current time.





If wdate(0) is not, then please advise what's the right function to get the timestamp of the current bar([0]) timestamp?

Last edited by nandv; 03/29/19 15:27.
Page 1 of 2 1 2

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1