Commit Graph

2322 Commits

Author SHA1 Message Date
Joe Jevnik c2aae2e0f4 BUG: rolling panel data became misaligned after extend_back 2014-11-12 16:47:44 -05:00
Joe Jevnik 8df1a49031 BUG: When increasing the length dynamically, the rolling panel was
getting filled with the wrong datetimes and causing errors.

Updates the logic for addressing missing datetimes and adds unit tests
for the 2 main cases (no missing datetimes, and some missing datetimes).
2014-11-11 13:29:57 -05:00
Joe Jevnik 54b1f15983 STY: Removes unused import in run_algo.py 2014-11-10 10:21:43 -05:00
Joe Jevnik e56457c671 ENH: Makes breakpoints work in algoscripts started with the run_algo.py
script.

Adds an option kwarg to TradingAlgorithm named 'algo_filename' that
represents the file where the algoscript came from (if any). The
run_algo.py script will pass this argument with the value passed to the
'-f' flag. The default name is '<string>' to represent that the script
is coming from a string in python and not a file. This matches the
behavior of exec and the python convention for compiling code objects.
2014-11-10 10:14:56 -05:00
Joe Jevnik ca59abcc43 ENH: Makes schedule_function work in daily mode. 2014-11-06 10:49:49 -05:00
Joe Jevnik 93429d69f5 BUG: HistoryContainer creation at runtime did not work as intended. 2014-11-05 18:31:11 -05:00
llllllllll 9ddb033e67 ENH: Changes the default offset for time_rules.market_open to 1, and
makes it an offset from 13:30 UTC.

This is to be more consistent with the market_close, which is an offset
from 20:00 UTC.

This also makes market_open and market_close cache the dt to offset from
for each day.
2014-11-05 14:59:48 -05:00
Joe Jevnik e1a55131ec DOC: Updates the release notes to include information about the dynamic
history update.
2014-11-04 00:08:19 -05:00
Joe Jevnik ca1569f22a ENH: Adds a closes_in_range and opens_in_range. 2014-11-03 16:26:40 -05:00
Joe Jevnik f8f7f2fc4c ENH: Allows history to be dynamic and grow the container at runtime.
Previously, all specs had to be pre-allocated by using the 'add_history'
function. This is now no longer required and instead serves as a hint to
the HistoryContainer to pre-allocate the space for the given spec.

History can grow by increasing the length for a frequency, adding a
frequency, or adding a field. It can grow with any combination of
these.

HistoryContainer now is aware of the data_frequency of the algorithm,
and no longer uses the daily_at_midnight flag; instead, this is the
default behavior.
2014-11-03 15:57:44 -05:00
Delaney Granizo-Mackenzie 1c08f60f7c MAINT: Updated the naming scheme from reconstruct to set_state 2014-10-29 14:30:26 -04:00
Delaney Granizo-Mackenzie 589c014f73 ENH: Updated naming scheme of serialization methods. 2014-10-29 14:15:04 -04:00
Brian Fink 677f5ecde0 BUG: Hide account methods from repr 2014-10-29 13:41:15 -04:00
Brian Fink 287023498e BUG: Fix flake8 2014-10-28 22:10:28 -04:00
Brian Fink 93296d7ef5 ENH: Add serialization to account 2014-10-28 21:54:14 -04:00
Scott Sanderson affeb2afbc DEV: Add tz kwarg to get_datetime. 2014-10-23 00:59:50 -04:00
Thomas Wiecki 820115f7be MAINT: Replace iterkv with iteritems.
iterkv is being deprecated as of pandas 0.14.
2014-10-22 17:25:37 +02:00
Thomas Wiecki 18ad02f6a4 MAINT: Make len check for ffillable explicit. 2014-10-22 17:25:37 +02:00
Joe Jevnik c6e85d08f0 ENH: Does value checking for time offsets for market_open and market_close 2014-10-20 17:17:34 -04:00
Joe Jevnik 69124cb6ab BUG: Fixed a bug with offsets in week_start and week_end 2014-10-20 17:17:34 -04:00
Joe Jevnik 615228b272 ENH: Changes the default time_rule for schedule_function to market_open() 2014-10-20 17:17:34 -04:00
Joe Jevnik ad25f29b7b ENH: Provides aliases for the (Date|Time)RuleFactory classes for better Quantopian/Zipline interoperability 2014-10-20 17:17:34 -04:00
Joe Jevnik d360b9d9bd ENH: Provides a more descriptive error if market_open or market_close are provided a non-keyword argument that is not a datetime.timedelta 2014-10-20 17:17:34 -04:00
Scott Sanderson 76c32f2940 PERF: Use np.empty instead of np.ones.
No reason to use ones when we multiply everything by NaN immediately.
2014-10-18 16:49:27 -04:00
Scott Sanderson 7104725e3c DEV: Cleanup from PR comments.
Flip axes of numpy array in frame_from_bardata.
Add default=None to SidData.get.
2014-10-17 11:55:30 -04:00
Scott Sanderson 30c4a1a1dc PERF: Optimized rewrite of HistoryContainer.update.
Uses a numpy array instead of a dict of dicts when initializing history
container.

In testing this reduced the total time spent in HistoryContainer.update
by 66%.

BEFORE COMMIT:
Thu Oct 16 22:30:46 2014    results/cprofile/unoptimized

         185223320 function calls (182210491 primitive calls) in 401.351
         seconds

   Ordered by: cumulative time
   List reduced from 2398 to 27 due to restriction <'update'>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     8580    0.461    0.000  160.571    0.019
     qexec/zipline/history/history_container.py:388(update)

