4
$\begingroup$

I am looking for open source software which can download stock data (yahoo/google finance etc) and used for screening/scanning stocks using technical analysis, for example:

  1. return stock list if close price is greater than 10 period moving average, or
  2. return stock list if upper bolinger band is greater than stock close price etc

Can anyone suggest similar open source software?

$\endgroup$
  • $\begingroup$ It would nice if there is one. $\endgroup$ – Gordon Jun 10 '16 at 17:52
  • $\begingroup$ @vonjd I have already upvoted your answer but I am still looking for more suggestions(if exist) from other users $\endgroup$ – Eka Jun 17 '16 at 16:31
  • $\begingroup$ If you are still looking for more suggestions I think you should invest 50 or 100 of your reputation and start a bounty! $\endgroup$ – vonjd Jul 5 '16 at 6:25
  • $\begingroup$ I would try a simple linear regression and look for a slope near to zero with a very high r2 and a low sigma. $\endgroup$ – KIC Aug 31 '18 at 12:49
4
$\begingroup$

I think the most sophisticated solutions are to be found within the R universe.

One package that comes to mind is the quantmod package. You can use it to download data from Yahoo and Google finance, plot charts and filter your stocks using all kinds of technical indicators (that come with the package).

It can be found on CRAN: https://cran.r-project.org/web/packages/quantmod/index.html

To get you started: http://www.quantmod.com/examples/

A gallery of some of the technical indicators: http://www.quantmod.com/gallery/

The full documentation (100 p.) can be found here: https://cran.r-project.org/web/packages/quantmod/quantmod.pdf

$\endgroup$
3
$\begingroup$

Being the question tagged as python and given I look for small challenges for my platform, backtrader, I took the chance to see how easy would be to do this with the platform.

Documented at: http://www.backtrader.com/posts/2016-08-15-stock-screening/stock-screening/

The core code in this case is an analyzer which looks for assets which are above the 10-days moving average (example from the OP). The analyzer code:

class Screener_SMA(bt.Analyzer):
    params = dict(period=10)

    def start(self):
        self.smas = {data: bt.indicators.SMA(data, period=self.p.period)
                     for data in self.datas}

    def stop(self):
        self.rets['over'] = list()
        self.rets['under'] = list()

        for data, sma in self.smas.items():
            node = data._name, data.close[0], sma[0]
            if data > sma:  # if data.close[0] > sma[0]
                self.rets['over'].append(node)
            else:
                self.rets['under'].append(node)

It can be used directly with the built-in executable btrun (created by setup.py / pip) or managed with a hand-crafted script. A sample execution with btrun:

btrun --format yahoo --data YHOO --data IBM --data NVDA --data TSLA --data ORCL --data AAPL --fromdate 2016-07-15 --todate 2016-08-13 --analyzer st-screener:Screener_SMA --cerebro runonce=0 --writer --nostdstats

Yes: the prices are being directly downloaded from Yahoo with --format yahoo.

Which earlier today (before the market closed again today) delivered:

- Analysis:
  - over: ('ORCL', 41.09, 41.032), ('IBM', 161.95, 161.221), ('YHOO', 42.94, 39.629000000000005), ('AAPL', 108.18, 106.926), ('NVDA', 63.04, 58.327)
  - under: ('TSLA', 224.91, 228.423)

I am sure that the same can be done with other python platforms like pyAlgoTrade, zipline, etc. A list of known (to me) python open source platforms can be found in the README of backtrader on the front page of the repository: https://github.com/mementum/backtrader

Disclaimer: if not obvious, I am the author of backtrader

$\endgroup$
1
$\begingroup$

I would recommend using Python because it can be downloaded for Windows or Mac and is available in almost all Linux repositories as standard.

Once you have Python installed you can use any of the following links to see how to get your data

https://www.quantstart.com/articles/Downloading-Historical-Intraday-US-Equities-From-DTN-IQFeed-with-Python

https://stackoverflow.com/questions/12433076/download-history-stock-prices-automatically-from-yahoo-finance-in-python

https://github.com/leonth/bulk-download-quandl

https://pypi.python.org/pypi/googlefinance

https://code.activestate.com/recipes/511444-stock-prices-historical-data-bulk-download-from-in/

and of course once you have your data you can screen it in situ on your pc however you want by, for example, using a technical analysis library such as TA Lib and/or writing your own custom screener in Python. An example of the latter can be seen at

https://www.youtube.com/watch?v=Y4GHgJjIQnk

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.