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
Simplification of long short strategy like in SIT R #78
Comments
Hey @potholiday, This is also easy with Cheers, |
Hey thanks for the reply . I have tried this code #59 and I am getting the same error. Any idea why its happening. |
Hey @potholiday , Can you try running this code: import bt
import pandas as pd
data = bt.get('HYG', start = '2000-01-01')
sma = data.rolling(200).mean()
plot = bt.merge(data,sma).plot(figsize=(15,5))
signal = data > sma
s = bt.Strategy('above200sma', [
bt.algos.SelectWhere(data > sma),
bt.algos.WeighEqually(),
bt.algos.Rebalance()])
t = bt.Backtest(s, data)
res = bt.run(t)
res.display() This works fine on my end. Also, have you updated to the latest version of
Let me know if you still run into the issue. Cheers, |
Thank you it worked without upgrading. Can I ask you one more help? The above code is a long only strategy
for short strategy I can use this
what kind of changes needed for a long and short strategy
|
@pmorissette Can you please answer my last question that is what is the right way to get both long and short signals together and pass it to the strategy in bt. The doc for SelectWhere is not useful |
Hey @potholiday, The simplest way is to use See http://pmorissette.github.io/bt/examples.html#sma-crossover-strategy - I think this is what you are looking for. Basically, you tell Cheers, |
Ok so is this correct . its not showing any error.
And also what is the best way to pass multiple parameters
Tried this but its showing error
If I want to get Sorry for asking this many doubts but their are not many good tutorials available for |
You will have to put Hope this helps, |
Thank you for clearing my doubts and taking your valuable time for explaining it. Can you please suggest any community or forum where |
Hey @potholiday, I am not aware of any such places. I just wrote this code a while back and put it up on Github for others to use / report bugs / submit PRs, etc. My advice, if you are interested in this library, is to get comfortable with Python, pandas and numpy. You can also browse through You might want to check out Hope this helps, |
I have tired many other back-testing modules in python before; quantopian, backtrader, pyalgotrader are a few but I find your backtester Can I give you a small recommendation, As well as using this example can you add much simpler code to your example page. Your example code is a little bit complex for an average programmer like me but the below code I can understand easily.
Any way keep up the good work and once more thank you for taking your valuable time |
Hey @potholiday, Thanks for the kind words and I'm glad to hear you like Thanks again, |
I have used systemic investor toolbox (SIT) package in R and its very good for backtesting. In that package creating signal for long, short or long-short strategy is very easy.
and then pass the signal to a backtest function
It would be easier if bt also has similar simplified functions.
The text was updated successfully, but these errors were encountered: