Commit Graph

1549 Commits

Author SHA1 Message Date
Eddie Hebert bb3e9727dc MAINT: Mask treasury_curves used by risk metrics to period range.
So that calculations that leverage the range of the treasury_curves,
like `pd.Series.searchsorted` will not overshoot the 'end' of the
range we are calculating risk metrics.
2013-04-04 13:44:22 -04:00
Eddie Hebert cf60eeb46b MAINT: Refactors out selection of treasury duration its own function.
Instead of having the duration selection logic in choose_treasury,
break out duration specific logig into another function.
2013-04-04 13:44:22 -04:00
Eddie Hebert 0cc953e00f MAINT: Move choose_treasury method from risk metrics class to module. 2013-04-04 13:44:22 -04:00
Eddie Hebert 2e603fa936 MAINT: Factor out treasury_curve argument from risk choose_benchmark
Move the reference to self.treasury_curve to a parameter, on the path
of making this method a module level function.
2013-04-04 13:44:22 -04:00
Eddie Hebert 39038131db MAINT: Remove saving of treasury duration.
The treasury_duration member in RiskMetrics is never used except
for in unit tests.

Remove the saving of treasury_duration in preparation for the
move of the choose_treasury method out of the RiskMetrics classes.

Down the line, if we do restore the sanving of treasury_duration,
choose_treasury can return a tuple that includes treasury_duration
instead of just returning the rate.
2013-04-04 13:44:22 -04:00
Eddie Hebert 8ea52e0421 MAINT: Factor out start and end date choose_treasury parameters.
Preparing for move of method to a module level function.
2013-04-04 13:44:21 -04:00
Eddie Hebert b461c0d91c MAINT: Move get_treasury_rate to risk module level. 2013-04-04 13:44:21 -04:00
Eddie Hebert 5f86ee72ee MAINT: Move search day distance function to module level. 2013-04-04 13:44:21 -04:00
Jonathan Kamens 4971d8478e MAINT: Specify --use-mirrors to pip install 2013-04-04 11:40:47 -04:00
Richard Frank 5a7702c22d MAINT: Factored out _create_data_generator helper method 2013-04-03 16:04:33 -04:00
Eddie Hebert 95ca73b15f MAINT: Remove unused members from risk test module. 2013-04-03 13:56:26 -04:00
Eddie Hebert a620afe639 STY: Add Test prefix to risk module test case. 2013-04-03 13:55:33 -04:00
Eddie Hebert 9627f48963 MAINT: Convert treasury curves data to pd.Series
Instead of using OrderedDict, use a pd.Series so that utilities
like searchsorted, etc. can be used.
2013-04-03 11:59:08 -04:00
Eddie Hebert 39f457ca28 MAINT: Use dateutil module for adding months to a datetime.
Instead of having an advance_by_months function maintained in
Zipline, leverage the relativedelta module provided by dateutil.
2013-04-03 10:41:47 -04:00
Eddie Hebert 0dca5d004a MAINT: Remove unused RiskReport.find_metric_by_end 2013-04-03 10:14:36 -04:00
Eddie Hebert 94f1152353 DEV: Update pegged version of requests. 1.1.0 -> 1.2.0 2013-04-02 20:14:24 -04:00
Eddie Hebert b3c23b0d8b MAINT: Rename risk metric function names to include '_ratio' suffix.
To make the risk metrics being calculated more clear, change the
naming convention that ratios have a '_risk' suffix.

Also, fixes typo in beta docstring.
2013-04-02 11:27:34 -04:00
Eddie Hebert 45bca4301f REL: v0.5.9
Highlights:

- Benchmark updating now permits empty ranges.
  (Fixes runtime crash when running immediately after Easter 2013.)
- Risk metrics
  - Performance improvents from converting to numpy and pandas.
    <@wesm, wesmckinn@gmail.com>
  - Refactoring of risk metric calculation out of class structure.
2013-04-02 11:22:31 -04:00
Eddie Hebert 05a03bcf21 BUG: Fix error during benchmark update over empty period.
On ranges with missing data from Yahoo, e.g.:
On 2013-04-2 the date range of April 2013-03-29 failed because
of the first day in the range being Good Friday, and the API not
yet updating for the Monday after.

Handle the 404 that is found by raising and warning that no
benchmark data was found, but continuing on.
2013-04-02 11:13:26 -04:00
Eddie Hebert dd172dd42a MAINT: Use trading day increment instead of timedelta in test factory.
In the test factory creation of returns, the date creation was using
a timedelta of one day instead of incrementing by trading days.

