Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Search someone to help or work with me to make my algo backtestable, i am learning..

Hi !

I am writting this algo below, and i need your help to make it backtestable :)

i am currently at the line losstrade for a syntax error that i don't understand because the syntax pass for the order_size_after_loss line just before with the same syntax.

15 responses

Can you make it any more legible?

Hi Jamie, i put it through notebook :)

Upload post !

After a weekend and this morning on it, i share with you the progress of my work.

Bilan :
- no error backtest (it's already huge for me lol) But.. balance still flat, need help to determine that... Debugger can't :'(
- code simplified and clarified

My goal :
- Make this version backtastable
- Add module slippage and commision
- Make it tradable on multiple continuous future

my ultimate goal, use this strategy with an LSTM, and see if the percentage of success can be improved

Before that, see what is doing on equities.

I let you read it, me i'am going to drink a full coffee pot

Hi quant team,

I am remi guérin, my account is down, but like you see i will be able to create an other. Could you check what's wrong ? thanks :)
Fearing about to losse my work.. i send you a message at the feedback adress.

@Guer Rem / @guerin remi

Sorry for any inconvenience. You should have gotten a support email stating your account is now restored along with access to all your previous notebooks and algos. Quantopian automatically checks for attempts to import modules which are blacklisted or not supported. Too many attempts and a lock is placed on one's account. In cases like this, simply send an email to support and the lock can be manually lifted.

Again, sorry about that and also didn't intend to highjack this thread.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Hi Dan, thanks that works !

Hi all,

Post update!
My first report :)
I am still out of the constraints contest.
Now work on that. If you see something wrong, don't hesitate to tell me !

Hi !

The previous post was backtested just on AAPL.
Since i have built my pipeline with all constraints for the contest, and i have an error that i can not fix :

TypeError: zipline.pipeline.term.getitem() expected a value of type zipline.assets._assets.Asset for argument 'key', but got int instead.
There was a runtime error on line 87.

line 87 : algo.attach_pipeline(make_pipeline(), 'my_pipeline')

If someone can help me :)

Hi !

I find the problem for my previous post, it was the StockWit. i removed it and search later a custom factor to determine the alpha to optimize.
Now i have an other prob for :


AttributeError: 'list' object has no attribute 'referenced_assets'
There was a runtime error on line 285.


I dont understand, because i have no term refering to 'referenced_assets' at line 285.

It was bracket to remove for 'objective=[opt.TargetWeights(target_weights)],' objective=opt.TargetWeights(target_weights),

Best practice to screen out nans within the pipe as a rule:

screen=(beta.notnull() & securities_to_trade),

Hi BS,

I put .dropna() on all my pipeline_output lol

I noticed that i dont use correctly the constraint in my signal code "SignalUp" and "SignalDown".
The pipeline return True securities where it shouldn't
I attached the pipe. If someone can explain me :)

The pipe use apparently any() by default to determine if a list of bool is True or False and i cant get ahead to use all()... help ???!

Several issues...

First, one cannot use the and operator with factors. Use & instead. Factors can only be manipulated with a small set of methods and operators (see the list here https://www.quantopian.com/help#quantopian_pipeline_factors_Factor ). Using the and operator doesn't generate an error which often makes this hard to catch. Seems like everything is working but it really isn't.

Second, the & operator has a higher precedence than the comparison operators > and <. Put parenthesis around the factor comparisons to force python to evaluate those first. (see the python docs for info on precedence https://docs.python.org/3/reference/expressions.html#operator-precedence).

So, in the notebook replace the following:

SignalUp = (volume < (volume1/2) and close < close1 and close1 > close2 and close2 > close3 and close3 > close4 and close4 > close5 and close5 > close6 and close6 > close7 and close7 > close8 and close8 > close9 and close9 > close10 and close10 > close11 and close11 > close12 and close12 > close13 and close13 > close14)

With this. Notice the use of & instead of and and the parenthesis around any factor comparisons

    SignalUp = ((volume < (volume1/2))  
                & (close < close1)  
                & (close1 > close2)  
                & (close2 > close3)  
                & (close3 > close4)  
                & (close4 > close5)  
                & (close5 > close6)  
                & (close6 > close7)  
                & (close7 > close8)  
                & (close8 > close9)  
                & (close9 > close10)  
                & (close10 > close11)  
                & (close11 > close12)  
                & (close12 > close13)  
                & (close13 > close14))

Attached is a notebook with these changes. Hope this helps.

Good luck.

Hi Dan, many thanks, works fine !

I attach my first backtest in positive with a simple strategy.
I will incorporate other simple strat.