Replies: 3 comments 3 replies
-
Thats kind of what I did, I just modified the dict in
It's not ideal but was the quickest solution for me. Your proposed solution is probably the most user friendly for everyone going forward. |
Beta Was this translation helpful? Give feedback.
-
I basically copied meldinman's approach with the addition of using the one_off_adjustments function in the ib_trading_hours.py to "force" some of the instruments to trade in a smaller time window. Very janky but it was the best I could do on short notice. I'm not very good with Python but I was looking at a library called DateTimeRange: (https://pypi.org/project/DateTimeRange/) |
Beta Was this translation helpful? Give feedback.
-
This thread. And #687 When people are tying themselves in knots trying to get the current approach to work, it's usually a sign that the approach is flawed. I'm wondering whether this is a problem that is too complicated to solve with code that trys to dynamically evaluate the correct trading hours for an instrument. I'm thinking the following - create a table for trading hours. This could be stored in .csv to allow manual hacking. We assume that all weeks are the same, so there is basically a series of records for each day of the week. We allow two trading sessions per day, this also allows weird start/end times to work eg session one 1900-0000, session two 0000 - 0500 for example. So each instrument will have 7*2 = 14 columns of data trading hours. There could be utility scripts that read the current trading hours from IB and create the initial set of records using some conservative settings, update the trading hours based on what IB has for the next week, push all trading hours backwards and forwards by N hours, and so on. We'd still get trading hours from IB and the trading hours we would use are the intersection between the stored hours and the IB hours. This means we can pick up closed markets, half day holidays, and times when there has been a DST change that we haven't reflected in our own data. Think of all the flexibility - you could trade for just one hour a day if you wished. Or 24 hours in principal (which means you would just pick up the IB hours). Thoughts? (I note in passing that this is the approach we used at AHL, and I used in my 'first system' before pysystemtrade) |
Beta Was this translation helpful? Give feedback.
-
@robcarver17 @rorymac @meldinman
I've got a change queued up to apply the gmt_offset from private config to conservative trading hours. You can see the code
After coding this up, it occurred to me that we could instead move the conservative trading hours dictionaries to private config.
Pros (of using config):
Cons:
Anyone have thoughts?
Beta Was this translation helpful? Give feedback.
All reactions