You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’ve rebased release–2.1 branch into master, all my investigation is base on that state. Replicate that step if you needed.
In duka/ore/processor.py, if the user added --local-time to the command line, the program just replace the ticks timezone, which called tzinfo with tz.tzlocal(). But we did it in a wrong way. .replace() function will return a new object, which is the modified one. That means the statements does nothing. Just changing the line to an assignment one still doesn’t work. The problem is much more complex. Let’s me explain this to you.
In Dukascopy Historical Data Feed, which duka intentionally want to be its command-line alternative one, treats local time options differently than our current implementation. Our target is to generate the same result as the official one.
Here’s the scenario: I’ve been live in a UTC+8 country, I want to download XAU/USD candlesticks data from date 2017–09–06 to 2017–09–07, and the timeframe I need is 4 hours.
If I chose Local option on the official tool, I’will get something like this:
It’s quite obvious that Line 1 at GMT is correspondent to Line 3 at Local, then Line 2 is to Line 4, etc.. We can easily conclude that, if the user wants a local version of data, he actually wants the data begins from the midnight of the start date and ends to the midnight of the end date in his locale.
Then I started changing some related code. Like in duka/ore/processor.py, instead of simply fetching range(0, 24) hours, I changed to an more precise day-and-hour way. First converting user-inputted start date and end date to datetime instances with local timezone tzinfo, then convert to GMT start datetime and end datetime.
Under fetch.py:
if local_time:
day = datetime.combine(day, datetime.min.time()) # convert to datetime, with start at midnight
day = day.replace(tzinfo=tz.tzlocal())
day = day.astimezone(tz.tzoffset(None, 0))
tasks = []
for i in range(0, 24):
delta_day = day + timedelta(hours=i)
url_info = {
'currency': symbol,
'year': delta_day.year,
'month': delta_day.month - 1,
'day': delta_day.day,
'hour': delta_day.hour
}
tasks.append(asyncio.ensure_future(get(URL.format(**url_info))))
I tried after these modifies but still not working as expected. I’ve find something interesting. Since we don’t preserve each fetch results return state (we just adding its serialized result to BufferIO buffer), we need add_hour function to keep the final result hour part correct. And current implementation is under the assumption of market opens at the beginning of GMT day (hour_delta = 0 on Line 42, under duka/ore/processor.py) and always closes at the end of GMT day.
I’m confused by this function pretty much, here’s some reasons:
Why we could just assume hour_delta begins from zero, is there any possibility that some market doesn't begin at GMT midnight?
add_hours function treats ticks[0] differently if ticks[0] is Saturday or the first day of an year. Why?
Since we don’t preserve fetch results return state. We don’t know whether the result returns empty or data. It’s all being combined or reduced! In the above scenario, XAU/USD market closed at 5 a.m. and re-opened at 6 a.m. in my locale, but current implementation will output the market closed at 11 pm. and re-opened at midnight. When encounter Monday, it will output the market closed at 6 p.m.. This question is actually the same and Question 1.
To resolve that issue, I think the program will need quite a large refactor, and I like to hear the opinions from original author and the community.
The text was updated successfully, but these errors were encountered:
I’ve rebased release–2.1 branch into master, all my investigation is base on that state. Replicate that step if you needed.
In
duka/ore/processor.py
, if the user added--local-time
to the command line, the program just replace the ticks timezone, which called tzinfo withtz.tzlocal()
. But we did it in a wrong way..replace()
function will return a new object, which is the modified one. That means the statements does nothing. Just changing the line to an assignment one still doesn’t work. The problem is much more complex. Let’s me explain this to you.In Dukascopy Historical Data Feed, which duka intentionally want to be its command-line alternative one, treats local time options differently than our current implementation. Our target is to generate the same result as the official one.
Here’s the scenario: I’ve been live in a UTC+8 country, I want to download XAU/USD candlesticks data from date 2017–09–06 to 2017–09–07, and the timeframe I need is 4 hours.
If I chose Local option on the official tool, I’will get something like this:
If i chose GMT:
Current program implementation will output something like this:
It’s quite obvious that Line 1 at GMT is correspondent to Line 3 at Local, then Line 2 is to Line 4, etc.. We can easily conclude that, if the user wants a local version of data, he actually wants the data begins from the midnight of the start date and ends to the midnight of the end date in his locale.
Then I started changing some related code. Like in
duka/ore/processor.py
, instead of simply fetchingrange(0, 24)
hours, I changed to an more precise day-and-hour way. First converting user-inputted start date and end date to datetime instances with local timezone tzinfo, then convert to GMT start datetime and end datetime.Under fetch.py:
I tried after these modifies but still not working as expected. I’ve find something interesting. Since we don’t preserve each fetch results return state (we just adding its serialized result to BufferIO buffer), we need add_hour function to keep the final result hour part correct. And current implementation is under the assumption of market opens at the beginning of GMT day (hour_delta = 0 on Line 42, under duka/ore/processor.py) and always closes at the end of GMT day.
I’m confused by this function pretty much, here’s some reasons:
hour_delta
begins from zero, is there any possibility that some market doesn't begin at GMT midnight?add_hours
function treatsticks[0]
differently ifticks[0]
is Saturday or the first day of an year. Why?To resolve that issue, I think the program will need quite a large refactor, and I like to hear the opinions from original author and the community.
The text was updated successfully, but these errors were encountered: