Skip to content

Commit

Permalink
BLD: added the option to run remote-run using run_algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
AvishaiW committed Sep 17, 2018
1 parent 3cc607f commit 224896d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
4 changes: 2 additions & 2 deletions catalyst/utils/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

log = Logger('remote')

# AUTH_SERVER = 'http://localhost:5000'
AUTH_SERVER = "https://sandbox2.enigma.co"
AUTH_SERVER = 'http://localhost:5000'
# AUTH_SERVER = "https://sandbox2.enigma.co"

BACKTEST = 'backtest'
STATUS = 'status'
Expand Down
45 changes: 45 additions & 0 deletions catalyst/utils/run_algo.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from catalyst.utils.factory import create_simulation_parameters
from catalyst.data.loader import load_crypto_market_data
import catalyst.utils.paths as pth
from catalyst.utils.remote import remote_backtest

from catalyst.exchange.exchange_algorithm import (
ExchangeTradingAlgorithmLive,
Expand Down Expand Up @@ -435,6 +436,8 @@ def run_algorithm(initialize,
strict_extensions=True,
environ=os.environ,
live=False,
remote=False,
mail=None,
exchange_name=None,
quote_currency=None,
algo_namespace=None,
Expand Down Expand Up @@ -502,6 +505,12 @@ def run_algorithm(initialize,
This defaults to ``os.environ``.
live : bool, optional
Should the algorithm be executed in live trading mode.
remote : bool, optional
Should the algorithm run on a remote server.
currently, available only on backtest mode.
mail : str, optional- if running with remote=True then, mandatory.
to which email address shall the server send the results to.
exchange_name: str
The name of the exchange to be used in the backtest/live run.
quote_currency: str
Expand Down Expand Up @@ -566,6 +575,42 @@ def run_algorithm(initialize,
raise ValueError(
'cannot specify `bundle_timestamp` without passing `bundle`',
)
if remote:
if mail is None or not re.match(r"[^@]+@[^@]+\.[^@]+", mail):
raise ValueError("Please specify a 'mail' parameter which "
"is a valid email address, in order to "
"send you back the results")
return remote_backtest(
handle_data=handle_data,
initialize=initialize,
before_trading_start=before_trading_start,
analyze=analyze,
algofile=None,
algotext=None,
defines=(),
data_frequency=data_frequency,
capital_base=capital_base,
data=data,
bundle=bundle,
bundle_timestamp=bundle_timestamp,
start=start,
end=end,
output=output,
print_algo=False,
local_namespace=False,
environ=environ,
live=False,
exchange=exchange_name,
algo_namespace=algo_namespace,
quote_currency=quote_currency,
live_graph=live_graph,
analyze_live=analyze_live,
simulate_orders=simulate_orders,
auth_aliases=auth_aliases,
stats_output=stats_output,
mail=mail
)

return _run(
handle_data=handle_data,
initialize=initialize,
Expand Down

0 comments on commit 224896d

Please sign in to comment.