Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
fredfortier committed Feb 9, 2018
2 parents 3c4c6c3 + 6b19822 commit 49b6792
Show file tree
Hide file tree
Showing 17 changed files with 360 additions and 251 deletions.
10 changes: 5 additions & 5 deletions catalyst/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ def get_environment(self, field='platform'):
The field to query. The options have the following meanings:
arena : str
The arena from the simulation parameters. This will normally
be ``'backtest'`` but some systems may use this distinguish
be ``backtest`` but some systems may use this distinguish
live trading from backtesting.
data_frequency : {'daily', 'minute'}
data_frequency tells the algorithm if it is running with
Expand All @@ -954,7 +954,7 @@ def get_environment(self, field='platform'):
The platform that the code is running on. By default this
will be the string 'catalyst'. This can allow algorithms to
know if they are running on the Quantopian platform instead.
* : dict[str -> any]
\* : dict[str -> any]
Returns all of the fields in a dictionary.
Returns
Expand Down Expand Up @@ -1032,7 +1032,7 @@ def fetch_csv(self,
argument is the name of the column in the preprocessed dataframe
containing the symbols. This will be used along with the date
information to map the sids in the asset finder.
**kwargs
\*\*kwargs
Forwarded to :func:`pandas.read_csv`.
Returns
Expand Down Expand Up @@ -1156,7 +1156,7 @@ def record(self, *args, **kwargs):
Parameters
----------
**kwargs
\*\*kwargs
The names and values to record.
Notes
Expand Down Expand Up @@ -1273,7 +1273,7 @@ def symbols(self, *args):
Parameters
----------
*args : iterable[str]
\*args : iterable[str]
The ticker symbols to lookup.
Returns
Expand Down
41 changes: 16 additions & 25 deletions catalyst/exchange/exchange_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def get_adj_dates(self, start, end, assets, data_frequency):
last_entry = None

if start is None or \
(earliest_trade is not None and earliest_trade > start):
(earliest_trade is not None and earliest_trade > start):
start = earliest_trade

if last_entry is not None and (end is None or end > last_entry):
Expand Down Expand Up @@ -600,14 +600,14 @@ def ingest_assets(self, assets, data_frequency, start_dt=None, end_dt=None,
if show_breakdown:
for asset in chunks:
with maybe_show_progress(
chunks[asset],
show_progress,
label='Ingesting {frequency} price data for '
'{symbol} on {exchange}'.format(
exchange=self.exchange_name,
frequency=data_frequency,
symbol=asset.symbol
)) as it:
chunks[asset],
show_progress,
label='Ingesting {frequency} price data for '
'{symbol} on {exchange}'.format(
exchange=self.exchange_name,
frequency=data_frequency,
symbol=asset.symbol
)) as it:
for chunk in it:
problems += self.ingest_ctable(
asset=chunk['asset'],
Expand All @@ -625,13 +625,13 @@ def ingest_assets(self, assets, data_frequency, start_dt=None, end_dt=None,
key=lambda chunk: pd.to_datetime(chunk['period'])
)
with maybe_show_progress(
all_chunks,
show_progress,
label='Ingesting {frequency} price data on '
'{exchange}'.format(
exchange=self.exchange_name,
frequency=data_frequency,
)) as it:
all_chunks,
show_progress,
label='Ingesting {frequency} price data on '
'{exchange}'.format(
exchange=self.exchange_name,
frequency=data_frequency,
)) as it:
for chunk in it:
problems += self.ingest_ctable(
asset=chunk['asset'],
Expand Down Expand Up @@ -830,7 +830,6 @@ def get_history_window_series_and_load(self,
field,
data_frequency,
algo_end_dt=None,
trailing_bar_count=None,
force_auto_ingest=False
):
"""
Expand Down Expand Up @@ -858,7 +857,6 @@ def get_history_window_series_and_load(self,
bar_count=bar_count,
field=field,
data_frequency=data_frequency,
trailing_bar_count=trailing_bar_count,
)
return pd.DataFrame(series)

Expand Down Expand Up @@ -887,7 +885,6 @@ def get_history_window_series_and_load(self,
field=field,
data_frequency=data_frequency,
reset_reader=True,
trailing_bar_count=trailing_bar_count,
)
return series

Expand All @@ -898,7 +895,6 @@ def get_history_window_series_and_load(self,
bar_count=bar_count,
field=field,
data_frequency=data_frequency,
trailing_bar_count=trailing_bar_count,
)
return pd.DataFrame(series)

Expand Down Expand Up @@ -962,12 +958,7 @@ def get_history_window_series(self,
bar_count,
field,
data_frequency,
trailing_bar_count=None,
reset_reader=False):
if trailing_bar_count:
delta = get_delta(trailing_bar_count, data_frequency)
end_dt += delta

start_dt = get_start_dt(end_dt, bar_count, data_frequency, False)
start_dt, _ = self.get_adj_dates(
start_dt, end_dt, assets, data_frequency
Expand Down
2 changes: 0 additions & 2 deletions catalyst/exchange/exchange_data_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ def get_exchange_history_window(self,
frequency, data_frequency
)
adj_bar_count = candle_size * bar_count
trailing_bar_count = candle_size - 1

if data_frequency == 'minute' and adj_data_frequency == 'daily':
end_dt = end_dt.floor('1D')
Expand All @@ -310,7 +309,6 @@ def get_exchange_history_window(self,
field=field,
data_frequency=adj_data_frequency,
algo_end_dt=self._last_available_session,
trailing_bar_count=trailing_bar_count,
)

df = resample_history_df(pd.DataFrame(series), freq, field)
Expand Down
2 changes: 1 addition & 1 deletion catalyst/exchange/utils/exchange_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ def resample_history_df(df, freq, field):
else:
raise ValueError('Invalid field.')

resampled_df = df.resample(freq).agg(agg)
resampled_df = df.resample(freq, closed='left', label='left').agg(agg)
return resampled_df


Expand Down
14 changes: 6 additions & 8 deletions catalyst/utils/run_algo.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class _RunAlgoError(click.ClickException, ValueError):
----------
pyfunc_msg : str
The message that will be shown when called as a python function.
cmdline_msg : str
The message that will be shown on the command line.
"""
Expand Down Expand Up @@ -416,7 +417,8 @@ def run_algorithm(initialize,
auth_aliases=None,
stats_output=None,
output=os.devnull):
"""Run a trading algorithm.
"""
Run a trading algorithm.
Parameters
----------
Expand Down Expand Up @@ -458,7 +460,7 @@ def run_algorithm(initialize,
This argument is mutually exclusive with ``data``.
default_extension : bool, optional
Should the default catalyst extension be loaded. This is found at
``$ZIPLINE_ROOT/extension.py``
``$CATALYST_ROOT/extension.py``
extensions : iterable[str], optional
The names of any other extensions to load. Each element may either be
a dotted module path like ``a.b.c`` or a path to a python file ending
Expand All @@ -469,12 +471,8 @@ def run_algorithm(initialize,
environ : mapping[str -> str], optional
The os environment to use. Many extensions use this to get parameters.
This defaults to ``os.environ``.
live: execute live trading
exchange_conn: The exchange connection parameters
Supported Exchanges
-------------------
bitfinex
live : bool, optional
Execute algorithm in live trading mode.
Returns
-------
Expand Down
Loading

0 comments on commit 49b6792

Please sign in to comment.