-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Order size for fixed amount of cash #137
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
Comments
self.buy(size=0.95) # Means use 95% available cash to purchase Check the below link for ref backtesting.py/backtesting/backtesting.py Lines 423 to 429 in aa6830b
|
To place an order for size equivalent of $100 value: current_price = self.data.Close[-1]
order_size = 100 // current_price hth |
Hi, I'm a beginner in this project.
I want to specify the trading size of the tutorial example:
However, by setting
size = 100
, I suppose it will trade for 100 units (shares of GOOGL) each time. Instead, I want to trade for an amount of size that is equivalent to 100 in cash for every trade.For example, if the stock price is 10$ per share, the trading size will be 10. If the price goes to $20, trade 5 shares then.
How shall I write it properly?
Thanks a lot!
The text was updated successfully, but these errors were encountered: