Hi All,
I have a portfolio of, let's say, 5 different futures symbols. I would like to keep track of the portfolio equity bar by bar for the purpose of position sizing each market using SetShareSize. Is it possible to do this from our code without using any Position sizer?
Any pointers will be helpful.
Thanks
Size:
Color:
Size:
Color:
Eugene, thank you very much for the pointers.
Size:
Color:
Hi,
I'm trying to run the code here (I already installed Community.Components):
http://www2.wealth-lab.com/WL5WIKI/kbInteractingWithPortfolioEquity.ashx
When I run the code in "Run a Strategy on-the-fly and display the portfolio equity curve" for a portfolio of 5 stocks, it compiles and runs but doesn't generate any trades. I'm using Portfolio simulation mode with fixed shares=1. If I keep everything the same, and remove the portfolio equity calculation part below
CODE:
Please log in to see this code.
then it generates trades. Any help will be appreciated.
Thanks.
Size:
Color:
QUOTE:
I'm trying to run the code here (I already installed Community.Components):
You (a free trial user) or maybe it was
tradertabb who
is a customer? (Yes, I notice virtually everything - both were trying to download the same extension from the same IP address at nearly the same time).
QUOTE:
Any help will be appreciated.
Sorry, this method is not supported. You're on your own with this. Good luck.
Size:
Color:
Eugene, yes indeed, I'm doing coding for the tradertabb account.
Are there any supported methods for accessing Portfolio level equity? The main goal is to be able do position sizing each market using SetShareSize using our own code without using any Position sizer.
Thanks.
Size:
Color:
In Wealth-Lab 6, accessing portfolio-level equity is only supported in PosSizers. Everything else is hackish to some extent. The most able and advanced hack is "Interacting Dynamically with Portfolio Level Equity" because it calls an interal method that Wealth-Lab is making a call to.
Nonetheless, it should work without any extra effort. Try the following:
1. Disable on demand update.
2. Restart Wealth-Lab or simply re-run with ClearGlobals(); inserted before other methods to clear global memory from any execution artifacts.
3.1. Run the code on only one symbol (multi-symbol backtest is done behind the scene),
3.2. and step on the first symbol of a DataSet to be sure.
Size:
Color:
P.S. I wonder why the fuss with SetShareSize at all? Why do you think you need the portfolio equity?
Size:
Color:
Eugene, thank you very much. I followed your steps and still I'm not getting any trades in the Trades tab and the performance tab is not showing any change in equity.
Although I see that Portfolio Equity chart is fluctuating, the one created by the OnTheFly class.
For position sizing, I'm using:
Portfolio Simulation Mode
Starting Capital = 100,000
Shares = 1
If I can get this working, can I set SetShareSize in the donor strategy based on previous bar's Portfolio Equity?
Thanks.
Size:
Color:
>>P.S. I wonder why the fuss with SetShareSize at all? Why do you think you need the >>portfolio equity?
Eugene, I'd like to be able to set the position sizes with respect to :
1) changing volatility in the individual market
2) changing volatility in the portfolio equity (kind of similar to DVar)
Thus, I need to be able to access the portfolio and individual market equity series bar by bar and then look back a certain number of bars to do the calculations. For instance, for the current bar, I'll need to access the equity curves starting from the previous bar.
Thanks.
Size:
Color:
QUOTE:
I followed your steps and still I'm not getting any trades in the Trades tab and the performance tab is not showing any change in equity.
With this method you will not get any trades in the Trades tab, there's not going to be any change in equity on the Equity tab, and no alerts are going to show up on the Alerts tab. This is by design.
The sole purpose is to get the equity curve by the portfolio simulation executing in the background (so to speak). What you should be seeing is a ChartPane replicating the portfolio equity of the strategy, and that's all. (However, unless it's a Futures contract, with Shares = 1 there's not much of an equity movement.)
Size:
Color:
QUOTE:
With this method you will not get any trades in the Trades tab, there's not going to be any change in equity on the Equity tab, and no alerts are going to show up on the Alerts tab. This is by design.
The sole purpose is to get the equity curve by the portfolio simulation executing in the background (so to speak). What you should be seeing is a ChartPane replicating the portfolio equity of the strategy, and that's all. (However, unless it's a Futures contract, with Shares = 1 there's not much of an equity movement.)
OK, Eugene I got it now. I thought something was wrong since there was no activity in the mentioned tabs!
Size:
Color:
QUOTE:
1) changing volatility in the individual market
Volatility of the individual instrument's equity curve? Or simply the market's volatility, like in the % Volatility PosSizer? Whatever your answer will be, PosSizer still seems the natural way to go.
The market's volatility is pretty trivial, while building the individual market equity series in a PosSizer will present certain coding challenge. Still, it's natural to achieve the goal in PosSizer.
Size:
Color:
QUOTE:
Volatility of the individual instrument's equity curve? Or simply the market's volatility, like in the % Volatility PosSizer? Whatever your answer will be, PosSizer still seems the natural way to go.
The market's volatility is pretty trivial, while building the individual market equity series in a PosSizer will present certain coding challenge. Still, it's natural to achieve the goal in PosSizer.
Indeed, I meant the volatility of the individual instrument's equity curve. As you wrote market's (price) volatility is pretty easy to deal with.
Are you suggesting that there might be updates to the PosSizer?
OK, I ran the the sample code with 1 share for each market fixed. I added ClearGlobals() to the code as you suggested. The PL was +7500 from the Portfolio Equity chart. Then I removed the 'OnTheFly class' and ran the strategy as Multi Symbol Backtest. This time time the PL was -12,000. The position size was again set to 1 share. I think there's something going on here? Any suggestions?
Thank you.
Size:
Color:
QUOTE:
Are you suggesting that there might be updates to the PosSizer?
It serves its task well, so
this kind of update is not planned (too specific).
QUOTE:
Any suggestions?
Remove ClearGlobals(), it's only for debugging while I was under wrong impression (and you thought it was not working), then carefully re-read the entire Wiki article for suggestions. There's hardly anything else I'd like to add to this.
QUOTE:
Indeed, I meant the volatility of the individual instrument's equity curve.
It will be a challenge in the Strategy code as well. Keep in mind that even running the equity interaction hack using the overloaded call for singe-symbol backtest mode (SSB) is
NOT equal to the individual instrument's equity within a portfolio backtest:
CODE:
Please log in to see this code.
Don't waste your time with hacks, go for PosSizer.
Size:
Color:
Thanks Eugene!
QUOTE:
It will be a challenge in the Strategy code as well. Keep in mind that even running the equity interaction hack using the overloaded call for singe-symbol backtest mode (SSB) is NOT equal to the individual instrument's equity within a portfolio backtest:
But if the position sizing is set to fixed 1 share in both cases (commissions set to zero), then the individual instrument's equity within a portfolio backtest should be equal to the one for single-symbol backtest, right?
QUOTE:
Don't waste your time with hacks, go for PosSizer.
PosSizer is very good but doesn't have the flexibility we need. I think I might need to create an outside application that processes trades of individual markets (set to 1 share) and step through it one day at a time keeping track of portfolio and individual markets equities.
Thanks again.
Size:
Color:
QUOTE:
But if the position sizing is set to fixed 1 share in both cases (commissions set to zero), then the individual instrument's equity within a portfolio backtest should be equal to the one for single-symbol backtest, right?
True, when your portfolio has sufficient funds to execute all concurrent signals from all its constituents.
Consider that you have a DataSet with BRK.A and GOOG as of today and $125,000 to buy them on 2 simultaneously fired alerts. With 1 share, you couldn't.
Size:
Color:
CODE:
Please log in to see this code.
Yes, indeed good point there, although little bit extreme :)
My mock portfolio has 5 stocks with share prices < $200 and with $100,000 available. So they should be OK for this test.
Thanks Eugene. I think I need to write my own application here.
Size:
Color: