Added requested changes
This commit is contained in:
parent
9b68986a2d
commit
d76ead271f
@ -11,11 +11,10 @@ from typing import Optional, Dict, Type
|
||||
|
||||
from freqtrade import constants
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
import validators
|
||||
import tempfile
|
||||
from urllib.parse import urlparse
|
||||
from urllib.request import urlretrieve
|
||||
import os
|
||||
import requests
|
||||
from pathlib import Path
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -82,14 +81,25 @@ class StrategyResolver(object):
|
||||
# Add extra strategy directory on top of search paths
|
||||
abs_paths.insert(0, extra_dir)
|
||||
|
||||
if validators.url(strategy_name):
|
||||
temp = tempfile.mkdtemp("freq", "strategy")
|
||||
abs_paths.insert(0, temp)
|
||||
try:
|
||||
# check if given strategy matches an url
|
||||
logger.debug("requesting remote strategy from {}".format(strategy_name))
|
||||
resp = requests.get(strategy_name, stream=True)
|
||||
if resp.status_code == 200:
|
||||
temp = Path(tempfile.mkdtemp("freq", "strategy"))
|
||||
name = os.path.basename(urlparse(strategy_name).path)
|
||||
urlretrieve(strategy_name, os.path.join(temp, name))
|
||||
Path(os.path.join(temp, "__init__.py")).touch()
|
||||
|
||||
temp.joinpath(name).write_text(resp.text)
|
||||
temp.joinpath("__init__.py").touch()
|
||||
|
||||
strategy_name = os.path.splitext(name)[0]
|
||||
|
||||
# register temp path with the bot
|
||||
abs_paths.insert(0, temp.absolute())
|
||||
|
||||
except requests.RequestException:
|
||||
logger.debug("received error trying to fetch strategy remotely, carry on!")
|
||||
|
||||
for path in abs_paths:
|
||||
strategy = self._search_strategy(path, strategy_name)
|
||||
if strategy:
|
||||
|
@ -23,6 +23,3 @@ coinmarketcap==4.2.1
|
||||
|
||||
# Required for plotting data
|
||||
#plotly==2.3.0
|
||||
|
||||
# Required for dynamic strategy loading from urls
|
||||
validators
|
||||
|
Loading…
Reference in New Issue
Block a user