Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
Re: Gateway loses historical market data every day
1- no need, it happens on first call. Make a dummy APPL historical and 'voila' |
Re: Is it possible to place order at 15:59 or 16:00 and get a fill?
On Thu, Aug 17, 2023 at 01:29 AM, <omgwtfsalty@...> wrote:
"All MOC orders must be received at NYSE markets by 15:50 ET, unless entered to offset a published imbalance. NYSE markets' rules also prohibit the cancellation or reduction in size of any market-on-close (MOC) order after 15:45 ET."I guess this quote must be from IBKR's website, where it's a bit outdated. NYSE 2023 opening and closing auction rules:? Nasdaq 2023 closing cross rules & faq:?https://nasdaqtrader.com/content/ETFs/closing_cross_faqs.pdf ? -- Best, DS |
Re: Is it possible to place order at 15:59 or 16:00 and get a fill?
MOC/LOC orders require that TIF is set to "DAY".
To put MOC order in the bracket, the following settings must be used for the bracket order peers: moc.ocaType = 3;This is to allow the MOC order to work in an OCA group of the bracket order children, countering the concern that Juergen raised. Although "3" for this setting is generally used to reduce the mutually exclusive orders by the size of either order's fill without overfill protection, with MOC/LOC order it just means "cancel the other order completely" because IBKR does not offer reduction of MOC/LOC orders while any other?ocaType?setting will resulting in the MOC/LOC order rejection. The result would look like this: You do not need any time condition for the MOC order as it will activate automatically once the exchange transitions from regular trading to the closing auction (and IBKR won't allow order conditions on MOC orders, though if you need to enable the order at a certain time for any reason, you can always use Good-After-Time (order.goodAfterTime) property, which, in addition to working with more order types than time conditions, is also easier to use as it takes a single line of code to configure). Referring to Juergen's concern again, since MOC orders indeed cannot be activated and cancelled after a few minutes before close (10 minutes for submission and 2 minutes for cancellation on NYSE, and 5 minutes for submission and 10 minutes for cancellation on Nasdaq), it might be a good idea to cancel or suspend the other orders at those cutoffs so as to avoid accidentally running into an overfill, although these guards would certainly complicate the code and kind of defeat the simplicity advantage of the MOC order in that it requires zero timing efforts. Today's liquid hours closing time can be learned from ContractDetails for the respective stock or from a Python package such as exchange_calendars. If you choose the MOC path, and seeing that you already use GTC TIFs, I believe temporary suspension of trading is enabled for GTC orders with?order.activeStopTime?property (vis a vis?order.activeStartTime, though I'll admit I never used these properties myself yet). -- Best, DS |
Re: Is it possible to place order at 15:59 or 16:00 and get a fill?
Hi ´³¨¹°ù²µ±ð²Ô sorry for the double post, I just re read what you said and looked it up. "All MOC orders must be received at NYSE markets by 15:50 ET, unless entered to offset a published imbalance. NYSE markets' rules also prohibit the cancellation or reduction in size of any market-on-close (MOC) order after 15:45 ET." Now I understand what you mean. I probably can't use it in this case then. Thanks for the advice. |
Re: Is it possible to place order at 15:59 or 16:00 and get a fill?
Hi ´³¨¹°ù²µ±ð²Ô, I tried on paper and it rejected the order with time conditions. However I did this instead without the time condition and it seemed to go through yesterday a few mins before market close, will try it on paper today hopefully it works as intended. Please let me know if I missed anything out.
Not sure if the tif for the MOC order should be "DAY" or "GTC" in this case.
|
Gateway loses historical market data every day
Hello,
my IB Gateway is configured for automatic restart every night. Each day the historical market data is yellow. See pic.. After close and relogin it is green.? 1. Can I manual reconnect the market data without closing the gateway? 2. Can I trigger reconnect market data per API? 3. Do you have other ideas how I can avoid manual restart? |
Re: Is it possible to place order at 15:59 or 16:00 and get a fill?
You probably can't, but why don't you give it a quick try in TWS or via the API to get a better feel for how things work? When you place a bracket order, IBKR wraps the attached orders (profit, loss, others) into a group for you. Only one of those attached orders should ever execute in case the parent fills. MOC orders (and MOO for that matter) are not compatible with groups since they cannot be cancelled after a certain point in time before market close (MOC) or market open (MOO).. My expectation is that IBKR rejects bracket orders when:
´³¨¹°ù²µ±ð²Ô
|
Re: Is it possible to place order at 15:59 or 16:00 and get a fill?
Thanks for the suggestion, how would I put this MOC order within my bracket order, would this work? Or do I not need to add a timecondition to an MOC order within this bracket?
|
Re: Historical Market Data Service error
I guess the name of your subscription gives it away. Your market data permissions for CME futures is "for Display on Trading Platform" not for consumption in machine readable form via TWS API. Market data is owned by the exchanges and licensed to companies such as IBKR so that they can offer subscriptions to their customers. Subscriptions for non-professional traders are generally less expensive than those for professionals, and subscriptions for "display to humans only" (raw, in the form of charts, for order entry, etc) is less expensive than subscriptions that provide access to raw real-time or historical data. You'll need a market data subscription that permits access from a client application via TWS API. ´³¨¹°ù²µ±ð²Ô On Tue, Aug 15, 2023 at 07:11 AM, <ohrmich207@...> wrote:
Error 162, reqId 3: Historical Market Data Service error message:No market data permissions for CME FUT, ... |
Re: Pairs trading: Parent vs Child order placement
If you need different quantities for the same security in a cadence where the execution of one order should enable the other order (trading in opposite direction), you can use pair trades mode for the child order with the same security and respective ratio of quantities:
order.HedgeType = "P";-- Best, DS |
Historical Market Data Service error
def get_historical_data(contract): nq_contract = Contract( |
Re: Pairs trading: Parent vs Child order placement
Thanks again for the very informative message. This highlights a couple of points of confusion with the TWS API.
This implies there's a mechanism by which an order can just be "attached" without being a bracket or a hedge order, and without having its quantities automatically modified. Maybe there's some way to tell the TWS API that an order is not a bracket order but rather an attached order that should simply execute when the parent executes. Edit: Actually, I originally misread your screenshot, I mistook different prices on each order to be quantities but now see that the quantity on all child orders is the same, 10 units. That's too bad anyway if that really is the case. Back to building a function that responds appropriately to incoming events. |
Retrieving live data for demo account via Python API?
I am trying to get live tick data (or at least data every second) through?TWS API Python.
I use the?self.reqTickByTickData(reqId, contract, "MidPoint", 0, True) method to retrieve tick by tick data where contract is specified as EURUSD as the following: eurusd_contract = Contract()
eurusd_contract.symbol = 'EUR'
eurusd_contract.secType = 'CASH'
eurusd_contract.exchange = 'IDEALPRO'
eurusd_contract.currency = 'USD' but data stream does not start. Someone else used this exact code to get data stream for equities and I wonder if this works differently to Forex or perhaps due to a demo account? Everything else in my code works as expected, I create the necessary class, can load historical data successfully using the contract above etc. |
No realized profit and loss for Forex ?
Hi,
if i execute m_pClient->reqPnLSingle(...) for the forex pairs i get 0.0 as pnl even if there were trades executed with a result different from 0. Why is that ? does this have something to do with virtual FX positions ? If i do exact the same for a stock i can get the correct pnl. |
Re: Level2 data falls behind actual market
Yes |
Re: Order entry time via the API?
I don't know how. Generally manual and automated are not very easy to run simultaneously. Trend is to add Manual capabilities UI directly on your automate so that your automate DB can store info |
Re: Order entry time via the API?
Thanks for the reply.
My application is listening for the openOrder callback, but I was expecting to see an order creation/submit time field on the order itself. For example, my application may not be running when an order is submitted manually via TWS, it is then not possible to find out via the API later what time it was submitted. |