Excessive Open Positions
Author: swuzy
Creation Date: 2/26/2015 2:20 PM
profile picture

swuzy

#1
Hi,
I used PosSizer set for One Trade per Symbol, and Configured to 20% of Equity, so I should have no more than 5 Open positions.
Settings are Daily Scale, 4 years, starting capital 100,000.
In running the code below on a set of 670 symbols (noted below), I end up with 7 open positions. So then I added the buy condition
CODE:
Please log in to see this code.
, but I still end up with 7 open positions. What am I doing incorrectly? How should it be written to work?

Thanks.
Seth

CODE:
Please log in to see this code.


The data set of 670 symbols is:

A AA AAL AAPL AAUKY ABB ABBV ABC ABEV ABT ACE ACN ACT ADBE ADI ADM ADP ADS ADSK ADT AEE AEP AES AET AFL AGN AIG AIV AIZ AKAM ALL ALLE ALTR ALXN AMAT AME AMGN AMP AMT AMX AMZN AN ANTM ANZBY AON APA APC APD APH ARG ASML ATI AVB AVP AVY AXAHY AXP AZN AZO AZSEY BA BAC BACHF BAM BAMXY BASFY BAX BAYRY BAYZF BBBY BBD BBL BBT BBVA BBY BCE BCR BCS BDX BEN BF/B BHI BHP BIDU BIIB BK BLK BLL BMO BMS BMY BNPQY BNS BP BRCM BRGYY BRK/B BSX BT BTI BTU BUD BWA BXP C CA CAG CAH CAJ CAM CAT CB CBG CBS CCE CCI CCL CELG CEO CERN CF CFN CFRUY CHEUY CHK CHL CHRW CHU CI CICHF CINF CL CLF CLR CLX CM CMA CMCSA CME CMG CMI CMS CNI CNP CNQ CNX COF COG COH COL COP COST COV CP CPB CRARY CRM CS CSC CSCO CSX CTAS CTL CTSH CTXS CVC CVS CVX D DAL DANOY DB DBSDY DCM DD DDAIF DDAIY DE DEO DFS DG DGX DHI DHR DIS DISCA DLPH DLTR DNB DNR DO DOV DOW DPS DRI DTE DTEGY DTV DUK DVA DVN E EA EADSY EBAY EC ECL ED EFX EIX EL EMC EMN EMR ENB EOG EONGY EPD EQR EQT ERIC ESRX ESS ESV ETE ETFC ETN ETR EW EXC EXPD EXPE F FANUY FAST FB FCX FDO FDX FE FFIV FIS FISV FITB FLIR FLR FLS FMC FOSL FOX FOXA FSLR FTI FTR GAS GCI GD GDFZY GE GGP GHC GILD GIS GLNCY GLW GM GME GNW GOOG GOOGL GPC GPS GRMN GS GSK GT GWW HAL HAR HAS HBAN HCA HCBK HCN HCP HD HDB HEINY HES HIG HMC HOG HON HOT HP HPQ HRB HRL HRS HSBC HSBC/PA HSP HST HSY HTHIY HUM IBDRY IBM IBN ICE IFF IGT IMO INFY ING INTC INTU IP IPG IR IRM ISNPY ISRG ITUB ITW ITYBY IVZ JBL JCI JD JEC JNJ JNPR JOY JPM JWN K KEP KEY KIM KLAC KMB KMI KMP KMX KO KORS KR KRFT KSS KSU L LB LEG LEN LH LLL LLTC LLY LM LMT LNC LO LOW LRCX LRLCY LUK LUKOY LUV LUX LVMUY LVS LYB LYG M MA MAC MAR MAS MAT MCD MCHP MCK MCO MDLZ MDT MET MFC MFG MHFI MHK MITSY MJN MKC MMC MMM MNST MO MON MOS MPC MRK MRO MS MSFT MSI MTB MTNOY MTU MU MUR MWV MYL NABZY NBL NBR NDAQ NE NEE NEM NFLX NFX NGG NI NILSY NKE NLSN NOC NOK NOV NRG NSANY NSC NSRGY NTAP NTRS NTT NU NUE NVDA NVO NVS NWL NWSA OGZPY OI OKE OMC ORAN ORCL ORLY OUBS OXY PAYX PBCT PBI PBR PBR/A PCAR PCG PCL PCLN PCP PCRFY PDCO PDRDY PEG PEP PETM PFE PFG PG PGR PH PHG PHM PKI PKX PLD PLL PM PNC PNR PNW POM POT PPG PPL PRGO PRU PSA PSX PTR PUK PVH PWR PX PXD QCOM QEP R RAI RBS RDC RDS/A RDS/B REGN REPYY RF RHHBY RHI RHT RIG RIO RL ROK ROP ROST RRC RSG RTN RY RYCEY SAN SAP SBMRY SBRCY SBUX SCCO SCG SCGLY SCHW SE SEE SFTBF SFTBY SHPG SHW SIAL SIEGY SJM SLB SLM SMFG SNA SNDK SNI SNP SNY SO SPG SPLS SRCL SRE SSL STI STJ STO STT STX STZ SU SWK SWN SWY SYK SYMC SYT SYY T TAP TCEHY TCTZF TD TDC TE TEF TEG TEL TEVA TGT THC TIF TJX TLSNY TLSYY TM TMK TMO TOT TRI TRIP TROW TRP TRV TS TSCDY TSCO TSLA TSM TSN TSO TSS TWC TWTR TWX TXN TXT TYC UL UN UNH UNM UNP UPS URBN USB UTX V VALE VALE/P VAR VFC VIAB VLKAY VLO VMC VNO VOD VRSN VRTX VRX VTR VZ WAT WBA WBK WDC WEC WFC WFM WHR WIN WIT WM WMB WMMVF WMMVY WMT WOPEY WPPGY WPX WU WY WYN WYNN X XEL XL XLNX XOM XRAY XRX XYL YHOO YUM ZION ZMH ZTS ZURVY
profile picture

