Commit Graph

1412 Commits

Author SHA1 Message Date
Tim d3f1e0ffa9 Small spelling change. 2013-02-16 17:43:38 +00:00
Tim b09ab5da99 Added closing parenthesis to comment note. 2013-02-16 17:39:18 +00:00
Tim 593aaa9880 Remove extra space in comment sentence. 2013-02-16 17:29:36 +00:00
fawce 3ae02281da Fixed bugs in the sequence of dividend payment calculations. Previously, we were using midnight of the current trading day in market close. That meant that we were "rewinding" the clock, and then checking the ex_date and pay_date. As a result, we were delaying payments by one day.
With this patch, on the close of markets we "fast forward" to midnight of the
next trading day and calculate the dividend payments. This patch assumes that
the dividend dates are all at midnight UTC.
2013-02-15 22:52:38 -05:00
Jonathan Kamens ccd3ab33e7 Upgrade numpy to 1.7.0 2013-02-14 11:48:05 -05:00
Thomas Wiecki 3c2e1d0726 Merge pull request #80 from quantopian/add_bars_yahoo
ENH: load_bars_from_yahoo provides OHLC. Based on Brian Cappello's code.
2013-02-13 13:23:42 -08:00
Thomas Wiecki 8c182ad66e ENH: load_bars_from_yahoo provides OHLC. Based on Brian Cappello's code. 2013-02-12 13:26:13 -05:00
Richard Frank f914c53790 Added parameter type validation to record_variables 2013-02-11 18:07:05 -05:00
Richard Frank 59d76ce378 Don't let record_variables be used after initialize. 2013-02-11 14:44:46 -05:00
Eddie Hebert 2600bbe1de Backfills a batch transform panel with supplemental data.
For the case where the window isn't covered by the data streaming
through the simulator.

e.g. in a case where the stocks being iterated over change every
quarter, the supplemental data will fill in the 'gap' missing from
the transform since the 'new' stocks were not streaming before
the beginning of the quarter.

Of note, test cases are covered by internal suites, but this could
use tests with completely mocked data.
2013-02-10 21:35:41 -05:00
Eddie Hebert aa1caae261 Fixes for trading calendar holidays for weekend holidays.
- Removes New Year's on Saturday, in that case there is no New Year's observed.
- Adds Monday after a July 4th Sunday
- Adds Friday before a July 4th Saturday
- Adds Monday after a Christmas Sunday
- Adds Friday before a Christmas Saturday
2013-02-10 17:23:29 -05:00
Eddie Hebert 3e050dff9c Changes rules for generating Thanksgiving holiday.
Thanksgiving is the 4th week of November, not the last Thursday
in November.

Some Novembers have 5 Thursdays, e.g. 2006
2013-02-09 23:42:31 -05:00
Eddie Hebert 699a47fe3d Converts batch transform panel to use pd.Panel dictionary arg.
Based on @twiecki's work in batch_to_pandas branch.
2013-02-08 00:01:41 -05:00
Eddie Hebert 79f7fe69ef Checks to make sure that an Event has a type before checking type.
The Dividend event is currently missing 'type', causing the type
check to fail.

TODO: Add a type to Dividends.
2013-02-07 18:17:26 -05:00
fawce 26ff73072c Emergency fix - filtering down to TRADE events in the transforms. 2013-02-07 18:01:21 -05:00
fawce 2b9368dedf Merge pull request #76 from quantopian/dividends_for_shorts
Implemented dividend costs for short positions.
2013-02-07 10:55:14 -08:00
fawce 31b528e8dd Implemented dividend costs for short positions.
Based on user feedback in Quantopian forums:
https://www.quantopian.com/posts/total-return-slash-dividends
2013-02-06 23:34:14 -05:00
fawce 817ed88e38 Adds dividends to performance tracking.
Algorithm returns and the risk calculations that depend on them now include
cash dividends. This commit does _not_ provide an API for user algorithms to
access dividends.

PerformanceTracker expects the dividend data to arrive as events, similar to
the way that Trades arrive. Dividends are expected to have adjusted payment
amounts that are inline with adjusted trades.

