For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

Implementing a stock screener/scanner

  • Hey,

    I'm trying to implement a stock screener which scans 100 stocks and signals if the stock is in an oversold zone (using RSI). But it feels a little bit heavy to do it with backtrader.

    So I'm wondering what's the best way to implement it?
    Is backtrader a good library for this use case?

  • Backtrader is the best library to do anything. :)

  • administrators

    @xord37 said in Implementing a stock screener/scanner:

    But it feels a little bit heavy to do it with backtrader.

    Python is heavy, but there is something easy you may consider:

    • If you are loading the entire history of the data feeds, you may switch to just loading the latest bars (as many as needed by the RSI, which will depend on the period you are using)

    To take into account weekends and bank holidays you may add some extra bars to the backwards calculation.

  • administrators

    If you check this post, you will see the code for a screener which loads only some bars (based on the expected period for a Simple Moving Average) to sort them out.

    The source for the data feeds will of course play a role in how fast things execute

    • If you pull the data from a database, it will be fast, because the database will know where the starting date is and give you the data from that point onwards

    • If you use files, the code has to read the file from the beginning until it reaches the expected start date.

  • @backtrader
    Thanks! This is just what I was searching for.

    One question, why use an Analyzer class instead of the Strategy class?
    Maybe there's something fundamental that I don't understand here..

  • administrators

    There is nothing special. Do it as you prefer.

Log in to reply