Working towards changing risk module behavior which would leverage
the trading day map, but tests fail because non-trading days are
created.

Remove `factory.create_returns`, moving uses of that function to us
`factory.create_returns_from_period`, since the number of days input
for `create_returns` was more difficult to use when specifying ranges
over arbirtray dates.
2013-04-01 23:52:50 -04:00
Eddie Hebert 210a43a306 MAINT: Factor out risk metric logic from risk objects.
Move the risk metric definitions to functions at the module level
with defined parameters.

Both risk implementations call these functions, where the difference
between risk implementations is with which internal data they
send to the various risk metrics.

Metrics moved:
- Sharpe Ratio
- Sortino Ratio
- Information Ration
- Alpha
2013-04-01 12:43:27 -04:00
Eddie Hebert 63063b1ebe DEV: Fixes typo in git stash message comparison. 2013-04-01 12:05:40 -04:00
Eddie Hebert 702e6f00d2 MAINT: Use numpy for risk period returns.
Following the lead of the RiskMetricsBatch conversion to use
more pandas and numpy.
Bringing the iterative and batch versions closer together as we
work towards folding them into one.
2013-03-29 17:06:54 -04:00
Eddie Hebert c6f8f430d7 DEV: Handles empty stash case in pre-commit hook.
Handles the case when reword is called and the `commit --amend` invokes
the pre-commit hook, when there is no stash the `git stash pop -q`
in that case leaves the rebase in an odd state.
Fixes by only calling the stash pop if changes were saved.
2013-03-29 17:06:37 -04:00
Eddie Hebert 147e806bb0 MAINT: Moves exchange to utc conversion inside of environment object.
So that the environments' exchange time is used without having to
specify it independently.

Also, moves uses of Delorean.shift for the exchange conversion inside
of environment to use the exchange_dt_to_utc method.
2013-03-28 12:29:52 -04:00
Eddie Hebert 10825c9a1d MAINT: Updates copyright year on finance module. 2013-03-28 09:24:53 -04:00
Eddie Hebert 7679e5a581 ENH: Wires minutely emission of data from performance tracker.
Wires up performance tracker so that when `emission_rate` is set
to `minute`, the performance packets are sent out every minute,
instead of once per day.

Please note, the performance packets that are generated are not
ready for prime time consumption, this patch is merely a step towards
hooking up the ability to inspect minute data.

Known issues:
- The packets do not currently include risk information.
  Since we need to consider how this affects the denominators
  of the risk calculations.
2013-03-27 16:58:56 -04:00
Wes McKinney 20d50450b6 ENH: use array and pandas operations to speed up risk computations 2013-03-27 13:42:46 -04:00
Eddie Hebert d87213a5f1 MAINT: Adds floating point tolerance to risk metric comparison tests.
In preparation of changing how risk metrics are calculated,
this makes the checking of results more tolerant to floating point
rounding, since upcoming changes change the results by a neglible margin.
2013-03-27 13:42:16 -04:00
Eddie Hebert 7dfa0d1980 REL: v0.5.8
- Fixes bug/confusion caused by pandoc conversion in setup.py
- Slight refactorings, removing missing methods, etc.
2013-03-27 13:04:24 -04:00
Eddie Hebert 09af6fb721 BUG: Avoids install errors caused by lack of pandoc binary.
The pyandoc module throws an OSError of:
"No such file or directory",
when the underlying pandoc binary does not exist.

This error has caused confusion for numerous people during pip
installation.

pandoc is only needed on upload to PyPI to convert to ReST.
So, instead of doing a try/except on the `import pandoc` for all cases,
now checking whether or not 'upload' was invoked when calling setup.py,
so that only maintainers have to worry about installation of pandoc.

By only exercising the pandoc logic when
2013-03-27 12:27:17 -04:00
Eddie Hebert 94e70a394b MAINT: Restricts dates to trading calendar in risk comparison test.
Converts the risk iterative and batch comparison tests to use
the trading environments next date, instead of just advancing by day,
so that the returns being passed into the RiskMetrics in the unit
test are using the same trading calendar as the internal checks for
trading days.

Fixes a case where empty return periods were being into
`calculate_period_returns`

