Commit Graph

1625 Commits

Author SHA1 Message Date
Eddie Hebert 9ffaec64d8 MAINT: Factor out check for window length value sanity.
Preparing for BatchTransform not using EventWindow, so
factoring out the checks for window length into a
function that can be shared.
2013-04-29 14:56:04 -04:00
Eddie Hebert 38bd4214a2 MAINT: Remove unused TransformMessage class. 2013-04-29 14:55:38 -04:00
Eddie Hebert a4ea33218d TST: Move batch transform tests to their own file.
From @twiecki's rolling batch transform work.
2013-04-26 23:56:35 -04:00
fawce de37a08c23 MAINT: flake8 error 2013-04-26 19:57:45 -04:00
fawce 9a66614ff2 Merge pull request #146 from quantopian/orders_m1d
Orders m1d
2013-04-26 16:55:28 -07:00
fawce f3cfc9623d ENH: new order management methods:
- get_open_orders
- get_order
- cancel
2013-04-26 19:46:00 -04:00
fawce afef4ea34c ENH: added cancel function
- removed vestigial methods
- removed code that drops filled orders from memory
2013-04-26 19:46:00 -04:00
fawce 9062b9636a MAINT: refactoring for orders api
- moved Order and Blotter to zipline.finance.blotter
- moved order method from AlgoSimulator to Blotter
- eliminated the set_order method in algorithm
- moved blotter to the algorithm
2013-04-26 19:45:59 -04:00
Eddie Hebert b3efb5eb69 MAINT: Remove ndict class.
Now that ndict is no longer used in any part of the system during
a backtest, remove all remaining references in tests, etc.
2013-04-26 16:03:01 -04:00
Eddie Hebert 89ea97ec52 MAINT: Use a distinct object for minute/day data instead of ndict.
Continue removing ndict usage, instead use a BarData object.
2013-04-26 15:26:01 -04:00
Eddie Hebert d4a8878c6e TST: Ensure holiday edge case is covered in dividend performance test.
Add a test suite of dividend performance that ensures a holiday
is covered, needed because tests usually go over a random test range,
so holiday coverage isn't covered in basic test.

From @fawce.
2013-04-26 10:56:54 -04:00
fawce 24dfcaffc8 MAINT: Remove TradeSimulationClient class layer.
In favor of directly using the AlgorithmSimulator class.
2013-04-25 18:03:44 -04:00
Eddie Hebert 6cf8db458d ENH: Emit minute benchmarks, refactor event loop, fix order timing.
Note, in a somewhat Catch-22 situation, the refactoring of
the simulation loop and streaming of minutely benchmarks enable
each other, since the benchmarks fall over because of doubled
date groupings, which is fixed by the change of the simulation loop,
but the simulation loop depends on using the benchmarks as a clock,
so pull the two changes in together, though the two changes do not
work independently of each other.
2013-04-25 17:18:58 -04:00
fawce 427ea8d4ca ENH: Change simulation loop to use benchmarks as simulation 'clock'.
Refactor PerformanceTracker, Blotter, and AlgorithmSimulator to
work with handling the end of a bar at the AlgorithmSimulator level
instead of within PerformanceTracker.

- PerforamnceTracker and Blotter are longer generators,
  both provide functions to process events instead.
- AlgorithmSimulator calls each from within the loop running
  over the data generator.
- Change test_perf_tracker utility to be compatible with change
  away from PerformanceTracker as a generator.

Has the effect of:
- Fixing the timing of order emission.
- Allow minutely emission of benchmarks, which was prevented
  by the extra grouping previously caused by Blotter.

Minutely emission also depends on work for streaming benchmarks
through performance and risk at a minute granularity.
2013-04-25 17:16:35 -04:00
Eddie Hebert d31303b86c ENH: Add basis for minute rate emission of performance.
- Create different benchmark containers in performance
  depending on emission rate.
- Add a minute close method which updates algorithm and
  benchmark returns, and calculates the risk metrics
  depending on those methods.
- Provide fake 0.0 values for annualized metrics like
  sharpe, sortino, and information, until we figure out
  how they should be treated in the context of minutely
  calculation.

