Keyboard Shortcuts
Likes
- Ib-Async
- Messages
Search
Re: Subscription
sponsored as well 15$, thanks for your work Il giorno gio 10 ott 2024 alle ore 19:56 Pratik Babhulkar via <praditik=[email protected]> ha scritto:
|
Re: Subscription
Thanks Mel, I sponsored $20 as well.
|
Re: Subscription
I Mel, Sponsored with $20.? I have been using ib_async and ib_insync for more than a couple of years now and plan to use them for long foreseeable future. I have also added a couple or PRs to the latest version and plan on helping in any way possible. I strongly think that this group should be kept alive and it certainly helps. Would be glad to take up more responsibilities as you find suitable. Plus: I am under 30 :D? Regards, Pratik Babhulkar On Thu, Oct 10, 2024 at 11:17?PM Mel via <climbermel=[email protected]> wrote:
|
Subscription
Just a reminder that this group uses a paid subscription model for groups.io. The current cost is $20 per month. Please use the Sponsor this Group button on the main page: /g/ib-async The current year was covered by only a couple of people, I think everyone that is getting a benefit should donate a couple of dollars. At the current amount of members, if everyone put in $5, that would cover another year. $5 or $10 per year is pretty inexpensive for a forum like this. The button automatically adds it to the group.io account and the monthly fees then come out of there. I would also like to ask if anyone would be interested in being an admin to the group! I don't like the risk of myself being the only one able to manage the group and to accept pending members. If I'm away, a person could wait a week or two to get approved as a member. Not to mention what happened to the last group admin... I believe I am older than Ewald was. Thanks, Mel Pryor |
Re: How to get RTH bars
Good point Pratik! You're right, IB is sending the data with UTC timestamps.
?
Timezone is already set correctly in TWS settings at the startup window. There's a setting TWS -> Global Configuration -> API -> Settings -> "Send instrument-specific attributes for dual-mode API client in" which is also set to "operator timezone".
?
Any other setting that could cause the issue? |
Re: How to get RTH bars
Most probably you are getting data in UTC. Check your first candle of the day as well. If all is shifted by 4 hours, you have your answer.?
?
You will need to change TWS timezone at login window and/or API setting page in Configuration and/or Historical Chart setting. That should solve your problem.
?
Regards,
Pratik Babhulkar
? |
Re: How to get RTH bars
toggle quoted message
Show quoted text
-------- Original message -------- From: "R Malhotra via groups.io" <rachan.malhotra@...> Date: 2024-09-28 8:41 p.m. (GMT-08:00) Subject: [ib-async] How to get RTH bars I'm using the code below to get 1 hour bars, but noticed that the last bar of the previous day is for the 7pm hour, not the 3pm hour, despite setting useRTH to True. Anyone know why that would be?
?
Thanks!
?
bars_hist_1h = ib.reqHistoricalData(
? ? contract, ? ? endDateTime='', ? ? durationStr='2 W', ? ? barSizeSetting='1 hour', ? ? whatToShow='TRADES', ? ? useRTH=True, ? ? keepUpToDate=False, ? ? formatDate=2) |
How to get RTH bars
I'm using the code below to get 1 hour bars, but noticed that the last bar of the previous day is for the 7pm hour, not the 3pm hour, despite setting useRTH to True. Anyone know why that would be?
?
Thanks!
?
bars_hist_1h = ib.reqHistoricalData( ? ? contract, ? ? endDateTime='', ? ? durationStr='2 W', ? ? barSizeSetting='1 hour', ? ? whatToShow='TRADES', ? ? useRTH=True, ? ? keepUpToDate=False, ? ? formatDate=2) |
Re: Mid price for options spread
Hey Draql12,?
?
On second thought, I think marketPrice() may be a more robust choice, as it first seeks to use the most recent trade price (comparing to only the actual ask and bid prices in that moment ignoring their sizes). If the three don't jive, then the function calls Midpoint().
?
The marketPrice() function could be especially useful for low-volume securities (such as OTM options) that don't have an active bid or ask. Although if the last trade price of the security occurred a long time ago (perhaps a week or a few days), then could adversely impact you but still, that fail would fall more on IB's data service (for providing you with an outdated and irrelevant last trade price) than the marketPrice() function itself. Naw meen.
?
I have re-printed its source code below for additional reading.
?
? ? def marketPrice(self) -> float:
? ? ? ? """ ? ? ? ? Return the first available one of ? ? ? ? * last price if within current bid/ask or no bid/ask available;
? ? ? ? * average of bid and ask (midpoint). ? ? ? ? """ ? ? ? ? if self.hasBidAsk(): ? ? ? ? ? ? if self.bid <= self.last <= self.ask: # <== check it out ignores bid/ask sizes! ? ? ? ? ? ? ? ? price = self.last ? ? ? ? ? ? else: ? ? ? ? ? ? ? ? price = self.midpoint() # <== what you already have ? ? ? ? else: ? ? ? ? ? ? price = self.last #<== all else failed ? ? ? ? return price ?
Regards,
Some Guy
|
Re: Handling Error 201
I save my orders to a dict of pending orders. If I get an error like that I remove it from my pending list. Aside from that you have to figure out why the original order was rejected. Should be in the order statuses or would be printed as an errorEvent.
?
Make sure you have the events setup to help debug
?
self.ib.orderStatusEvent += self.handle_order_status_update
self.ib.execDetailsEvent += self.handle_trade_execution_details
self.ib.errorEvent += lambda reqId, errorCode, errorString, contract: log.error(
f"Error. ReqId: {reqId}, Code: {errorCode}, Msg: {errorString}, Contract: {contract}"
) # This one logs a lot
|
Re: Error 162, Historical Market Data Service error message:API scanner subscription cancelled:
Hey saschaludo,?
?
I'm not real great at coding in Python, but the logging library may provide an adequate band-aid for this problem. Try this:?
?
import logging
util.logToConsole(logging.CRITICAL) # limit messages to critical only
# scanner code goes here
util.logToConsole(logging.WARNING) # reset logging to the default, WARNING level
?
If you're interested in knowing more about what the logging library can do for you, then I would take a look here:
?
Regards,
Some Guy |
Re: Mid price for options spread
Hey Draql12,?
?
I looked up the midpoint() source code in the ticker.py file and have produced it below. Note that the function incorporates bidsize and asksize in its logic, so I would be sure to print('Bidsize:', ticker.bidSize) and print('Asksize:', ticker.askSize) as well when validating this function.
?
? ? def hasBidAsk(self) -> bool:
? ? ? ? """See if this ticker has a valid bid and ask.""" ? ? ? ? return ( ? ? ? ? ? ? self.bid != -1 ? ? ? ? ? ? and not isNan(self.bid) ? ? ? ? ? ? and self.bidSize > 0 ? ? ? ? ? ? and self.ask != -1 ? ? ? ? ? ? and not isNan(self.ask) ? ? ? ? ? ? and self.askSize > 0 ? ? ? ? ) ? ? def midpoint(self) -> float:
? ? ? ? """ ? ? ? ? Return average of bid and ask, or NaN if no valid bid and ask ? ? ? ? are available. ? ? ? ? """ ? ? ? ? return (self.bid + self.ask) * 0.5 if self.hasBidAsk() else nan |
Ticker.Tickfilter.timebars usage?
Hey everyone,??
?
Thank you for keeping this project and forum up and running.?
?
Writing to ask if someone has any examples or pointers of how tick data can be aggregated into timebars? The functionality seems to exist already, I just haven't been able to put it together on my own.
?
I appreciate whatever comments you can provide.?
? |