Eugene

#2
Hi,

Consider using Position Options PosSizer's "Max Open Positions" option. I double checked that it should limit the number of open trades across the portfolio.


P.S.
QUOTE:
So then I added the buy condition
CODE:
Please log in to see this code.

, but I still end up with 7 open positions.

This code applies only on a per symbol basis, that's why it won't do -- unless a Strategy is rewritten for DataSetSymbols loop (e.g. rotational strategies).
profile picture

swuzy

#3
I was hopeful as to Position Options. But Ouch!

After I configured th to Max open positions = 5, Max open in symb = 1, Max Long = 5, Mas short 0, Max pos per day = 5,
and ran it, I got Zero trades. Huh!?

Not working for me. Sigh.
profile picture

swuzy

#4
Also, when I shuffle top left choices between Fixed Dollar, Pct of Equity, and Max Risk Pct, the input fields remain shaded out and not available for input changes.
profile picture

Eugene

#5
Settings Max Open Positions is enough. There is no need to enable any other options in this case. I double checked and it works correctly. To reenable the "shaded out" fields, uncheck "Use .Tag".
profile picture

swuzy

#6
It is strange. When I close the test strategy and open another similar one, I have trades, but 7 open positions (while using Position Options configured above).

When I reopen the test strategy, and run it with Position Options, I have no trades.

When run the test strategy without using Position Options (and just use the WL Percent of Equity 20%), I have trades and 7 open positions.

It is a mystery.
profile picture

swuzy

#7
So I exited WL, pulled up the test strategy, invoked Position Options. This time the fields were not shaded out; except for choice "For last position, use all what's left" which is greyed out. I configured it as stated above for 5 long positions.

I ran it and it generated trades.

However, when I check the Trade tab, Exit Date, I still see 7 open positions, not 5.

??

profile picture

Eugene

#8
I was unable to reproduce this using your code, DataSet and pos.sizing settings. Everything is processed correctly as can be seen:




Most likely, you haven't pressed the "Max Open Pos." button and expectedly, the option wasn't activated. Please follow this picture to set up the control properly:



profile picture

swuzy

#9
You are right, I had not clicked onto Max open position.

I have done so now. I believe I have set up my PosSizer the same as in your display.

However, my Open Positions are 6; and per the record, there are times that it goes to 8.

Still a puzzle, as to what I am not doing correctly.

Is it possible that these instances reflect a sell and a buy on the same day?



profile picture

Eugene

#10
I positively can not duplicate it using WL Developer 6.8, Google and BBFree data. Neither with "One Trade..." nor with "Position Options". I thought it could do with some symbols(s) not being updated (stopped trading) but that's not the case here.

