Skip to content

Commit

Permalink
REL: Update stubs for 1.1.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
buinvest authored and richafrank committed Mar 10, 2017
1 parent 153f663 commit 7d27684
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 41 deletions.
6 changes: 3 additions & 3 deletions docs/source/whatsnew/1.1.0.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Development
-----------
Release 1.1.0
-------------

:Release: 1.1.0
:Date:
:Date: March 10, 2017

This release is meant to provide zipline support for pandas 0.18, as well as several bug fixes, API changes, and many
performance changes.
Expand Down
3 changes: 3 additions & 0 deletions etc/gen_type_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ def main():
# "from MOD import *" will re-export the imports from the stub, so
# explicitly importing.
stub.write(dedent("""\
import collections
from zipline.assets import Asset, Equity, Future
from zipline.assets.futures import FutureChain
from zipline.finance.asset_restrictions import Restrictions
from zipline.finance.cancel_policy import CancelPolicy
from zipline.pipeline import Pipeline
from zipline.protocol import Order
from zipline.utils.events import EventRule
from zipline.utils.security_list import SecurityList
"""))
Expand Down
105 changes: 67 additions & 38 deletions zipline/api.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import collections
from zipline.assets import Asset, Equity, Future
from zipline.assets.futures import FutureChain
from zipline.finance.asset_restrictions import Restrictions
from zipline.finance.cancel_policy import CancelPolicy
from zipline.pipeline import Pipeline
from zipline.protocol import Order
from zipline.utils.events import EventRule
from zipline.utils.security_list import SecurityList


def attach_pipeline(pipeline, name, chunksize=None):
def attach_pipeline(pipeline, name, chunks=None):
"""Register a pipeline to be computed at the start of each day.
Parameters
Expand All @@ -15,10 +18,11 @@ def attach_pipeline(pipeline, name, chunksize=None):
The pipeline to have computed.
name : str
The name of the pipeline.
chunksize : int, optional
chunks : int or iterator, optional
The number of days to compute pipeline results for. Increasing
this number will make it longer to get the first results but
may improve the total runtime of the simulation.
may improve the total runtime of the simulation. If an iterator
is passed, we will run in chunks based on values of the itereator.
Returns
-------
Expand All @@ -30,6 +34,23 @@ def attach_pipeline(pipeline, name, chunksize=None):
:func:`zipline.api.pipeline_output`
"""

def batch_order_target_percent(weights):
"""Place orders towards a given portfolio of weights.
Parameters
----------
weights : collections.Mapping[Asset -> float]
Returns
-------
order_ids : pd.Series[Asset -> str]
The unique identifiers for the orders that were placed.
See Also
--------
:func:`zipline.api.order_target_percent`
"""

def cancel_order(order_param):
"""Cancel an open order.
Expand All @@ -39,6 +60,26 @@ def cancel_order(order_param):
The order_id or order object to cancel.
"""

def continuous_future(root_symbol_str, offset, roll):
"""Create a specifier for a continuous contract.
Parameters
----------
root_symbol_str : str
The root symbol for the future chain.
offset : int
The distance from the primary contract.
roll_style : str
How rolls are determined.
Returns
-------
continuous_future : ContinuousFuture
The continuous future specifier.
"""

def fetch_csv(url, pre_func=None, post_func=None, date_column='date', date_format=None, timezone='UTC', symbol=None, mask=True, symbol_column=None, special_params_checker=None, **kwargs):
"""Fetch a csv from a remote url and register the data so that it is
queryable from the ``data`` object.
Expand Down Expand Up @@ -83,32 +124,6 @@ def fetch_csv(url, pre_func=None, post_func=None, date_column='date', date_forma
A requests source that will pull data from the url specified.
"""

def future_chain(root_symbol, as_of_date=None, offset=0):
"""
Look up a future chain.
Parameters
----------
root_symbol : str
The root symbol of a future chain.
as_of_date : datetime.datetime or pandas.Timestamp or str, optional
Date at which the chain determination is rooted. If this date is
not passed in, the current simulation session (not minute) is used.
offset: int
Number of sessions to shift `as_of_date`. Positive values shift
forward in time. Negative values shift backward in time.
Returns
-------
chain : FutureChain
The future chain matching the specified parameters.
Raises
------
RootSymbolNotFound
If a future chain could not be found for the given root symbol.
"""

def future_symbol(symbol):
"""Lookup a futures contract with a given symbol.
Expand Down Expand Up @@ -221,8 +236,9 @@ def order(asset, amount, limit_price=None, stop_price=None, style=None):
Returns
-------
order_id : str
The unique identifier for this order.
order_id : str or None
The unique identifier for this order, or None if no order was
placed.
Notes
-----
Expand Down Expand Up @@ -338,7 +354,7 @@ def order_target_percent(asset, target, limit_price=None, stop_price=None, style
----------
asset : Asset
The asset that this order is for.
percent : float
target : float
The desired percentage of the porfolio value to allocate to
``asset``. This is specified as a decimal, for example:
0.50 means 50%.
Expand Down Expand Up @@ -532,6 +548,19 @@ def schedule_function(func, date_rule=None, time_rule=None, half_days=True, cale
:class:`zipline.api.time_rules`
"""

def set_asset_restrictions(restrictions, on_error='fail'):
"""Set a restriction on which assets can be ordered.
Parameters
----------
restricted_list : Restrictions
An object providing information about restricted assets.
See Also
--------
zipline.finance.asset_restrictions.Restrictions
"""

def set_benchmark(benchmark):
"""Set the benchmark asset.
Expand Down Expand Up @@ -575,16 +604,16 @@ def set_commission(commission):
:class:`zipline.finance.commission.PerDollar`
"""

def set_do_not_order_list(restricted_list):
def set_do_not_order_list(restricted_list, on_error='fail'):
"""Set a restriction on which assets can be ordered.
Parameters
----------
restricted_list : container[Asset]
restricted_list : container[Asset], SecurityList
The assets that cannot be ordered.
"""

def set_long_only():
def set_long_only(on_error='fail'):
"""Set a rule specifying that this algorithm cannot take short
positions.
"""
Expand All @@ -599,7 +628,7 @@ def set_max_leverage(max_leverage):
be no maximum.
"""

def set_max_order_count(max_count):
def set_max_order_count(max_count, on_error='fail'):
"""Set a limit on the number of orders that can be placed in a single
day.
Expand All @@ -609,7 +638,7 @@ def set_max_order_count(max_count):
The maximum number of orders that can be placed on any single day.
"""

def set_max_order_size(asset=None, max_shares=None, max_notional=None):
def set_max_order_size(asset=None, max_shares=None, max_notional=None, on_error='fail'):
"""Set a limit on the number of shares and/or dollar value of any single
order placed for sid. Limits are treated as absolute values and are
enforced at the time that the algo attempts to place an order for sid.
Expand All @@ -628,7 +657,7 @@ def set_max_order_size(asset=None, max_shares=None, max_notional=None):
The maximum value that can be ordered at one time.
"""

def set_max_position_size(asset=None, max_shares=None, max_notional=None):
def set_max_position_size(asset=None, max_shares=None, max_notional=None, on_error='fail'):
"""Set a limit on the number of shares and/or dollar value held for the
given sid. Limits are treated as absolute values and are enforced at
the time that the algo attempts to place an order for sid. This means
Expand Down

0 comments on commit 7d27684

Please sign in to comment.