- ago
Can the IB broker information provided in the Accounts screen be accessed programmatically? Or how can a C# program query account positions, value, cash?
7
454
17 Answers

Reply

Bookmark

Sort
Cone7
- ago
#1
"Can it?" Anything is possible, but right now you'd have to create your own API client to do it.

I thought there was a feature request out there to build a bridge to access that info, but I couldn't find one in the list (yet).
0
- ago
#2
And I'm also curious as to "why" because WL7 encapsulates this in using the actual broker account's Equity value (optionally).
0
- ago
#3
QUOTE:
And I'm also curious as to "why" because WL7 encapsulates this in using the actual broker account's Equity value (optionally).

(Did you mean WL8?) Regarding account value, in a strategy that open positions with an algorithmically calculated % of equity for each symbol, wouldn't I require this data to calculate position size using Transaction.Quantity?
0
- ago
#4
QUOTE:
"Can it?" Anything is possible, but right now you'd have to create your own API client to do it.


Haha. Well, almost anything ;). By "can" I mean is it available in the product today.

I know these capabilities are exposed in IBKR API, based on their API documentation and I want to make sure I am not missing some capabilities that already exist in WL8 I'm not finding.

I'm not sure what's involved in creating my own API client. I'm betting it's way beyond my technical capabilities. Is the WL8 IB connector open source?

I will create a feature request post based on my experience with IB connector so far.
0
Cone7
- ago
#5
WL7 or WL8 -
If you just need a % of Equity-based Position Sizer, just select the Trading Preferences for Portfolio Sync - especially the one to use the Broker-reported Account value for new signals. Hit F1 to see the documentation on that.

However, if there's a reason you must calculate it in the script, then we'll need a feature request.
0
- ago
#6
QUOTE:
can you comment Cone's post #5 here?
Cone is correct about TD, but I am talking about Interactive Brokers (IB or IBKR), where this functionality appears to be available through their TWS API.

Here's what I was inquiring about:
If you just need a % of Equity-based Position Sizer, just select the Trading Preferences for Portfolio Sync - especially the one to use the Broker-reported Account value for new signals. Hit F1 to see the documentation on that.

QUOTE:
In order to potentially automate the process I go through manually today.

Have you tested the Broker-reported Account value for new signals?
0
- ago
#7
QUOTE:
Here's what I was inquiring about:
If you just need a % of Equity-based Position Sizer, just select the Trading Preferences for Portfolio Sync - especially the one to use the Broker-reported Account value for new signals. Hit F1 to see the documentation on that.

I believe I already answered your question in https://www.wealth-lab.com/Discussion/Access-Accounts-data-from-broker-programmatically-7914 post #3. Cone suggested I create a feature request for this, which is the origin of this feature request.
0
- ago
#8
QUOTE:
Have you tested the Broker-reported Account value for new signals?

Sorry, I'm unclear what you are asking. Are you asking if I looked at the Accounts page? If so, I am looking to access this information from new methods in C# code.
0
- ago
#9
QUOTE:
Sorry, I'm unclear what you are asking. Are you asking if I looked at the Accounts page? If so, I am looking to access this information from new methods in C# code.

It's been clear. Before we consider new features I asked why you think it may be even necessary now that WL8 encapsulates this.
QUOTE:
I believe I already answered your question in https://www.wealth-lab.com/Discussion/Access-Accounts-data-from-broker-programmatically-7914 post #3. Cone suggested I create a feature request for this, which is the origin of this feature request.

Can you elaborate with an example proving that Transaction.Quantity is superior to the built-in convenience?
0
- ago
#10
QUOTE:
Can you elaborate with an example proving that Transaction.Quantity is superior to the built-in convenience?

@Eugene, the Accounts page will show a live human being looking at their computer what is going on so in their account so they can make certain trading decisions. I don't see what that has to do with the request for automation hooks in code, although it is essentially the same account data. So I know the current API WL8 IB already knows how to access and *report* it. I am looking for it to be available to the strategy code via broker account queries as well.

Does that help?
0
- ago
#11
QUOTE:
Does that help?

No.

I've been talking about this option in Preferences, per Cone's post #5 here, which is designed to remove complexity:

Wealth-Lab gets the account value via broker APIs and uses it as the total Equity value for Pct of Equity sizing for new signals.
0
- ago
#12
QUOTE:
I've been talking about this option in Preferences, per Cone's post #5 here, which is designed to remove complexity:

@Eugene It definitely removes complexity but also lacks some flexibility when it comes to coding strategies. There are two shortcomings in regard to the use case envisioned in this feature request:
1. The account information is presented in the Accounts window but is not available to strategy code where it might be used for additional trading decisions.
2. Reporting data in a window requires a live human to look at it. I don't know how to drive automation from that (scraping?).
3. Please tell me how that would work with the use case to specify different % equity positions for different trades. I couldn't figure out how to do it with the current hooks in WL8.

I feel like we are retracing old ground as I have previously described this more than once. I'm apparently not communicating clearly. I'm not sure how else to explain it.

@Cone's response to me was that we would need a Feature Request to implement it, which I created here.
1
Cone7
- ago
#13
I'll mention this similar request which has an example of how a strategy might make use of account info -
https://www.wealth-lab.com/Discussion/Add-methods-for-portfolio-sync-in-strategy-code-like-FindPortfolioOpenPosition-7851
0
- ago
#14
If WL could see the actual "real" portfolio positions, then one wouldn't need Strategy Monitor anymore for "real-time" trading. Instead, we could use a "Strategy Trader" solution that would evaluate indicators in Initialize{} then Execute{} would only evaluate the last bar (skipping the backtesting part altogether) and generate Signals (Alerts) accordingly.

I'm not saying Strategy Monitor (and backtesting) should be scraped. We still need the backtesting simulation to develop and optimize the strategy and its parameters. But for actually generating the daily trading Signals, Strategy Trader only needs to Execute the last bar with the real portfolio positions. There's simply no need to perform a backtest simulation for the real-time trading case. And you wouldn't have to worry about trying to keep the simulation in sync with the real portfolio anymore.

And since Strategy Trader isn't doing backtesting in the first place (except with the last bar), it will be much more responsive than Strategy Monitor.

---
There's an issue about how PreExecute{} should work with this Strategy Trader solution, but perhaps that's a different topic.
0
- ago
#15
Interesting idea!
0
- ago
#16
QUOTE:
Interesting idea!

There are some issues (probably better discussed in another topic). And some of these issues have already been discussed when we talked about my ResyncPort(...) class a year ago, which I use both on WL6 and WL7/8. That class simply forces the off-the-Chart bar to use the real portfolio positions instead of the simulated positions. Recall, we do not want ResyncPort(...) to affect any of the backtesting stats, so the on-the-Chart bars are off limits to it. ResyncPort() only affects trading Signals and nothing else.

But what we can do today is provide the strategy a WL "supported" API to look at the real portfolio. What we do from there is another story (not related to this topic). After we get this feature request passed, we can talk more about what's next (like a Strategy Trader mode that uses the real portfolio to generate Signals for the off-the-Chart bar).
0
Cone7
- ago
#17
I don't know how that would reduce the need for the S. Monitor (you need a "conglomerator" to monitor many symbols), but there's certainly merit to the idea for the fast tick and n-second traders.
0

Reply

Bookmark

Sort