PerformanceTracker maintains state of all the unpaid dividends in the position
objects held in PerformancePeriod. Dividend objects contain all the relevant
dates (declared, ex, payment) as well as net and gross amounts. Dividends are
removed from the list as they are paid. Cash flow is not incremented until the
payment day. This creates the possibility of a dividend being owed but not
paid or realized before the end of a test. For example, a dividend with an
ex_date of today may have a pay date 2 weeks in the future. Right now the
algorithm does not receive any credit for unpaid dividends.

Tests cover buying/selling around the ex_date and payment_date, and checking
that the performance calculated is as expected.
2013-02-06 16:39:39 -05:00
fawce 372a714eb8 deleting the portfolio object from every event. 2013-02-06 16:35:24 -05:00
Eddie Hebert 983f3fab30 Fixes New Year's holidays inclusion in trading calendar.
If NYE lands on the weekend, the Monday following is a holiday.
2013-02-04 23:22:42 -05:00
fawce 40d25c5519 Update README.md 2013-02-03 16:28:20 -05:00
Eddie Hebert 8c04621f57 Changes stddev and vwap transforms to accept parameters as kwargs.
So that algorithms that specifiy market_aware, days and delta
as args can be transitioned to just specifying a window_length kwarg.

Moving towards removing market_aware and delta completely.
2013-02-02 13:22:37 -05:00
Eddie Hebert 48c874f22a Deprecates market_aware and delta kwargs to EventWindow.
The eventual goal is to remove the market_aware and delta kwargs,
but removing the kwarg completely would break the init
method of EventWindow based classes for existing algorithms.

In the meantime, this ensures that only market_aware is only ever
set to True and raises an error if it is False.

Also raises exceptions if values are set for delta, which was only
used if market_aware was False

Also, since the logic for checking window length is changed,
because in market aware mode we should always be checking the
window length, this adds some sanity checking to the window length.
2013-02-01 21:05:49 -05:00
Eddie Hebert 1bc19c052b Removes unused test transform. 2013-02-01 21:05:49 -05:00
Eddie Hebert be6572f1aa Change flag value on unit tests that use market_aware==False.
Changes these tests to use market_aware==True, so that unit tests
follow the same code path as actual execution.

All use of EventWindows against data follows market_aware behavior.

These tests are the only use of market_aware==False, so heading
down the path of removing market aware completely.
2013-02-01 21:05:49 -05:00
Eddie Hebert 18c7905ab9 Merge pull request #69 from mjhanninen/fix-example
Fixes an incorrect order in examples.
2013-02-01 09:50:47 -08:00
Eddie Hebert 3225c03c75 Merge pull request #70 from bernarpa/patch-1
Update zipline/transforms/stddev.py
2013-02-01 09:47:53 -08:00
Paolo Bernardi a11a57cec8 Update zipline/transforms/stddev.py
Fixed typo.
2013-02-01 17:47:31 +01:00
Eddie Hebert 68327f5a10 Removes documentation references to pavement.
The references to pavement were causing confusion on what libraries
are needed for installation.
2013-02-01 11:33:32 -05:00
Matti Hanninen 4026e6122f Fixes an incorrect order in examples. 2013-02-01 18:17:23 +02:00
Eddie Hebert 079d7b322e Updates README to distinguish between backtesting and trading. 2013-02-01 10:17:02 -05:00
Eddie Hebert 2859afa032 Fixes assert type of window length check. 2013-01-31 21:16:41 -05:00
Eddie Hebert 3dd1b36d38 Changes unit tests asserts to UnitTest methods.
So that evaluated variables are printed on fail.
2013-01-31 20:10:47 -05:00
Ryan Day 4d56f57468 Add the information ratio to risk metrics.
Calculates relative to the benchmark returns.
2013-01-31 18:25:36 -05:00
Eddie Hebert e43dfef65d Adjusts start date of test algo gen to account for market dates.
When date_gen changed to use market dates, the end of this env
was run over by the date_gen.
2013-01-31 13:20:11 -05:00
Eddie Hebert 69b87b859b Fixes trading day generation logic in test source.
This uses more of @fawce's original logic from record_var branch.

