Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue in function to allocate #384

Open
GDQF opened this issue Aug 29, 2022 · 1 comment
Open

Issue in function to allocate #384

GDQF opened this issue Aug 29, 2022 · 1 comment

Comments

@GDQF
Copy link

GDQF commented Aug 29, 2022

Hi,

When I backtest multiple strategies, I am sometimes shown the error message below:

The difference between what we have raised with q and
the amount we are trying to raise has gotten bigger since
last iteration! full_outlay should always be approaching
amount! There may be a case where the commission fn is
not smooth

I went into the code and debugged. I was in a situation where self.integer_positions = True and

full_outlay <  full_outlay_of_1_more < amount 

In this particular situation, given that I can buy one more unit, the quantity should go up by one unit q+=1.
This would therefore lead to a new full_outlay that is much more closer to amount (but still inferior) which would then lead to the condition np.abs(full_outlay - amount) > np.abs(last_amount_short) to be False and therefore would not trigger the error message.

It appears that this situation is not taken into account in the code If full_outlay < full_outlay_of_1_more < amount then no action is taken to update the quantity nor the full_outlay.

This situation can definitely happen ! Reach out for more details.

                    full_outlay_of_1_more, _, _, _ = self.outlay(q + 1)

                    if full_outlay < amount < full_outlay_of_1_more:
                        break
                    else:
                        q += 1
                        full_outlay = full_outlay_of_1_more

@MDDietz1
Copy link
Contributor

This is an annoying error message that I have also struggled with. But looking at the code I can't replicate what you are describing/see how that is possible. There is a loop which increases the amount until the condition is satisified. The escape condition below would seem to require that full_outlay_of_1_more>amount

bt/bt/core.py

Lines 1619 to 1620 in edbc9b5

if full_outlay < amount and full_outlay_of_1_more > amount:
break

Please provide more detail! E.g. at what point in the code did you find full_outlay < full_outlay_of_1_more < amount

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants