Commit Graph

554 Commits

Author SHA1 Message Date
Jonathan Kamens fd0530d889 MAINT: Flake8 2015-05-01 11:03:01 -04:00
Jonathan Kamens 557e6a3009 Every setup_logger needs a teardown_logger 2015-05-01 07:38:42 -04:00
Jonathan Kamens 656bd86c17 TST: One more overwrite_sim_params=False needed 2015-04-30 15:38:09 -04:00
Jonathan Kamens c94880af2c TST: Suppress warnings in test_history_add_field_* tests
Temporarily suppress warnings for one line of the
test_history_add_field_* tests to work around #576 until it's fixed.
2015-04-30 15:31:21 -04:00
Jonathan Kamens 5c546b4f6c TST: overwrite_sim_params=False in tests when using list of sources
When specifying a list of sources to algorithm.py:run in a unit test,
specify overwrite_sim_params=False to suppress the unnessary
UserWarning.
2015-04-30 15:30:19 -04:00
Jonathan Kamens 8f9f65bdc6 MAINT: Flake8 2015-04-30 14:31:01 -04:00
Jonathan Kamens dcb8aa06af TST: Simplify test_examples and convert to unittest TestCase
Also, remove use of os.chdir() in the test, which causes other tests
to break by changing the current directory in the middle of the test
run.
2015-04-30 14:24:30 -04:00
Jonathan Kamens 7bb2677a9d TST: Convert test_munge.py tests to unittest format 2015-04-30 13:27:46 -04:00
Jonathan Kamens 865a20099a MAINT: Use "difference" instead of "-" to make Pandas happy 2015-04-30 13:19:00 -04:00
Jonathan Kamens ca0f906b11 TST: Don't modify master security lists directory during tests
Rather than drop files temporarily into the master security lists
directory during unit tests, create temporary directories for the
tests. This avoids issues when the tests are being run at the same
time as other code that uses the real security lists data.
2015-04-29 21:41:32 -04:00
warren-oneill fdd4940faf make calendar test compare generated calendar with the benchmark calendar
renaming cal_days to bench_days
2015-04-20 15:02:30 -04:00
Brian Fink 82d2ddfa90 BUG: Fix limit orders
Only fill limit order if impacted fill price is better than the limit price.
If a limit order is partially filled, only fill the remaining shares if the
impacted fill price is better than the limit price.
2015-04-16 17:09:14 -04:00
Brian Fink 8baf52fe01 ENH: Add max leverage account guard 2015-04-10 15:19:54 -04:00
warren-oneill 61571601ac added test for initialization of max_date in TradingEnvironment and removed trading_day from max_date if statement. 2015-04-08 16:57:32 -04:00
warren-oneill 6432631981 uncommenting out test_calendar_vs_environment 2015-04-08 16:57:01 -04:00
Thomas Wiecki d578d5825e BUG: Filter nans in DataFrame and Panel sources.
If a SID hasn't started trading yet, pandas' convention is to use nans.
Before this change, zipline would raise an exception if there were nans in the
input data.

We now skip events where the prices contains a nan and has not been traded
before (in which case forward fill).

Fixes #446.
2015-04-08 17:00:22 +02:00
Eddie Hebert 314b22656f MAINT: Remove left over simple transform code.
Remove pieces that are no longer used now that the simple transforms are
wrappers around history via the SIDData object.

Move window length related pieces into batch_transform, since the rest
of the utils module is no longer used.
2015-03-30 14:18:39 -04:00
Jonathan Kamens fa755d54a7 STY: Flake8 2015-03-19 17:21:25 -04:00
Jonathan Kamens e942275108 STY: Flake8
Upgrade the version of the flake8, pep8, and mccabe PyPI packages, and
make the code changes necessary for compatibility with the updated
packages.
2015-03-19 17:21:25 -04:00
jfkirk 84d4fa3c08 ENH: Adds Equity and Future classes as extensions of Asset class 2015-03-19 13:23:40 -04:00
jfkirk 2fd2f02c2a MAINT: Refactors Security to Asset
This commit refactors the Security cython class to Asset, and refactors some fields of the class accordingly. This change is so the terminology is consistent and correct when Asset is extended to asset types that are not securities, such as futures.
2015-03-19 13:23:40 -04:00
Eddie Hebert e69cf46e63 TST/BUG: Remove incorrect time period from hardcoded date.
Incompatible with changes to date parsers which reject the mismatch of
13:31 and AM.
2015-03-19 10:15:05 -04:00
Dale Jung 7892a6943f RFT: Remove Position management from PerformancePeriod. This cuts down
on the number of per-tick update that occur since they were duplicated
per each PerformancePeriod. Also opens up the path to cythonizing the
entire object
2015-03-18 22:48:14 -04:00
Jonathan Kamens 6cd2f4f1f2 TEST: Update Security class unit tests for Python3 compatibility 2015-03-12 10:32:26 -04:00
Jonathan Kamens e19f02a2ec BUG: Handle all possible types of Security object __richcmp__ args
A cython __richcmp__ function isn't allowed to assume that its first
argument is the same as the type of the class to which it belongs, so
our code needs to account for either of its two arguments being of the
wrong type.