TODO: Add unit test to ensure that this function generates only
market days.
2013-01-31 13:06:15 -05:00
Eddie Hebert c298cfda03 Adds recorded variable to dual moving average example.
Attr: Thomas Wiecki <thomas.wiecki@gmail.com> (@twiecki)
2013-01-31 08:19:07 -05:00
Eddie Hebert 81337d1306 Adds the ability to record variables.
Takes the value set for a variable on handle_data and records it,
e.g.:
```
    def initialize(self):
        self.incr = 0
        self.record_variables(['incr'])

    def handle_data(self, data):
        self.incr += 1
```

Would record a variable of `incr`.

Emits the recorded variables as part of the daily performance.

This batch combins work from:
Thomas Wiecki <thomas.wiecki@gmail.com> (@twiecki)
fawce <fawce@quantopian.com> (@fawce)
2013-01-31 08:16:54 -05:00
Eddie Hebert dfd9f2105d Changes test_source date_gen to only emit trading days.
Based on @fawce's work on record_vars branch.
2013-01-31 07:13:53 -05:00
Eddie Hebert a6ce57ef4f Removes code branching on sequential/merged flags in StatefulTransform.
So that the unit tests exercise the same transform logic as what
is executed a TradingAlgorithm object.
2013-01-30 16:23:40 -05:00
Eddie Hebert 7443b0c602 Pulls alias_dt wrapper out of sequential_transforms.
So that stepping through/cProfile output are a little clearer.
2013-01-30 16:20:58 -05:00
Eddie Hebert 946ecfafc0 Adds a trading day index to tradingcalander.
The trading day index is all business days in range minus the
non trading days we are already calculating.

Also, uses trading calendar indexes for batch transform, since the
batch transform was the only use of non_trading_days.

Instead of constantly adding and removing holidays to do market
day delta math, uses pandas DatetimeIndex to get the index of the dates
and uses the index difference to calculate market days.
2013-01-30 14:36:37 -05:00
Eddie Hebert 47c8015489 Moves creation of non_trading_days into a function.
So that we're not leaving rules used for configuration hanging in
module space.
2013-01-30 14:33:44 -05:00
Eddie Hebert 44140d2de7 Fixes dates used in test factory for batch transforms.
The test factory was creating non-market days.
i.e. the date range spanned the weekend.

Using pandas' BDay frequency so that only business days are created.

This specific date range doesn't have holidays, so not accounting
for holidays in the factory.

Also, widens the range of the trading calendar to cover the test dates
generated by the factory which include 1990.
Previously the trading calendar began with 2002, meaning that holiday
and weekend adjustments with the data exercised by the factory did
not trigger when run with data in 1990.

This does increase the memory footprint of the tradingcalendar module.
However, only by a couple MB, so taking the hit there to enable
correct behavior.
2013-01-30 14:06:56 -05:00
Eddie Hebert 2587cd6512 Enriches message returned for test batch transform.
Adds formatting of the failing values when ReturnPriceBatchTransform's
data shape does not match the window_length.
2013-01-30 14:04:17 -05:00
Eddie Hebert d52a9f3a67 Corrects wording on event_window test, with regards to empty values.
These tests ensure that there are three, not two, empty values
at the beginning of the transform.

Also, ensures that we are using a window length of 3 on the tests.
So that wordings of errors,etc. match the window length.
2013-01-30 14:00:06 -05:00
Eddie Hebert 5b294faf0c Removes unused method. 2013-01-28 23:22:04 -05:00
Eddie Hebert c65522c787 Merge pull request #66 from rday/sortino_ratio
Add the Sortino ratio for downside risk
2013-01-28 11:14:59 -08:00
Ryan Day bb16eda1fa Force float value, and compare result against boundary 2013-01-28 14:08:44 -05:00
Ryan Day 64ffa055c9 Add the Sortino ratio for downside risk 2013-01-28 08:55:14 -05:00