Commit Graph
1079 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
Richard Frank 5a7702c22d MAINT: Factored out _create_data_generator helper method 2013-04-03 16:04: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 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 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 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 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 McKinneyandEddie Hebert 20d50450b6 ENH: use array and pandas operations to speed up risk computations 2013-03-27 13:42:46 -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
fawceandEddie Hebert 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
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 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
Richard FrankandEddie Hebert eb6b7c08fc MAINT: Using zone attribute of tzinfo instead of string 2013-03-25 11:52:29 -04:00
Richard FrankandEddie Hebert 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
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
Eddie Hebert 832c93134f MAINT: Removes comment referreing to removed started_at member. 2013-03-20 22:18:30 -04:00
Eddie Hebert 279e125ab8 MAINT: Pull initialization of simulation dt out of event loop.
Fakes a 'peek' into the data stream, so that the 'do we have a
simulation_dt?' check isn't called on each leoop iteration.
2013-03-20 14:34:12 -04:00
Eddie Hebert 08882bc8aa MAINT: Updates copyright on risk module. 2013-03-20 14:30:11 -04:00
Eddie Hebert 5dc449ba19 MAINT: Changes boolean check for snapshot existence in performance.
Small tweak to check for existence of elements using built-in
boolean of lists, instead of checking for `len`.
2013-03-20 13:19:39 -04:00
Eddie Hebert 75049fdd15 MAINT: Removes unused started_at member from performance tracker. 2013-03-20 13:05:38 -04:00
Eddie Hebert 3707c7b225 MAINT: Changes name of grouping of by dt in generator chain.
Changes name to `grouped_by_dt` instead of `grouped_by_date` to
clarify that the grouping is by dt, which can be by minute, instead
of grouping by calendar date.
2013-03-20 12:12:33 -04:00
Eddie Hebert 95a9b7b3c2 MAINT: Updates docstring for performance tracker class. 2013-03-20 11:27:57 -04:00
Eddie Hebert 8bf4c60169 MAINT: Removes unused member from performance tracker class.
`last_dict` is not referenced elsewhere.
2013-03-20 10:46:59 -04:00
fawce 93e22aa8b7 added more acceptable number types for event fields in batch
transforms.
2013-03-20 02:21:44 -04:00
Eddie Hebert 0169251c89 MAINT: Removes unused init method from algorithm.
The init method had been copied to method called initialize,
to avoid confusion with __init__
2013-03-19 22:59:38 -04:00
Eddie Hebert d2bdfc931d BUG: Fixes error added while rearticulating sim_params.
Previous attempt to make sim_parms logic clearer had clobbered the
override logic when sim_params is passed to the run function.

Added a few comments as well as restructuring how the sim_params
that are passed to run overrides the default values or not.

This also makes the passing of sim_params to run to no longer have
the side-effect of overwriting the default sim_params.
2013-03-19 22:46:04 -04:00
Eddie Hebert ccef17dec6 MAINT: Fixes comment about perf type. 2013-03-19 21:35:01 -04:00
Eddie Hebert a645b2a86e MAINT: Fixes comment about returned performance types.
The simulator had been changed to return dictionary objects instead
of ndicts.
2013-03-19 20:56:56 -04:00
Eddie Hebert 50e0334b3d STY: Uses if/else for setting sim_params in algorithm.
Instead of checking 'if' and then 'if not', uses an if/else.
2013-03-19 20:53:44 -04:00
Eddie Hebert 1909a0576f MAINT: Removes unused frame_count member from algorithm class.
frame_count is only over incremented, but never read or otherwise
used.
2013-03-19 20:36:53 -04:00
Eddie Hebert 0b6e4650d9 MAINT: Removes unused flag from algorithm class.
The `self.done` member of TradingAlgorithm is never used.
2013-03-19 19:50:40 -04:00