Positionsize not used when funds available

Hello, i have returned to using AB after a long absence and i am a bit rusty, An old AFL of mine is giving unusual (to me) results for a particular situation and i would appreciate being told what i am doing wrong to not get available funds allocated to a trade up to position size setting, ( preferably in AFL rather than a non-zero value in settings )..
For case 1 below i set position size to 15,000 in AFL code and also in settings. (This came about as i was trying to isolate the problem). I set initial equity up to 1m without changing the end problem.
Case 1. Initial Equity=1m, Test range 2 days. 4 stocks entered and stopped out next day, Settings image=
image

Also, Number of positions allowed in settings portfolio page = 4, entry volume limit %=10.
For this case i get 4 trades of $15,000 and no trades the next (last day).
Case 2. Change settings position size to zero. Get same 4 trades on day 1, but on day 2 only $130 in value is traded against the buy signal stock even though there should be $940,000 or so available.
Symbol Trade Date Price Ex. date Ex. Price % chg Profit % Profit Shares Position
OMH (long) 26th "" 1.39 "" 27 "" 1.48 ""6.47% "" -51.56 -39.54% 93.8 130.38
Case 3: corresponds to case 1 with start date 27th. OMH is not selected as a trade.
Case 4: corresponds to case 2 with start date 27th. OMH is selected as a trade worth $130.38 as in case 2..
I also tried backtests of several years and got the same last day results.
I also eliminated the position size setting in AFL code for that without it making a difference.
I suppose i have missed something basic in terms of what is or is not allowed, but i can't isolate what it is.
I am guessing that it has something to do with there (potentially) being all available trades (4) being filled before equity(1) and applystops are applied on the day of the next buy signal to the buys on the previous day.
Your assistance will be appreciated.

@gerryj did you use the "Detailed Log" option in the Backtester settings dialog (that you'll open clicking this icon immagine in an Analysise tab)?

immagine

In general, this log will provide a lot of useful information to understand what's going on with your tests.

3 Likes

Beppe, i have now! thanks for the tip.
I had continued running tests and now i am getting a different set of buys, so i have to backtrack a little in the morning (it's late here) and digest the detailed info. I will post the relevant detailed log then if i need more help.

Thanks to beppe's tip i have some different info and a detailed log. In this case, rather than a trade taking place with less than the desired position size, no trades take place on day 2.
The detailed log is below.:
There are 8 buy signals on day 2. ASL is the first but it doesn't pass "minShares/MinPosValue" test.
The other buys don't appear to get a look in.
I changed min shares to .1 and initial equity to 100000.
Comments?
Detailed Log:
Date Information
2018-02-23
Entry signals(score):AFG=Buy(1), APX=Buy(1), AX1=Buy(1), BAL=Buy(1), MYX=Buy(1), NXT=Buy(1), SFR=Buy(1), WTC=Buy(1),
Exit signals:
Enter Long, AFG, Price: 1.893333, Shares: 7922.535, Commission: 30, Rank: 1, Equity 99940, Margin Loan: 0, Fx rate: 1
Enter Long, APX, Price: 10.27083, Shares: 1460.446, Commission: 30, Rank: 1, Equity 99880, Margin Loan: 0, Fx rate: 1
Enter Long, AX1, Price: 1.07875, Shares: 13904.98, Commission: 30, Rank: 1, Equity 99820, Margin Loan: 0, Fx rate: 1
Enter Long, BAL, Price: 16.05625, Shares: 934.2157, Commission: 30, Rank: 1, Equity 99760, Margin Loan: 0, Fx rate: 1
4 Open Positions: , AFG (+7922.54), , APX (+1460.45), , AX1 (+13905), , BAL (+934.216), Market Value: 59477.58, Equity: 99357.58, Cash: 39880.00, Margin: 0.00, Net Cash Balance: 39880.00,
2018-02-26
Entry signals(score):ASL=Buy(1), BDR=Buy(1), LYC=Buy(1), MSB=Buy(1), NWH=Buy(1), OMH=Buy(1), ORE=Buy(1), PDN=Buy(1),
Exit signals:AFG=Sell, APX=Sell, AX1=Sell, BAL=Sell, MYX=Sell, NXT=Sell, SFR=Sell, WTC=Sell,
Exit Long, AFG, Price: 1.88, (Avg. exit pr. 1.88), Shares: 7922.535, Commission: 30, (Total comm.: 60), Profit: -165.6312 (-1.10 %), Entry rank:1, Equity: 99899.45, Fx rate: 1
Exit Long, APX, Price: 10.43, (Avg. exit pr. 10.43), Shares: 1460.446, Commission: 30, (Total comm.: 60), Profit: 172.4592 (1.15 %), Entry rank:1, Equity: 99899.45, Fx rate: 1
Exit Long, AX1, Price: 1.07, (Avg. exit pr. 1.07), Shares: 13904.98, Commission: 30, (Total comm.: 60), Profit: -181.6686 (-1.21 %), Entry rank:1, Equity: 99899.45, Fx rate: 1
Exit Long, BAL, Price: 16.2, (Avg. exit pr. 16.2), Shares: 934.2157, Commission: 30, (Total comm.: 60), Profit: 74.29351 (0.50 %), Entry rank:1, Equity: 99899.45, Fx rate: 1
ASL not entered because requested size is less than MinShares/MinPosValue
0 Open Positions: , Market Value: 0.00, Equity: 99899.45, Cash: 99899.45, Margin: 0.00, Net Cash Balance: 99899.45,

Hello, i can close this out now. The cause of the problem was due to the volume of shares being incorrectly downloaded -- out by a factor of 1m. This affects the min. shares needed to satisfy the position size setting (makes it very high), and a limit is applied by AB, and either you get the situation i originally posted, or no trade is entered, which makes sense. My AFL doesn't make use of volume so i couldn't find the cause there.
It is at this moment a mystery of how the volume was divided by 1m, but i guess it is finger trouble, and i will look into that.
Thanks again beppe for putting me on the right track.

As well, I found the reason for incorrect volume which led to the problem in the first place. I usually use eod data from one source, and i started using intraday from another to test out some ideas. That data comes in csv format, and the volume data for example looks like "5,123,456". AB unsurprisingly thinks it is 3 fields and posted 5 as the volume. My bad for not noticing it.