Clearing the way for the pandas based optimization of the risk module.
2013-03-27 11:42:40 -04:00
Eddie Hebert 41d3c72627 MAINT: Removes unused currentValue method on Position object.
This method became unused when vectorizing position totals.
2013-03-26 22:33:19 -04:00
Eddie Hebert 736a4babf0 MAINT: Renames parameter to TradeSimulationClient.
Renames from environment -> sim_params to match the type of the
argument passed.

(A refactoring had changed it to SimulationParams.)
2013-03-26 17:09:48 -04:00
jbredeche 9f17ccab39 Merge pull request #114 from quantopian/filter_sources
adds an optional filter to the algorithm's date_sorted_sources
2013-03-26 13:53:47 -07:00
fawce 241a43bb13 ENH: Adds an optional filter to the algorithm's date_sorted_sources
So that a filter function can filter out sids on a 'static' source,
when the universe of sids changes.

e.g. when using fetch_csv with a changing universe of stocks.
2013-03-26 16:48:34 -04:00
fawce 09627c2809 adds an optional filter to the algorithm's date_sorted_sources 2013-03-26 14:54:33 -04:00
Eddie Hebert a05039c514 MAINT: Uses Transaction object in tests instead of ndict.
So that Transaction object behavior is exercised, uses the Transaction
object in performance module tests instead of ndict.

Also, adds fields to the __init__ of Transaction, to make the
definition of the object more well defined.
2013-03-25 23:51:34 -04:00
Eddie Hebert f2d618b466 MAINT: Moves create_trade out of gens.utils
Slight refactoring of moving create_trade so that it's alongside
other testing/mock data utilities, instead of part of the gens module.
2013-03-25 23:51:25 -04:00
Eddie Hebert 45e28a4b9d MAINT: Updates copyright year on gens.utils module. 2013-03-25 23:51:20 -04:00
Eddie Hebert 33a1ed305f MAINT: Removes alternate function from gens.utils
This function is no longer refrenced elsewhere in the codebase.
2013-03-25 23:51:12 -04:00
Eddie Hebert 5118789e9b MAINT: Removes unused mock data function from gens.utils
This function is unused, and on the general path of moving testing
functions out of gens.utils
 # Please enter the commit message for your changes. Lines starting
2013-03-25 23:50:59 -04:00
Eddie Hebert 47f3192728 MAINT: Updates copyright year of perf_tracking tests. 2013-03-25 23:50:23 -04:00
Eddie Hebert 6f1cbcbc4f MAINT: Moves internal state variables in performance tracker.
Slight refactoring of grouping the tracking variables in the
PerformanceTracker together.

So that it's easier to see which are config members and which are
members used to track internal state.
2013-03-25 12:44:45 -04:00
Eddie Hebert 19a1279385 REL: v0.5.7
Highlights, with thanks to contributors inline:

- Runtime performance improvements
- Fixed the omission of peformance messages on days with no trades
- Changes to batch_transform implementation
-- supports sid filtering
-- performance improvements using pandas
-- added an option for only computating when there is a window length's
   worth of data
- Added new risk metrics
-- Sortino
-- information ration
  (Ryan Day, ryanday2@gmail.com @rday)
- Added stop and limit orders
  (Tony Worm, verdverm@gmail.com @verdverm)
- Added variable recording
- Deprecated market_aware and delta kwargs to EventWindow
- Fixes to trading calendars for missing holidays
- Added TradingEnviorment context manager
- Added support for streaming through dividends
- Yahoo source now has OHLC
- Updates downloaded benchmark and treasury data when new data is available.
  (Ryan Day, ryanday2@gmail.com @rday)
- Added optional adjustment of Yahoo data
  (Jeremiah Lowin, jlowin@lowindata.com @jlowin)
2013-03-25 12:44:45 -04:00
Richard Frank eb6b7c08fc MAINT: Using zone attribute of tzinfo instead of string 2013-03-25 11:52:29 -04:00
Richard Frank fdf38d3562 BUG: Moved asserts back to before calculations that rely on them.
This means we get a failed assert immediately, instead of an
OverflowError later.
2013-03-25 11:52:29 -04:00
Eddie Hebert 2504874a84 DEV: Updates README with numpy installation tip.
Adds `pip install numpy` to the installation notes,
since `pip install zipline` will not work out of the box
if numpy is not installed beforehand.
2013-03-22 13:54:10 -04:00
fawce 5b59bf3453 Merge branch 'master' of github.com:quantopian/zipline 2013-03-21 15:14:48 -04:00
fawce 0e0fecf4ee allows config to force no datasources by passing a None.
absence of the parameter triggers the default.
2013-03-21 15:13:56 -04:00