Commit Graph

1457 Commits

Author SHA1 Message Date
David Michalowicz 43d1af0240 MAINT: Refactor commission model class hierarchies 2017-05-12 12:31:36 -04:00
Scott Sanderson d653820be3 MAINT: batch_order_target_percent -> batch_market_order.
The only downstream contex that was using batch_order_target_percent
already had all necessary prices, so calling batch_order_target_percent
was wasteful.
2017-05-09 13:52:57 -04:00
dmichalowicz a4464e7d20 MAINT: Various futures slippage model fixes and cleanup
- Handle history lookback error before start date
- Adjust default futures slippage volume limit
- Allow subclassing EquitySlippageModel and FutureSlippageModel together.
2017-05-09 11:47:55 -04:00
Andrew Daniels d155d894fe MAINT: Pass data_frequency to get_history_window
This allows us to remove the check for whether the provided dt had a
time of midnight, which was a flimsy way to infer if the data frequency
was 'daily'. Besides the explicit check being preferable, this method
was broken on the futures calendar, since midnight is a valid market
minute.
2017-05-09 09:34:39 -04:00
Andrew Daniels a4f1171f1f TST: Adds MinuteEquityHistoryFuturesCalendarTestCase
Added as a subclass of MinuteEquityHistoryTestCase, where the primary
calendar is 'us_futures'.

Notes on modifications to MinuteEquityHistoryTestCase:

- To work on generic calendars, many tests now use set minutes for
  window start and end, and check the values on active equity minutes.
- test_minute_regular should test against active equity minutes
- Adapts test_minute_midnight to work with futures calendar
  - Use a method of getting the last open minute that works with
    calendars that are open at midnight
  - Test against Sunday at midnight, since the real intention of this
    test is to check that given a non-open minute, we fall back to the
    last open minute.
