Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
Re: reqHistoricalData returns low volumes
Thank you Gordon and Jurgen for such a complete answer. I did do a thread search but seem to be going through a streak of failure. I didn't spot the CLEARLY written topic, nor did I read the IB docs. I have no excuses and am sorry to been so remiss in my approach here. I am using 10.31.1m ( tws workstation). Please take the word duplicate out of the topic of my post as that's ANOTHER failure to add to the list :-) Thank you both SO MUCH for taking the time to do my thinking for me and I'll try not to do this again. cp |
Re: reqHistoricalData returns low volumes
Gordon is correct. You need to multiply the volume by 100 since you seem to be getting "volume in lots of 100" and not "volume in shares". TWS API has the feature HDMS_MARKET_DATA_IN_SHARES since TWS API version 185 (that is TWS/IBGW version 10.18.02). In order to receive shares:
That will move the decimal point to the right, but you will still see a (significant) discrepancy between the full day historical volume and other total volume reports. We had a thread about this in June with the title "How can you explain the substantially lower trading volume shown in IBKR?" Among the posts is one that I made where I compared the historical volume with the tick-by-tick volume for one AAPL day. Here the highlights:
Take a look at my post since it has a detailed tally for one AAPL day. 闯ü谤驳别苍
?
PS. If you don't mind, I'll rename this thread when posts have settled down a little and take the "duplicate lines" out of the title.
?
On Wed, Oct 16, 2024 at 03:30 PM, comicpilsen wrote:
|
Re: reqHistoricalData returns low volumes
IBKR report volume in full lot (100's), I would even say "of full lots", so in general IBKR volumes is lower than other feeds
?
Note from my experience:
It may also impact IBKR VWAP computation on low volume tickers.(more odd lots)
IBKR VWAP is slightly different than what others feeds do 'suggest' (impact is cumulative, hence more difference on VWAP by the end of a day)?
? |
Re: reqHistoricalData returns low volumes
sorry to be so dense but I'm missing something basic here. I'm still getting low volumes irrespective of useRTH=0 or useRTH=1 . I can run it at 3am or 9pm and I get the same results. What am I missing???? I just want the OHLC for stocks. I know it's my code but I'm not seeing it.
the contract looks like this
and the function looks like this
|
Re: Procedure Declaration does not match Error
开云体育You can message me directly if you wish.? They usually don't like programming specific questions, just TWS general issues. I have done a lot of VBA and you can set a break point i? the code and then step through using F8. Mel -------- Original message -------- From: "vicente via groups.io" <vicente@...> Date: 2024-10-15 3:37 p.m. (GMT-08:00) Subject: [TWS API] Procedure Declaration does not match Error Hello everyone,??
?
Recently I inherited a spreadsheet that connects to the TWS API and have been trying to get it to work as intended I keep getting the error message pictured below and am at a loss on how to fix it.? I am completely new to dealing with VBA and wouldn't know how to fix / address this issue.?
?
Thanks
?
?
|
Procedure Declaration does not match Error
Hello everyone,??
?
Recently I inherited a spreadsheet that connects to the TWS API and have been trying to get it to work as intended I keep getting the error message pictured below and am at a loss on how to fix it.? I am completely new to dealing with VBA and wouldn't know how to fix / address this issue.?
?
Thanks
?
?
|
Re: Close Orders Rejected
I think bespalex is on the right path. Do you know what your net beta exposure is? There's a Risk Navigator tool that will show you how your positions add up. Managing margin for multiple instruments is not trivial as it is not additive.
?
I would recommend giving this a go: https://www.interactivebrokers.com/campus/trading-course/ibkrs-risk-navigator/ |
Re: Close Orders Rejected
This can happen due to portfolio margin calculation, if for example you hold long QQQ and short NVDA, that will have a lower margin requirement than naked short NVDA, as the positions partly cancel each other's risk.
Also, as noted above, when you sell NVDA short, you got your cash position increase (you just sold shares you borrowed), and if later you somehow tied this cash or used it, you can't close your short as it requires buying shares back with cash. |
Re: duplicate rows from a simple api request reqHistoricalData
Hi both Thanks for the replies and going the extra yard. I checked both the raw ( pre merge) csv's and the duplicates are there. As Jurgen hasn't seen this behavior I am CERTAIN that the problem is my end. I'll turn OFF after market and look at this again ( thanks patrick) . I strongly suspect a programming error on my part. Thank you for confirming that this is aberrant behavior. cp |
Re: duplicate rows from a simple api request reqHistoricalData
"Implied_Volatility" is not part of the "TRADES" historical data Bar object, so you must be doing some data merging. And the values in that column are too large for NVDA VWAPs for those days. Any chance the second record each day gets generated within your data processing logic? I grabbed the same data, got only one record per day, and the records I received are identical to your #71612, #71614, and #71616 (after rounding to two digits). Also, what exactly does the contract look like ("Exchange", "Primary Exchange", others). 闯ü谤驳别苍 ?
On Sat, Oct 12, 2024 at 07:31 PM, comicpilsen wrote:
|
Re: duplicate rows from a simple api request reqHistoricalData
Comic, I'm just guessing but it looks to me like the rows aren't exactly identical. The highs and lows are different and the volumes. I am thinking the lower volume rows are after-market trading as you have specified "Trades". On Sat, Oct 12, 2024 at 5:32?PM comicpilsen via <comicpilsen=[email protected]> wrote:
|
duplicate rows from a simple api request reqHistoricalData
I'm sending
and getting two rows per day all the time but don't know why?
Am I missing something in the call please? |
Re: Close Orders Rejected
开云体育To check the impact of an order on margin, you can do a what-if in TWS or via the API before you enter the order and see the impact on margin requirement. Pls check the IBKR docs. It's not that easy to give a formula since it will depend on
a few factors incl margin mode of the account and??IBKR's margin calculation at the time (they've made some changes after the vol spike on August 5 for portfolio margin to make it more stringent due to wider bid/ask spreads).?
You're right the cash is reserved as collateral for a short position but the impact on margin may not be 0 by closing the position. Best is to always keep sufficient 'margin cushion'. I believe they show a warning in TWS when that goes below 10% but better to keep significantly higher than that especially when holding volatile products (options, tech stocks etc) rgds, Bart On Oct 12, 2024 at 11:44?AM -0700, Flaviu Paul via groups.io <flaviupaul@...>, wrote:
|
Re: Close Orders Rejected
I will use the what-if order, thank you, but I would want to use it when I try to buy a new stock so that I don't get into a situation where I am no longer able
to exit the current position on other stock.?
?
Is the formula something like this:
equityWithLoanAfter - initMarginAfter > buffer
?
"I thought you were trying to close out a short position. So for that you would need to buy back the stock so spend cash. "
?
It is a short position and I have to buy back the stock, but isn't the cash already taken when I open the trade and used as collateral?
?
? |
Re: Close Orders Rejected
开云体育I don’t think you can retrieve historical margin or excess liquidity. You can only see it for the current time in TWS in the account window. You can do a what-if order to see impact on margin situation at the present time, in TWS or via API.?
I thought you were trying to close out a short position. So for that you would need to buy back the stock so spend cash.? rgds, Bart On Oct 12, 2024 at 1:36?AM -0700, Flaviu Paul via groups.io <flaviupaul@...>, wrote:
|
Re: Close Orders Rejected
Thank you Bart.
I don't know how to get the historical excess liquidity or initial margin. The Daily PNL was positive when I tried to close the position and had unused cash.?
You mentioned that "since your cash position will reduce", my cash position would increase as I close the position as I exit the trade I transform the
shares back into cash. |