Skip to content

Commit 7d27684

Browse files
buinvestrichafrank
authored andcommitted
REL: Update stubs for 1.1.0 release
1 parent 153f663 commit 7d27684

File tree

3 files changed

+73
-41
lines changed

3 files changed

+73
-41
lines changed

docs/source/whatsnew/1.1.0.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
Development
2-
-----------
1+
Release 1.1.0
2+
-------------
33

44
:Release: 1.1.0
5-
:Date:
5+
:Date: March 10, 2017
66

77
This release is meant to provide zipline support for pandas 0.18, as well as several bug fixes, API changes, and many
88
performance changes.

etc/gen_type_stubs.py

+3
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ def main():
1111
# "from MOD import *" will re-export the imports from the stub, so
1212
# explicitly importing.
1313
stub.write(dedent("""\
14+
import collections
1415
from zipline.assets import Asset, Equity, Future
1516
from zipline.assets.futures import FutureChain
17+
from zipline.finance.asset_restrictions import Restrictions
1618
from zipline.finance.cancel_policy import CancelPolicy
1719
from zipline.pipeline import Pipeline
1820
from zipline.protocol import Order
1921
from zipline.utils.events import EventRule
22+
from zipline.utils.security_list import SecurityList
2023
2124
2225
"""))

zipline/api.pyi

+67-38
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
import collections
12
from zipline.assets import Asset, Equity, Future
23
from zipline.assets.futures import FutureChain
4+
from zipline.finance.asset_restrictions import Restrictions
35
from zipline.finance.cancel_policy import CancelPolicy
46
from zipline.pipeline import Pipeline
57
from zipline.protocol import Order
68
from zipline.utils.events import EventRule
9+
from zipline.utils.security_list import SecurityList
710

811

9-
def attach_pipeline(pipeline, name, chunksize=None):
12+
def attach_pipeline(pipeline, name, chunks=None):
1013
"""Register a pipeline to be computed at the start of each day.
1114
1215
Parameters
@@ -15,10 +18,11 @@ def attach_pipeline(pipeline, name, chunksize=None):
1518
The pipeline to have computed.
1619
name : str
1720
The name of the pipeline.
18-
chunksize : int, optional
21+
chunks : int or iterator, optional
1922
The number of days to compute pipeline results for. Increasing
2023
this number will make it longer to get the first results but
21-
may improve the total runtime of the simulation.
24+
may improve the total runtime of the simulation. If an iterator
25+
is passed, we will run in chunks based on values of the itereator.
2226
2327
Returns
2428
-------
@@ -30,6 +34,23 @@ def attach_pipeline(pipeline, name, chunksize=None):
3034
:func:`zipline.api.pipeline_output`
3135
"""
3236

37+
def batch_order_target_percent(weights):
38+
"""Place orders towards a given portfolio of weights.
39+
40+
Parameters
41+
----------
42+
weights : collections.Mapping[Asset -> float]
43+
44+
Returns
45+
-------
46+
order_ids : pd.Series[Asset -> str]
47+
The unique identifiers for the orders that were placed.
48+
49+
See Also
50+
--------
51+
:func:`zipline.api.order_target_percent`
52+
"""
53+
3354
def cancel_order(order_param):
3455
"""Cancel an open order.
3556
@@ -39,6 +60,26 @@ def cancel_order(order_param):
3960
The order_id or order object to cancel.
4061
"""
4162

63+
def continuous_future(root_symbol_str, offset, roll):
64+
"""Create a specifier for a continuous contract.
65+
66+
Parameters
67+
----------
68+
root_symbol_str : str
69+
The root symbol for the future chain.
70+
71+
offset : int
72+
The distance from the primary contract.
73+
74+
roll_style : str
75+
How rolls are determined.
76+
77+
Returns
78+
-------
79+
continuous_future : ContinuousFuture
80+
The continuous future specifier.
81+
"""
82+
4283
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):
4384
"""Fetch a csv from a remote url and register the data so that it is
4485
queryable from the ``data`` object.
@@ -83,32 +124,6 @@ def fetch_csv(url, pre_func=None, post_func=None, date_column='date', date_forma
83124
A requests source that will pull data from the url specified.
84125
"""
85126

86-
def future_chain(root_symbol, as_of_date=None, offset=0):
87-
"""
88-
Look up a future chain.
89-
90-
Parameters
91-
----------
92-
root_symbol : str
93-
The root symbol of a future chain.
94-
as_of_date : datetime.datetime or pandas.Timestamp or str, optional
95-
Date at which the chain determination is rooted. If this date is
96-
not passed in, the current simulation session (not minute) is used.
97-
offset: int
98-
Number of sessions to shift `as_of_date`. Positive values shift
99-
forward in time. Negative values shift backward in time.
100-
101-
Returns
102-
-------
103-
chain : FutureChain
104-
The future chain matching the specified parameters.
105-
106-
Raises
107-
------
108-
RootSymbolNotFound
109-
If a future chain could not be found for the given root symbol.
110-
"""
111-
112127
def future_symbol(symbol):
113128
"""Lookup a futures contract with a given symbol.
114129
@@ -221,8 +236,9 @@ def order(asset, amount, limit_price=None, stop_price=None, style=None):
221236
222237
Returns
223238
-------
224-
order_id : str
225-
The unique identifier for this order.
239+
order_id : str or None
240+
The unique identifier for this order, or None if no order was
241+
placed.
226242
227243
Notes
228244
-----
@@ -338,7 +354,7 @@ def order_target_percent(asset, target, limit_price=None, stop_price=None, style
338354
----------
339355
asset : Asset
340356
The asset that this order is for.
341-
percent : float
357+
target : float
342358
The desired percentage of the porfolio value to allocate to
343359
``asset``. This is specified as a decimal, for example:
344360
0.50 means 50%.
@@ -532,6 +548,19 @@ def schedule_function(func, date_rule=None, time_rule=None, half_days=True, cale
532548
:class:`zipline.api.time_rules`
533549
"""
534550

551+
def set_asset_restrictions(restrictions, on_error='fail'):
552+
"""Set a restriction on which assets can be ordered.
553+
554+
Parameters
555+
----------
556+
restricted_list : Restrictions
557+
An object providing information about restricted assets.
558+
559+
See Also
560+
--------
561+
zipline.finance.asset_restrictions.Restrictions
562+
"""
563+
535564
def set_benchmark(benchmark):
536565
"""Set the benchmark asset.
537566
@@ -575,16 +604,16 @@ def set_commission(commission):
575604
:class:`zipline.finance.commission.PerDollar`
576605
"""
577606

578-
def set_do_not_order_list(restricted_list):
607+
def set_do_not_order_list(restricted_list, on_error='fail'):
579608
"""Set a restriction on which assets can be ordered.
580609
581610
Parameters
582611
----------
583-
restricted_list : container[Asset]
612+
restricted_list : container[Asset], SecurityList
584613
The assets that cannot be ordered.
585614
"""
586615

587-
def set_long_only():
616+
def set_long_only(on_error='fail'):
588617
"""Set a rule specifying that this algorithm cannot take short
589618
positions.
590619
"""
@@ -599,7 +628,7 @@ def set_max_leverage(max_leverage):
599628
be no maximum.
600629
"""
601630

602-
def set_max_order_count(max_count):
631+
def set_max_order_count(max_count, on_error='fail'):
603632
"""Set a limit on the number of orders that can be placed in a single
604633
day.
605634
@@ -609,7 +638,7 @@ def set_max_order_count(max_count):
609638
The maximum number of orders that can be placed on any single day.
610639
"""
611640

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

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

0 commit comments

Comments
 (0)