1. Please try a different data provider: Yahoo, then Google. Any change?
2. Try on Dow 30 DataSet.
3. Experiment with different data ranges: All Data, Most Recent etc. Does it affect?
4. Which Wealth-Lab Pro version are you running currently? By chance, have you noticed similar behavior in previous builds?
profile picture

robinkno

#11
I have started getting very strange back test results where the number of open positions far exceeds my settings.

Please see the attached screen shot.

Prior to the latest upgrade I always used the Portfolio Simulation Mode; Percent of equity. The result would be Open positions at most 1 greater than expected and only a few times within that backtest. So for a 9.9% Percent of Equity I would usually get 10 as the max open positions but occasionally 11. Not a problem

However I have started seeing ridiculous open positions, see the screen shot.

I looked at the Open Issues and then the forum to see if this was recurring problem and found this thread which did not seem to get resolved.

I tried the Pos Sizer as detailed by Eugene, see screen shot.
I tried different strategies, on an SP500 dataset in Fidelity Data, and the same dataset in Ascii data.
Longer data ranges give a lot more excessive trades and even 5 year range gives 17 trades open when 10 (maybe 11) should be the max.

I know this thread was started prior to the latest upgrade but until now I never had this problem. You may recall some of the other issues I (and several others) have had since the upgrade which seems to have altered some ways the program operates. I know the program had to be re-coded but it does not work the same way it did before. There is something very flaky in the upgrade.

I look forward to suggestions to get around this latest hurdle.

Thanks
Robin.
profile picture

Eugene

#12
Robin,

Indeed seeing such an open position count looks unusual but prior to knowing what Strategies you tried I'll refrain from making conclusions. I'm not finding any discrepancy between the Position Options and the pure Percent Equity sizing in my tests between 6.9.15 and 6.9.20.

You did try out the PosSizer but haven't activated the very option we're talking about here. See pictures in posts #8 and #9 for an illustration of how it looks like when enabled i.e. the button pressed. At the moment there's no limit to the number of open positions. Please enable and retry.

If you like one of us to explain the higher position count please provide the Strategy or sample code used (if it's a downloadable one then the name would suffice) and Preferences (F12 key), esp. Backtest Settings.
profile picture

robinkno

#13
Eugene
QUOTE:
You did try out the PosSizer but haven't activated the very option we're talking about here. See pictures in posts 38 and #9 for an illustration of how it looks like when enabled i.e. the button pressed. At the moment there's no limit to the number of open positions. Please enable and retry


Sorry, but I don't see what is different, which button have I not pressed?
profile picture

Eugene

#14
Please review screenshots in posts #8 and #9 (where the other user acknowledges making the same mistake). "Max open positions" is a button and it must be clicked for the option to work. In your case it's depressed i.e. the option is inactive. Just having a number in the field per se is not enough - it's pressing the button on the left of the input field that does the trick.
profile picture

robinkno

#15
Got it!! I looked but could not see.
Yes that fixed the excessive trades, thanks.

The remaining question is why has the basic Pos Sizer stopped working?

But, thanks, I have the work around.
profile picture

Eugene

#16
Good to hear it works.

QUOTE:
The remaining question is why has the basic Pos Sizer stopped working?

Please refer to suggestion in my post #12 above, last paragraph.
profile picture

robinkno

#17
This is one strategy where the basic pos sizer isn't working.

CODE:
Please log in to see this code.
profile picture

Eugene

#18
"Reduce Quantity based on Volume" is the answer. It's pretty natural and expected that applying this option which, according to the User Guide, limits the trade quantity to the minimum of the projected position size and the specified percentage of the trade's bar volume, may result in much smaller position size taken (especially in small cap stocks). In other words it's applied after your usual position size of 10% is determined, potentially reducing it up to the minimum of 1 share (an extreme case of total illiquidity). The smaller the actal position size the more buying power is left and the more positions can be taken.

It would be less apparent if you would've run the same code on the Dow 30 DataSet (let alone some FAANG one) but S&P 500 contains stocks that trade much less actively at times. In addition, the way you've configured the similar option in the Position Options PosSizer, setting it to 0.1% vs 1% (in Preferences), overrides the Wealth-Lab's figure and makes the effect even stronger.

The latest upgrade is not to blame. Case closed.
profile picture

robinkno

#19
Thanks. Glad we got that resolved.
profile picture

Eugene

#20
You're welcome.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).