How to avoid overbuying/overselling
I am a beginner to backtrader. It seems that when I use self.buy or self.sell, I expect the trader to not use more cash than initially set with broker.setcash(x). However, this does not seem to happen. How can I make sure that no more than the set cash is used?
btdoesn't allow you to buy more than cash available. Short positions by default adds cash, but this can be turned off using
shortcashparameter, check out Docs - Broker.
Thank you for the quick reply!
I am quite new to trading, does this mean that the broker.getvalue() value might overestimate the real value of the portfolio, because loaned money is added to the total value?
No, this is what docs say -
shortcash (default: True)
If True then cash will be increased when a stocklike asset is shorted and the calculated value for the asset will be negative.
If False then the cash will be deducted as operation cost and the calculated value will be positive to end up with the same amount
@ab_trader just out of curiosity, why would anyone want shortcash=True? I can't seem to make sense of it.
@blake nvm, i figured it out