*NOTE* This does not fully work without the changes to the
simulation loop by @fawce
2013-04-25 16:49:38 -04:00
Eddie Hebert 7d615c5af5 MAINT: Improve message for return mismatch by including current dt.
Based on work from @fawce's simulation loop work.
2013-04-25 16:48:19 -04:00
Eddie Hebert 2cc6764b90 TST: Factor out the running events through a test performance tracker.
Based on @fawce's work for changing the simulate loop.
2013-04-25 16:33:01 -04:00
Eddie Hebert d0651706ac TST: Prevent dividend test from using non-trading day.
Use the next events' datetime for the transaction instead of
incrementing by a calendar day.
2013-04-25 15:41:26 -04:00
Eddie Hebert fd6c71286d MAINT: Use sim_params for risk metrics init.
Prepare for adding emission_rate in risk metrics logic.
2013-04-25 15:30:34 -04:00
Eddie Hebert d067f13ba8 MAINT: Use a fake progress value for minute performance.
Eventually should to either return None or remove
progress completely, but in the meantime, return a
constant of 1.0 for progress of minute emissions.

Also, factor out the daily calculation into a property
instead of calculating during process.
2013-04-25 14:28:33 -04:00
Eddie Hebert 4b33d6ea4b TST: Ensure that create_trade_history uses midnight for daily trades.
Prepare for implementation of backtest loop that depends on daily
trades being grouped by midnight.
2013-04-25 13:25:50 -04:00
Eddie Hebert 2b0a91e568 BUG: Fix examples with regards to simulation parameters.
Fix bug where algorithms that lack sim_params do not pass the source
derived created sim_params through the generator creation logic.
2013-04-25 12:57:56 -04:00
Eddie Hebert fed0a9a998 TST: Ensure that test bars and events use midnight for daily data.
Daily data should be using midnight as the timestamp,
ensure that test data created by data_gen use midnight, so that
upcoming implementations that rely on the timestamp will be compatible.
2013-04-25 11:30:57 -04:00
Eddie Hebert c6cbc9f8e2 TST: Explicitly define the data frequency of record incr test. 2013-04-25 01:12:58 -04:00
Eddie Hebert 1183c44fad MAINT: Remove unused last_dt member from risk.RiskMetricsIterative 2013-04-25 00:28:35 -04:00
Eddie Hebert ab1a23526d BUG: Use last trading day for last successful date message.
market_open member does not exist on TradingEnvironment.
2013-04-24 16:17:31 -04:00
Eddie Hebert 8937ac1f41 MAINT: Generate perfomance message only once per bar for minute mode.
Instead of creating a set of perf messages for each event during minute
emission mode, only include the messages on the last event in the bar.

Should cut down on calculations/serialization as well, as work towards
doing more 'end of bar' logic for minute benchmarks.
2013-04-22 17:37:32 -04:00
fawce 3811df78b9 BUG: Fix grouping of events streamed through blotter.
To fix the grouping of events so that (dt, events) ordering
is preserved, the tracking of order states needs to change
in the following way.

Change how order keeps track of dates:
- Change order's dt field to reflect modified date.
- Add a created field.

Change how performance keeps track of orders by:
- Map dt to transactions
- Map dt to orders
- Map order ids to keep track of updated orders.
2013-04-22 16:46:28 -04:00
Eddie Hebert a1e3222456 STY: Tweak whitespace in comment. 2013-04-22 15:56:03 -04:00
Eddie Hebert 32d57ef955 STY: Add space after comma in order docstring. 2013-04-22 15:33:13 -04:00
Eddie Hebert 097c225c6b BUG: Fix treasury loading.
Make adjustments for using Python built-in ElementTree instead of lxml
based lxml.

lxml was edited out during pulling in of memory friendly loading of
treasury curves, however some of the use of ETree was lxml specific.

Mea culpa.
2013-04-22 14:03:25 -04:00
Richard Frank 4ba35d7d46 ENH: Stream benchmark and treasury data when downloading
Instead of loading entire csv or xml into memory.
2013-04-22 12:35:17 -04:00
fawce ca0bce1680 TST: Refactor so tests can exercise internal methods in blotter. 2013-04-18 16:09:24 -04:00
fawce bc95c3a62e BUG: Fix emission of order updates.
The emission of order updates from the blotter were incorrect,
and subsequently, performance.