AFTER COMMIT:
Thu Oct 16 22:12:28 2014    results/cprofile/optimized

         143177181 function calls (140164352 primitive calls) in 272.403
         seconds

   Ordered by: cumulative time
   List reduced from 2395 to 27 due to restriction <'update'>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     8580    0.086    0.000   47.294    0.006 qexec/zipline/history/history_container.py:388(update)
2014-10-16 22:32:43 -04:00
Brian Fink 50c5b73a7b add account object to context 2014-10-10 17:10:45 -04:00
Joe Jevnik df234f516c BUG: Fixes various bugs with the event manager:
- NotHalfDay only worked at midnight
- week_(start|end) were actually month_(start|end)
- Removes check_args from api.
- Default offset of 30mins for market_(open|close)
2014-10-09 14:01:56 -04:00
Jonathan Kamens 1d3a8759bc MAINT: Remove use of deprecated getchildren method on xml element
Rather than calling getchildren on xml.etree.ElementTree elements,
we're now supposed to just itegrate over the elements.
2014-10-08 11:39:48 -04:00
Joe Jevnik d6e997e96c BUG: Stops the TradingEnvironment from being created at import time when
zipline.utils.events is imported.

Changes the class level attribute `env` on EventRule to a property so
that the environment is only looked up at when needed.
2014-10-07 12:30:28 -04:00
Joe Jevnik 3c37704a5b ENH: Adds a new api method schedule_function.
schedule_function takes a date rule, a time rule, and a function and
will call the function, passing context and data only when the two rules
fire. This allows for code that is conditional to the datetime of the
algo.

This is implemented internally with `Event` objects which are pairings
of `EventRule`s and callbacks.

handle_data becomes a special event with a rule that always fires. This
makes the logic for handling events more complete and compact.
2014-10-06 13:42:36 -04:00
Thomas Wiecki 6050b57fa4 Merge pull request #406 from gitter-badger/gitter-badge
DOC Add a Gitter chat badge to README.md
2014-10-05 01:23:25 +02:00
The Gitter Badger 02f5f30fdf Added Gitter badge 2014-10-03 22:46:37 +00:00
Scott Sanderson 490391b9ae TEST: Remove uncessary copy calls from history tests. 2014-10-03 06:07:02 -04:00
Scott Sanderson 028ba719a2 BUG: Fix numpy dtype casting bug that only manifests in pandas 0.14.0. 2014-10-02 18:09:51 -04:00
Scott Sanderson d52dc68b5a PERF: Use numpy functions for concatenation in history. 2014-10-02 16:10:56 -04:00
Scott Sanderson 19d97524da PERF: Don't apply lambdas to large DataFrames. 2014-10-02 11:12:51 -04:00
Scott Sanderson 235954d480 DEV: Overhaul core history logic.
Overhaul the core HistoryContainer logic to be more robust to changing
universes.

Major Changes
-------------
* Remove `return_frame` cache.  The original purpose of using
  return_frames was to avoid having to create new DataFrames on each
  iteration of handle_data, but we ended up having to copy the return
  frames anyway because user code could mutate the frames in place.
  Removing the return_frames reduces unnecessary copying, and reduces
  the logic of `get_history` to just forward-filling and concatenating
  two DataFrames.

* Use a `MultiIndex`ed DataFrame to represent
  `last_known_prior_values`.  This makes lookups faster and greatly
  simplifies the logic of adding and dropping sids.

* HistoryContainer no longer attempts to determine its universe based on
  the contents of its internal buffers.  The TradingAlgorithm
  controlling the container is now responsible for explicitly calling
  `add_sids` or `drop_sids` when securities enter or leave the
  algorithm's universe.  These methods, along with the internal
  `_realign` method, provide a clean interface for changing the universe
  of securities managed by the container.

* Refactor index mutation logic in `RollingPanel` into a
  `MutableIndexRollingPanel` subclass.  Maintenance of the old behavior
  is regrettably necessary to support `BatchTransform`.

* Refactor shared logic from `roll` and `get_history` into a single
  `aggregate_ohlcv_panel` method that's responsible for collapsing an
  OHLCV buffer into a frame.
2014-09-29 14:42:57 -04:00
Scott Sanderson b3c7c26cee MAINT: Remove unused function in test_rolling_panel.py. 2014-09-29 14:40:03 -04:00
Scott Sanderson fcb137e0bb DOC: Clarificatory comments in HistoryContainer. 2014-09-29 14:40:03 -04:00
Scott Sanderson 9152d8da37 DOC: Slightly better comment on Frequency._ffill. 2014-09-29 14:40:03 -04:00
Scott Sanderson c477680ca3 MAINT: Use filter builtin instead of if-statement and continue. 2014-09-29 14:40:02 -04:00
Scott Sanderson 97e4e5e94d MAINT: In _create_generator only overwrite perf_tracker when it's None. 2014-09-29 14:40:02 -04:00
Scott Sanderson 94b53bdcb7 MAINT: Minor tweaks to docstring. 2014-09-29 14:31:57 -04:00
Joe Jevnik 4db4256cfe MAINT: Adds a tests/utils/ directory and renames test_utils.py
to utils/test_factory.py
2014-09-29 12:57:39 -04:00
Scott Sanderson fd71f956c7 DOC: Add more information to IncompatibleHistoryFrequency message. 2014-09-19 23:48:55 -04:00
John Ricklefs 16827e1af4 REV: Revert numpy update (back to 1.8.1)
This reverts commit 0eb12156c8.
2014-09-18 14:10:13 -04:00
John Ricklefs 0eb12156c8 BLD: Update numpy to 1.8.2 2014-09-18 12:23:54 -04:00
Thomas Wiecki 4615b57fc2 MAINT: Add custom exception for incompatible history frequency specification. 2014-09-18 16:20:28 +02:00
Thomas Wiecki 69a66f776e BLD: Trying to fix travis. 2014-09-17 19:21:29 +02:00