Furthermore, the correct way for __richcmp__ to handle when it doesn't
know how to do a comparison is to return NotImplemented.
2015-03-10 20:36:52 -04:00
Jonathan Kamens 716bdbb7cd BUG: Fix >= comparison for Cythonized Security object
The >= comparison for the Cythonized Security object was actually
doing <=. Fix this and add unit tests for all the Security object rich
comparison operators.
2015-03-08 09:31:50 -04:00
Delaney Granizo-Mackenzie c49b00e9a1 Merge pull request #510 from quantopian/move-serialization-methods-into-zipline
MAINT: Added pickle protocol methods into zipline.
2015-03-05 15:06:54 -05:00
Delaney Granizo-Mackenzie b095f09472 MAINT: Added pandas version check to version testing
Now version testing will only be run if the pandas version is
current. This is to allow the test matrix to pass on travis.
The version must be updated in file whenever pandas is upgraded.
2015-03-05 11:47:57 -05:00
Delaney Granizo-Mackenzie a2bc6dd1f5 BUG: Fixed bug with returning non-primitive dicts. 2015-03-04 17:47:48 -05:00
Delaney Granizo-Mackenzie 51677ea700 ENH: Added Dale's verbose serialization error tracking.
Thanks, Dale.
2015-03-04 17:18:29 -05:00
Delaney Granizo-Mackenzie fd0f07aab9 MAINT: Added new sample saved state. 2015-03-04 16:28:36 -05:00
Delaney Granizo-Mackenzie f9afb132e3 BUG: Fixed bugs in the file paths to the sample saved state. 2015-03-04 15:57:59 -05:00
jfkirk 0375b350b8 ENH: Adds Security cython class in new package 'zipline.assets'
The class is not yet used. Adding this class is part of the effort to allow Zipline
simulation of more types of assets than stocks.

DEV: Adds build_ext to .travis.yml
2015-03-04 14:19:29 -05:00
Delaney Granizo-Mackenzie 1f69126854 ENH: Added testing for versioning of serialized state. 2015-03-04 14:17:13 -05:00
Delaney Granizo-Mackenzie 5c756a84c5 ENH: Added tests for pickling zipline objects. 2015-03-04 14:17:13 -05:00
Delaney Granizo-Mackenzie 0f0b97e5ac MAINT: Refactored testing code. 2015-03-04 14:17:12 -05:00
Delaney Granizo-Mackenzie 56d87c5170 ENH: Added testing for serialization. 2015-03-04 14:17:12 -05:00
theandycamps d192b1846f MAINT: Move knowledge date for existing DNT list 2015-03-03 16:46:56 -05:00
Dale Jung 29aab7755f TST: updated test to the fact that we aren't creating new lists to store
orders
2015-02-27 05:06:02 -05:00
Dale Jung b3bc7e166d BUG: Remove sid entry from open_orders when there are none.
TST: updated tests for new open_orders behavior
2015-02-19 11:22:54 -05:00
Thomas Wiecki 760bbced73 Revert "ENH Allow order_percent to work with various market values"
This reverts commit dd37a49f2f as it lead to different algo behavior we have to investigate first.
2015-02-17 20:27:59 +01:00
Jeremiah Lowin dd37a49f2f ENH Allow order_percent to work with various market values
Currently, `order_percent()` and `order_target_percent()` both operate as a percentage of `self.portfolio.portfolio_value`. This PR lets them operate as percentages of other important MVs.

(also adds `context.get_market_value()`, which enables this functionality)

For example:
```python
order_percent('AAPL', 0.5)

order_percent('AAPL', 0.5, percent_of='cash')

order_target_percent('MSFT', 0.1, percent_of='shorts')

tech_stocks = ('AAPL', 'MSFT', 'GOOGL')
tech_filter = lambda p: p.sid in tech_stocks
for stock in tech_stocks:
    order_target_percent(stock, 1/3, percent_of_fn=tech_filter)
```
2015-02-12 14:15:20 +01:00
Dale Jung 38e8d5214d PERF: History Perf Enhancements
Limited use of `pandas` data structures in both `HistoryContainer` and
`RollingPanel`. Where possible, methods were amended to return raw
`ndarrays` with the indexing logic done separately. This allows us to
cut down the number of times pandas objects are created both as returns
and intermediate values. The separation of indexing from data access
allowed us to minimize the times we’d make use of pandas indexes.

This required that that certain methods like `NDFrame.ffill` be replaced
with versions that work with `ndarrays`. Some of this was done via
straight numpy methods and others by access pandas internal
machinery. Outside of allowing us to use faster ndarrays, many of these
function provided speedups over their pandas counterparts as we didn’t
require the extra features like handling multiple dtypes. i.e. np.isnan
is faster than pd.isnull, but only works with certain dtypes.
2015-02-11 06:25:53 -05:00
fawce 412baa3c3f fixed catastrophic bug in load_from_directory
and added a new test case
was not iterating over lookup date directory names, and
therefore mising all by one list of stocks.
discovered because of differing sort orders between
my local machine, other devs, and travis ci.
2015-02-05 13:57:41 -05:00
fawce 08a0d1b604 python 3.3 compatible iterators 2015-02-05 13:57:40 -05:00
fawce 1ab082102a first edition of leveraged etf list 2015-02-05 13:57:28 -05:00
fawce 536ace94b8 new security list class
and tests
2015-02-05 13:57:27 -05:00
fawce 909b412e9b modified do not order guard to take an iteratble or a container
container allows for dynamic restrictions, necessary for a
point in time implementation of the restricted list.
2015-02-05 13:56:46 -05:00
fawce 52f78fcbc7 restricted list trading control added. 2015-02-05 13:56:45 -05:00
fawce 6c3e1e1ba4 added tests for performance pack fields 2015-01-07 21:47:13 -05:00