2017-05-09 09:34:38 -04:00
Andrew Daniels b2a39b4ae4 TST: Adds DailyEquityHistoryOnFuturesCalendarTestCase
Added as a minimal subclass of DailyEquityHistoryTestCase, swapping out
just the primary calendar. This requires significant modifications to
DailyEquityHistoryTestCase, to allow for a generic primary calendar.
2017-05-09 09:34:38 -04:00
Andrew Daniels f088afc1e1 MAINT: Modify ReindexBarReader.get_value to handle missing data
Instead of raising an exception, return 0.0 for volume, and nan for
everything else.
2017-05-09 09:34:37 -04:00
Freddie Vargus caed14adcc Merge pull request #1746 from quantopian/update-transaction-repr
MAINT: Add better repr for transactions
2017-05-08 14:54:24 -04:00
Richard Frank 0e0cb2f343 BUG: Fixed abstractness of MarketImpactBase 2017-05-05 14:09:02 -04:00
Andrew Daniels b3c1cd5535 MAINT: Display diff if input to daily bar writer has gaps/extra bars 2017-05-04 10:19:09 -04:00
Andrew Daniels 0d9f4d29f5 MAINT: Handle gaps in input to daily bars writer (#1778)
Previously, a dataframe passed into BcolzDailyBarWriter.write that was
missing an expected session between its first and last sessions would be
written incorrectly. Upon converting the dataframe to a ctable, the
values for all days following the gap would be shifted backwards, and
nans would be shifted in at the end.

This commit handles the issue by asserting that the number of rows in
the input table matches the number of sessions in the calendar between
the table's first and last sessions.

Also fixes a test that was mistakenly using minutes_in_range where it
should have been using sessions_in_range (uncovered by this change).
2017-05-03 20:49:22 -04:00
Freddie Vargus e0433c4718 MAINT: Add better repr for transactions
Flake8
2017-04-28 11:13:40 -04:00
dmichalowicz 6beb4d6a36 BUG: Futures slippage model could have zero transaction volume 2017-04-26 13:35:00 -04:00
Jean Bredeche c7250d3207 BUG: Python3 compatibility. 2017-04-26 10:47:27 -04:00
Jean Bredeche b55d4bd423 BUG: Add backwards compatibility for position lookup by int. 2017-04-26 09:55:05 -04:00
dmichalowicz dd21346eca API: Add slippage and commission models for futures 2017-04-25 17:29:41 -04:00
Jean Bredeche 15d8dc93a3 MAINT: PR feedback. 2017-04-24 15:41:23 -04:00
Jean Bredeche 8c5e4b7bbc BUG: Blotter should process as many splits as it can 2017-04-24 15:41:23 -04:00
Jean Bredeche 64746b186b BUG: get_splits should return empty list, not empty dict 2017-04-24 15:41:23 -04:00
Jean Bredeche 5305fbe471 REF: Remove assetfinder from PerformancePeriod 2017-04-24 15:41:22 -04:00
Jean Bredeche 9a0d9d868c REF: Remove asset_finder and multipliers from PositionTracker 2017-04-24 15:41:22 -04:00
Jean Bredeche e429664fa6 REF: Blotter no longer needs AssetFinder 2017-04-24 15:41:21 -04:00
Jean Bredeche 1f8e194e09 BUG: Position cost basis was calculated incorrectly for Futures
For futures, we need to divide the position’s commission by the
contract size to get a per-unit commission in order to properly update
the position’s cost basis.
2017-04-24 15:41:20 -04:00
Jean Bredeche b1248cb6d6 REF: Explicitly use Assets in Position, Order, Transaction
(Instead of `sid`, which were already usually assets)

Perf packets are unchanged and still emit `sid`: int
2017-04-24 15:41:13 -04:00
dmichalowicz f3086c548d API: Add factory for calendars 2017-04-24 09:37:32 -04:00
dmichalowicz 67dd149660 BUG: Ordered contracts could end prematurely 2017-04-21 15:52:21 -04:00
Andrew Daniels 4c334c6c38 PERF: Optimize session close lookups in resample bar reader (#1749)
Optimize session close lookups in MinuteResampleSessionBarReader:

- Adds `session_closes_in_range` method (along with
  `session_opens_in_range`) to TradingCalendar to allow vectorized
  retrieval of all values in a range of sessions.
- Improves code path for resampling a single session's worth of data (as
  is the case when calling `get_value`), since we don't actually need to
  look up the close minute.
2017-04-11 16:35:04 -04:00
Andrew Daniels 6dd1616c15 PERF: Use scalar lookups for TradingCalendar.schedule
When retrieving the open and close for a given session, we only care
about the scalar values, so using DataFrame.at instead of DataFrame.loc
is significantly faster.
2017-04-10 17:23:07 -04:00
dmichalowicz f6e1a95ca9 ENH: Preliminary support for Futures slippage and commission models 2017-04-10 14:37:20 -04:00
Maya Tydykov ea419492a2 Merge pull request #1739 from quantopian/fix-zipline-and-pandas-bug
Fix zipline and pandas bug
2017-04-07 12:22:06 -04:00
dmichalowicz 6f1d4b4a5f BUG: OrderedContracts chain could sometimes terminate on first contract 2017-04-07 10:01:22 -04:00
Andrew Daniels f4f2048a68 PERF: Avoid repeated recursive calls when getting forward-filled close
Instead of recursively calling `DailyHistoryAggregator.closes` until we
find a non-nan close, we can instead call `load_raw_arrays` once, and
find the value from the returned array.
2017-04-06 09:51:01 -04:00
Maya Tydykov 497708d86e BUG: address pandas normalization bug on non-sorted DT index 2017-04-04 17:00:32 -04:00
dmichalowicz 483ec5dae8 TST: Make TradingEnvironment resources static 2017-04-04 10:58:45 -04:00
dmichalowicz cf68953bf2 TST: Use 'us_futures' calendar in test fixtures 2017-04-03 10:18:03 -04:00
dmichalowicz 99dfe5961d BUG: Getting continuous future current contract failed on None 2017-03-30 12:09:55 -04:00
dmichalowicz 7829541112 EHN: Make continuous future adjustment style an argument 2017-03-29 08:49:12 -04:00
dmichalowicz 0d157859e0 BUG: Open and close resampling code could hit index errors 2017-03-28 16:06:29 -04:00
Jean Bredeche 6cf81a3f1c ENH: Allow override of order amount rounding. (#1722)
* ENH: Use regular rounding to calculate order amounts.

We previously tried to prevent accidental over-ordering by truncating
orders down unless they were within 1e-4 of the next higher integer.
Unfortunately, this makes it easy for a sell order to be one share short
of the desired position.

Using regular rounding treats both buys and sells in the same way.

* ENH keep non-rounding behavior consistent, but leave code structured to make easier to override

* DOC make round_order public and describe behavior in docstring
2017-03-27 20:44:12 -04:00
Freddie Vargus ca9da830fd STY: Add newline 2017-03-27 09:59:08 -04:00
Freddie Vargus 598444a2e8 TST: Test for adhoc holidays in CFEExchangeCalendar 2017-03-27 09:56:40 -04:00
Maxwell Rounds d66f7f53a0 ENH: Adding CFE Adhoc Holidays
The CFE was closed along with the NYSE in observation of the days of
mourning in honor of the passing of presidents Gerald Ford and Ronald
Reagan. The CFE also observed the closures due to Hurricane Sandy,
along with NYSE. Adding those adhoc holidays to exchange_calendar_cfe
and removing them from cfe.csv in tests. To fit with
USNationalDaysofMourning, also removing the closure in observation of
the day of mourning in honor of the passing of president Nixon in
1994, despite the fact that the exchange did not exist at that time.

Signed-off-by: Maxwell Rounds <maxwell.j.rounds@gmail.com>
2017-03-26 15:54:14 -07:00
David Michalowicz 15b8832421 Merge pull request #1718 from quantopian/more-generic
Add ContinuousFuture to lookup_generic
2017-03-25 09:23:35 -04:00
dmichalowicz c86798bc16 ENH: Add ContinuousFuture to lookup_generic 2017-03-25 09:04:17 -04:00
dmichalowicz 158d90a9ec ENH: Allow DataPortal.get_spot_value to accept multiple assets 2017-03-25 09:02:10 -04:00
Andrew Daniels 43d6004cff ENH: Adds StaticSids pipeline filter (#1717)
Useful for avoiding the need to create Asset objects when sids are
easier to use.

This is based off the existing implementation of StaticAssets, and
StaticAssets is now implemented as a wrapper around StaticSids.
2017-03-22 14:28:54 -04:00
dmichalowicz bb801344e9 ENH: Better error message for non-existent root symbol 2017-03-16 11:18:17 -04:00
Maya Tydykov f4455179d4 Merge pull request #1710 from quantopian/sort-pipeline-data-on-asofdate
Sort pipeline data on asofdate
2017-03-15 14:40:11 -04:00
Maya Tydykov 6e4060fc4f BUG: sort data on asof_date to resolve ts conflicts
MAINT: fix arg default and update docstring
2017-03-15 14:10:58 -04:00
Jean Bredeche ea1fb05676 ENH: teach BarData about current session's minutes 2017-03-15 13:40:33 -04:00