Previously, only the first action of the order was emitted,
fix so that all status updates are emitted.
2013-04-18 16:08:44 -04:00
Ben McCann fc4d563a02 DOC: Fix documentation compilation 2013-04-17 11:15:38 -04:00
Eddie Hebert bf1fc42acc BUG: Fix time spent checking equality of floating point numbers.
The use of np.allclose introduced a severe performance penalty,
caused by the creation of two `np.array`s for each check.

Instead create and use a similar check which maintains tolerance
to floating point rounding, but operates only on scalars.
2013-04-16 13:09:26 -04:00
Eddie Hebert 9f0500aa33 TST: Use 9:31 AM EST for first minute of minute performance tests. 2013-04-16 12:23:09 -04:00
Eddie Hebert e7d64fa2e5 STY: Move import in test to top of file. 2013-04-16 12:23:06 -04:00
Eddie Hebert 5a73ec7de3 TST: Prevent random integer during unit test from exceeding bounds. 2013-04-16 10:49:17 -04:00
Eddie Hebert 643d556482 MAINT: Add empty values for risk metric calculated components.
eigen vales, covariance, etc. are not calculated until the first
return is passed through, so initialize this values to None, so that
`repr` and its ilk work on a freshly created `RiskMetricsIterative`
object.
2013-04-16 10:45:11 -04:00
Richard Frank e8f6b43f2b TST: When comparing dicts, ensure they have the same keys.
dict 'b' might have more keys.
2013-04-15 16:57:44 -04:00
Richard Frank d487401989 BUG: Perf tracker should emit perf messages only for TRADE events 2013-04-15 16:57:33 -04:00
Eddie Hebert 4ff49749d7 BUG: Fix environment minute date range start and volume.
The bar timestamps for day start and finish, for NYSE traded stocks,
should be 9:31 AM EST to 4:00 PM EST, for a total of 390 minutes.

Fix starting at 9:30 AM and the creation of 391 bars.
2013-04-15 16:35:41 -04:00
Eddie Hebert 9099d301f3 ENH: Stream benchmark returns as events.
Instead of creating a list of benchmarks in the risk module,
stream benchmarks through the system as events, starting from the
algorithm generator.

Works towards more easily setting arbritrary pricing data as
a a benchmark, as well as working towards live minutely benchmarks.
2013-04-15 11:43:13 -04:00
Eddie Hebert 6210467bec MAINT: Use pd.Series for benchmarks and algorithm returns in risk.
Instead of lists, use pd.Series, so that memory is preallocated.
2013-04-15 11:37:21 -04:00
Richard Frank 2dbafd5162 BUG: Zero out the microsecond attribute of datetimes
wherever we zero out the second attribute.  Otherwise, we can be
off by some microseconds from midnight, etc.
2013-04-15 10:44:44 -04:00
Eddie Hebert cc322af498 TST: Removes unused members in set up from TestPerformanceTracker. 2013-04-15 10:31:19 -04:00
Eddie Hebert 35f57ada3e ENH: Send transactions and orders as standalone events.
- Add transaction and order types
- Move TransactionSimulator from trading.py to tradesimulation.py
  (only used by other members of the tradesimulation module)
- Make Transaction an independent event, like dividend
- Add Blotter class.
- Flatten the transaction events to be independent of trade bar events
- Make orders into events that reach performance (need to add
handling)
- Issue IDs to orders and tracking each transaction's order id.
- Make volume share slippage fill orders independently, rather than
  aggregating them into a single transaction.
- Perf tracker holds orders, serializes them with transactions.
- Order state defined and maintained by order class.
- Minutely emission of orders based on last_modified date.
2013-04-14 18:59:57 -04:00
Eddie Hebert cfbbbe2f1c TEST: Ensure that test_transforms's algos are passed sim_params. 2013-04-12 12:54:11 -04:00
Eddie Hebert 48a691e9a7 TST: Group test trades for transaction simulator by date.
Group by date to prepare for other values to be added per dt.
2013-04-12 11:13:23 -04:00