Last active
May 14, 2019 00:29
-
-
Save qharlie/3803dc7532513d3657635a0a46ac471c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import backtrader as bt | |
import util.data as btu | |
import os | |
def run_stock_scanner(tickers, _from, _to, analyzers): | |
cerebro = bt.Cerebro() | |
for ticker in tickers: | |
DataFactory = btu.get_store().getdata | |
data = DataFactory( | |
dataname=ticker, | |
timeframe=bt.TimeFrame.TFrame("Days"), | |
fromdate=pd.Timestamp(_from), | |
todate=pd.Timestamp(_to), | |
historical=True) | |
cerebro.adddata(data) | |
for a in analyzers: | |
cerebro.addanalyzer(a,_name=str(a.__name__)) | |
ret = cerebro.run(runonce=False, stdstats=True, writer=True) | |
return ret | |
# from scanner import run_stock_scanner, KitchenSinkAnalyzer | |
# | |
# tickers = btu.us_tickers() | |
# | |
# res = run_stock_scanner(tickers, | |
# '2019-04-10', | |
# '2019-05-10', | |
# [KitchenSinkAnalyzer]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment