Commit graph

31 commits

Author SHA1 Message Date
vikram-narayan
d708817e44 MAINT: use ISO 10383 codes for exchanges 2018-10-01 12:45:27 -04:00
Joe Jevnik
6969ebac53 ENH: vectorize dividend ratio calculation 2018-09-26 14:16:54 -04:00
Andrew Daniels
1ca8d8b1ea TST: Update some overrides of make_equity_daily_bar_data to use sids arg 2018-09-22 20:52:55 -04:00
Andrew Daniels
adce6ff549 TST: Refactor make_equity_daily_bar_data to take sids and a country code
On the path of allowing for tests to easily set up data across multiple
countries.

Most of the existing overrides have just been updated to take the new
signature without any other changes. They'll be update to incorporate
the new parameters in a subsequent commit.
2018-09-22 20:52:55 -04:00
vikram-narayan
d4ba48709d MAINT: use trading_calendars in zipline
- remove zipline.utils.calendars
- update imports
- add trading-calendars to requirements
2018-07-02 11:10:49 -04:00
David Michalowicz
caa75383c3 REF: Change auto close to happen at session end 2017-07-20 16:41:14 -04:00
Jean Bredeche
ea1fb05676 ENH: teach BarData about current session's minutes 2017-03-15 13:40:33 -04:00
David Michalowicz
60e8ea30e5 Merge pull request #1644 from quantopian/closed-means-closed
Don't allow ordering assets after their auto close date
2017-01-20 10:19:27 -05:00
dmichalowicz
6e707f97a7 BUG: can_trade was true for assets after their auto close date 2017-01-20 09:54:30 -05:00
Jean Bredeche
7c72a4fc56 BUG: fix a py3 invalid char 2017-01-19 20:43:48 -05:00
Jean Bredeche
b5438ac94e ENH: add current_session property to BarData 2017-01-19 16:53:49 -05:00
Eddie Hebert
9f60524e14 STY: Use def statements instead of lambda assignment. (#1639)
From pep-0008:

```
Always use a def statement instead of an assignment statement that binds a
lambda expression directly to an identifier.

Yes:

def f(x): return 2*x
No:

f = lambda x: 2*x

The first form means that the name of the resulting function object is
specifically 'f' instead of the generic '<lambda>'. This is more useful for
tracebacks and string representations in general. The use of the assignment
statement eliminates the sole benefit a lambda expression can offer over an
explicit def statement (i.e. that it can be embedded inside a larger expression)
```
2017-01-06 13:39:07 -05:00
Andrew Liang
3b5031a829 MAINT: Rename restrictions.py to asset_restrictions.py
For clarity as to what sort of restrictions these are
2016-09-30 16:35:24 -04:00
Andrew Liang
b70084c6bf ENH: can_trade should take restricted list into account
Additionally, create an option for a violation of a 'do not order'
trading control to log an error instead of failing
2016-09-29 10:11:14 -04:00
Jean Bredeche
ae0d41af6f ENH: Make reader.get_value raise NoDataOnDate if the date is not in the calendar.
DataPortal now catches the NoDataOnDate exception and returns nan for
OHLC and 0 for V.

Price is still forward filled, unchanged.
2016-09-14 22:21:43 -04:00
Jean Bredeche
fbd3774278
ENH: Update can_trade to check exchange time
BarData now takes the trading calendar as a parameter.

can_trade now checks if the asset’s exchange is open at the current or
next market minute (defined by the given trading calendar).
2016-08-31 21:22:06 -04:00
Eddie Hebert
151c3e45a7 TST: Fix get_last_traded_dt on bcolz daily reader.
Remove special handling for the last session of an asset, which was
moving the last traded back a session.

If the asset has data on a session, `get_last_traded_dt` should always
return that session if it is the parameter to the method.
2016-08-31 14:59:58 -04:00
Eddie Hebert
71a34bf7ac MAINT: Standardize reader get value methods.
The daily/session bar reader's `spot_price` took the same parameters and
returned the same kind of output as the minute bar reader's `get_value`.

Standardize on one method to make a common interface, which may be
formally factored out in a later patch; to help enable writing reader
implementations or mixins which can be agnostic to the bar frequency.
2016-08-24 12:46:36 -04:00
Jean Bredeche
9a2ad260e5
BUG: Temporarily commenting out new can_trade functionality until we sort out downstream dependencies. 2016-08-13 21:46:00 -04:00
Jean Bredeche
fd03004d9f TST: Add tests to verify that we check the correct exchange calendar for can_trade
Also added temporary code to skip trying to get the last price of a
Future until we have finished the Futures data layer.
2016-08-02 23:12:07 -04:00
Jean Bredeche
d8af3fb92e ENH: Augment data.can_trade to check whether the asset's exchange is currently
open.
2016-08-02 23:11:10 -04:00
Jean Bredeche
6fb4923cc7 Re-implemented the Calendar API.
Instead of having separate ExchangeCalendar and TradingSchedule objects, we
now just have TradingCalendar.  The TradingCalendar keeps track of each
session (defined as a contiguous set of minutes between an open and a close).
It's also responsible for handling the grouping logic of any given minute
to its containing session, or the next/previous session if it's not a market
minute for the given calendar.
2016-07-12 13:13:50 -04:00
Eddie Hebert
51eda06323 MAINT: Add equity to naming of bar data classes.
In preparation of adding futures, add equity to the names of both the
classes and methods for writing bcolz data. Futures data will use a
different minutes per day with a separate reader. This change will allow
both equity and futures fixtures to be side by side.

Also, break out the method which generates the dataframes and trading
days member into fixtures (`EquityMinuteBarData` and
`EquityDailyBarData`) on which the `*BarReader` fixture depends.  This
fixture is separated out to enable reader/writers in different formats
to use the same data setup. (There is internal code which needs to write
minute and daily bar data in a database format.)
2016-06-30 08:21:42 -04:00
jfkirk
75e0e4723d TST: Refactors more tests to use WithTradingSchedule 2016-06-08 13:34:20 -04:00
jfkirk
d9fc514fa8 TST: Adds TradingSchedule test fixture 2016-06-08 13:34:20 -04:00
jfkirk
4b7390ac81 WIP: Refactors tests to use TradingSchedule 2016-06-08 13:34:19 -04:00
jfkirk
c8304e8601 ENH: Adds ExchangeCalendar, TradingSchedule, and implementations
Conflicts:
	tests/data/test_minute_bars.py
	tests/data/test_us_equity_pricing.py
	tests/finance/test_slippage.py
	tests/pipeline/test_engine.py
	tests/pipeline/test_us_equity_pricing_loader.py
	tests/serialization_cases.py
	tests/test_algorithm.py
	tests/test_assets.py
	tests/test_bar_data.py
	tests/test_benchmark.py
	tests/test_exception_handling.py
	tests/test_fetcher.py
	tests/test_finance.py
	tests/test_history.py
	tests/test_perf_tracking.py
	tests/test_security_list.py
	tests/utils/test_events.py
	zipline/algorithm.py
	zipline/data/data_portal.py
	zipline/data/us_equity_loader.py
	zipline/errors.py
	zipline/finance/trading.py
	zipline/testing/core.py
	zipline/utils/events.py
2016-06-08 13:34:18 -04:00
Joe Jevnik
efac476976 ENH: make BcolzMinuteBarWriter.write take iterable
Updates the BcolzMinuteBarWriter.write api to allow users to pass their
data as a stream instead of requiring that they loop over their data
externally. This matches the API presented by BcolzDailyBarWriter.
2016-04-29 16:14:48 -04:00
Joe Jevnik
bc0b117dc9 MAINT: make the data loading apis more consistent.
Changes BcolzDailyBarWriter to not be an abc, data is passed as an
iterator of (sid, dataframe) pairs to the write method.

Changes the AssetsDBWriter to be a single class which accepts an engine
at construction time and has a `write` method for writing dataframes for
the various tables. We no longer support writing the various other data
types, callers should coerce their data into a dataframe themselves. See
zipline.assets.synthetic for some helpers to do this.

Adds many new fixtures and updates some existing fixtures to use the new
ones:

WithDefaultDateBounds
  A fixture that provides the suite a START_DATE and END_DATE. This is
  meant to make it easy for other fixtures to synchronize their date
  ranges without depending on eachother in strange ways. For example,
  WithBcolzMinuteBarReader and WithBcolzDailyBarReader by default should
  both have data for the same dates, so they may use depend on
  WithDefaultDates without forcing a dependency between them.

WithTmpDir, WithInstanceTmpDir
  Provides the suite or individual test case a temporary directory.

WithBcolzDailyBarReader
  Provides the suite a BcolzDailyBarReader which reads from bcolz data
  written to a temporary directory. The data will be read from
  dataframes and then converted to bcolz files with
  BcolzDailyBarWriter.write

WithBcolzDailyBarReaderFromCSVs
  Provides the suite a BcolzDailyBarReader which reads from bcolz data
  written to a temporary directory. The data will be read from a
  collection of CSV files and then converted into the bcolz data through
  BcolzDailyBarWriter.write_csvs

WithBcolzMinuteBarReader
  Provides the suite a BcolzMinuteBarReader which reads from bcolz data
  written to a temporary directory. The data will be read from
  dataframes and then converted to bcolz files with
  BcolzMinuteBarWriter.write

WithAdjustmentReader
  Provides the suite a SQLiteAdjustmentReader which reads from an in
  memory sqlite database. The data will be read from dataframes and then
  converted into sqlite with SQLiteAdjustmentWriter.write

WithDataPortal
  Provides each test case a DataPortal object with data from temporary
  resources.
2016-04-15 23:46:10 -04:00
Richard Frank
8b610a2ab7 TST: Cleaned up test references to adjustments db
If we don't clean them up, then windows can delete
the temp dir with the db.
2016-04-12 19:33:22 -04:00
Eddie Hebert
16fd6681a6 ENH: Rewrite of Zipline to use lazy access pattern
More documentation to follow in release notes.

Based on lazy-mainline branch, see for more details.

Also-By: Jean Bredeche <jean@quantopian.com>
Also-By: Andrew Liang <aliang@quantopian.com>
Also-By: Abhijeet Kalyan <akalyan@quantopian.com>
2016-04-04 16:12:58 -04:00