blankly-finance / blankly

🚀 💸 Easily build, backtest and deploy your algo in just a few lines of code. Trade stocks, cryptos, and forex across exchanges w/ one package.
https://package.blankly.finance
GNU Lesser General Public License v3.0
2.03k stars 261 forks source link

Cannot run a `screener` locally #175

Closed kobykotiv closed 1 year ago

kobykotiv commented 2 years ago

Description

Intro

What you are doing is amazing! A unified API for trades is hard to accomplish! Kudos to you!

This screener error

I am writing a 'conditional grid' trader bot.

If someTicker is unusually volatile, (ATR > 0.85) Then activate grid trading funciton. Else, just hold and do nothing.

Unfortunately, I must utilize a Screener to scan many different tickers, ["BTC-USD","ETH-USD","LTC-USD"] and I always get this error despite installing all the dependencies, (croniter). What else can I try to do to run a screener locally? I cannot find a solution in the documentation. Am I missing something?

settings.json

{
    "settings": {
        "use_sandbox_websockets": false,
        "websocket_buffer_size": 10000,
        "test_connectivity_on_auth": true,
        "coinbase_pro": {
            "cash": "USD"
        },
        "binance": {
            "cash": "USD",
            "binance_tld": "us"
        },
        "alpaca": {
            "websocket_stream": "iex",
            "cash": "USD",
            "enable_shorting": true,
            "use_yfinance": false
        },
        "oanda": {
            "cash": "USD"
        },
        "keyless": {
            "cash": "USD"
        },
        "ftx": {
            "cash": "USD",
            "ftx_tld": "com"
        },
        "ftx_futures": {
            "cash": "USD",
            "ftx_tld": "com"
        },
        "kucoin": {
            "cash": "USDT"
        }
    }
}

backtest.json (if applicable)

{
    "price_data": {
        "assets": []
    },
    "settings": {
        "use_price": "close",
        "smooth_prices": false,
        "GUI_output": true,
        "show_tickers_with_zero_delta": false,
        "save_initial_account_value": true,
        "show_progress_during_backtest": true,
        "cache_location": "./price_caches",
        "continuous_caching": true,
        "resample_account_value_for_metrics": "1d",
        "quote_account_value_in": "USD",
        "ignore_user_exceptions": true,
        "risk_free_return_rate": 0.0,
        "benchmark_symbol": null
    }
}

Error (if applicable)

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_5114/2898991751.py in <module>
      8 
      9 print(tickers)
---> 10 _screener = Screener(paperCoinbase,is_ticker_volitile,atickers,init=init)
     11 

~/.local/share/virtualenvs/blanklys-vrA71F_1/lib/python3.7/site-packages/blankly/frameworks/screener/screener.py in __init__(self, exchange, evaluator, symbols, init, final, formatter)
     62         if not blankly.is_deployed and blankly._screener_runner is None:
     63             cron_settings = load_deployment_settings()['screener']['schedule']
---> 64             blankly._screener_runner = ScreenerRunner(cron_settings)
     65 
     66         # TODO export the symbols here as a list

~/.local/share/virtualenvs/blanklys-vrA71F_1/lib/python3.7/site-packages/blankly/frameworks/screener/screener_runner.py in __init__(self, cronjob)
     33         except ImportError:
     34             raise ImportError("To run screeners locally, please \"pip install croniter\".")
---> 35         self.__main = __main__.__file__
     36 
     37         self.croniter = self.croniter(cronjob, datetime.datetime.fromtimestamp(time.time()).astimezone(timezone.utc))

AttributeError: module '__main__' has no attribute '__file__'

Platform Info

EmersonDove commented 2 years ago

Oh this is an interesting bug, I suppose the way we're finding your main file locally is very not compatible with your system or python version. This might take us some time to resolve but I'll ask our in-house linux guy to try it.