Commit Graph
107 Commits
Author SHA1 Message Date
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 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
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 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 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 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
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
Richard FrankandEddie Hebert ebdb5429aa MAINT: Moved DailyReturn to protocol module to break circular references
and removed code that solved that same problem with conditional imports.
2013-03-01 16:05:39 -05:00
Richard Frank 7696abb169 MAINT: Removed unused prior_day_open from SimulationParameters 2013-03-01 13:21:28 -05:00
fawce 5587c1bc64 added functools.wraps as per @richafrank 2013-02-19 13:15:57 -05:00
fawce 9cc043f130 added a decorator for applying an environment to a function context. 2013-02-19 12:52:17 -05:00
fawceandEddie Hebert a4a4d38a73 TradingEnvironment allows the specification of a benchmark index and a local timezone for the exchange. This commit adds tests to verify the TradingEnvironment properly handles London Stock Exchange index, FTSE.
- added LSE reference rrules calendar (thanks to Edward Johns)
    - added tests to verify LSE environment matches rrule calendar
    - added a test to verify global environment behavior can be set.
    - moved DailyReturn class to trading to eliminate circularity from
    risk <-> trading.
    - updated TradingEnvironment to be a context manager. This allows users
    to run algorithms in individually isolated environments in one python
    process. This is useful for managing multiple algorithms in a single
    ipython notebook.
    - added comments to explain behavior and useage of the global environment
2013-02-18 10:24:32 -05:00
fawceandEddie Hebert 2c7355a0dc Refactoring of TradingEnvironment to isolate the global state: index symbol and exchange timezone. Parameters that define the simulation (start, end, and capital base) were put in a new class, SimulationParameters.
Global state for the financial simulation environment is accessed through the
zipline.finance.trading module, which now contains a module variable:
environment.

Parameters are passed into an algorithm as a keyword argument, sim_params.
SimulationParameters creates a trading day index for the test period that
can be used to find trading days, calculate distance between trading days,
and other common operations. The sim params index is just selected from the
global state.

================

Details:

    - adding delorean to the requirements.
    - made index symbol a parameter for loading the benchmark data. changed
    messagepack storage to be symbol specific.
    - ported risk, performance, algorithm, transforms, batch transforms
    and associated tests to use simulation parameters and global environment
    - factory and sim factory use global state and sim params
    - factory method parameter names now reflect the class expected
2013-02-18 10:24:32 -05:00
Eddie Hebert 5b294faf0c Removes unused method. 2013-01-28 23:22:04 -05:00
Eddie Hebert a25590b0a1 Exposes the list of trading days contained in a trading environment.
Previously, the list was generated, but only used to calculate
the number of days in the environment.

With exposing this list, working towards a path where the simulation
uses the trading days to determine when to handle market closes.
2013-01-01 13:01:49 -05:00
Eddie Hebert a8413e1cc2 Adds reprs for PerformanceTracker and TradingEnvironment.
For debugging in the REPL.
2012-12-27 18:26:55 -05:00
Richard Frank e7b504f4ca Removed list of trading days since we already have an OrderedDict 2012-12-12 15:23:26 -05:00
Richard FrankandEddie Hebert 4981c67c31 Handle missing historical data more elegantly
Updated the search for treasury data when there is none for the
test end date.
It could be that the end date is not a trading day, or we could
just be missing treasury data. In either case, we try to recover
more gracefully now, by searching as far as possible and maybe
logging a warning.

Similarly, if there is no benchmark data for the test end date,
look for the next trading day. If we really have no data,
blow up with our own explicit exception, instead of overflowing
in our search for dates in the future.
2012-12-10 13:03:25 -05:00
Richard Frank 4d41070585 Fix for slippage time getting out of sync with algo.
Moved grouping by date earlier in the pipeline of generators,
prior to any date-dependent state getting involved.  Grouping
pulls from the pipeline until the start of the next group,
which is in the next day.  The effect of grouping after
slippage but before handle_data is that slippage and the algo
are out of sync by a transaction.
2012-11-27 13:38:50 -05:00
Eddie Hebert 0f819474e0 Normalizes indentation to 4 spaces. 2012-10-10 16:11:03 -04:00
fawceandEddie Hebert 16b0d71506 refactoring of algorithm to make it work for both batch style run method, and generator style consumption. removed the portfolio property from the data parameter. added set_slippage and set_commission methods to algorithm. removed timeout tracking. 2012-10-10 16:06:32 -04:00
Eddie Hebert bbf2317c57 Saving point for adding license files. 2012-10-08 17:32:40 -04:00
Eddie Hebert 77af1ca632 Applies PEP-8 and pyflakes style to tests and zipline.
Mostly whitespace, line width and other spacing changes.
Also, removes use of deprecated has_key in favor of `in`

Going forward new patches should pass running `flake8` before
submission.
2012-10-05 12:14:09 -04:00
fawce 7a8697f0e5 updated based on PR feedback. 2012-09-30 22:12:00 -04:00
fawce 1caefbff43 tests are passing for independent commission model 2012-09-28 23:12:41 -04:00
fawce 1267f66dbe removed old refs 2012-09-14 19:42:55 -04:00
fawce 57a1834c5a refactored so that slippage is implemented as pluggable classes. 2012-09-13 21:22:01 -04:00
scottsanderson 55ffa2b391 fix bug where trading environment enters infinite loop on invalid dates 2012-08-23 10:47:35 -04:00
scottsanderson 1f78a07d30 refactor tradesimulation client to not use StatefulTransform unnecessarily 2012-08-21 19:55:40 -04:00
scottsandersonandEddie Hebert 7ce3667bc2 hard coded one-day warmup 2012-08-14 17:03:49 -04:00
scottsanderson 74859751ff whitespace 2012-08-07 18:25:22 -04:00
fawce aeb50da170 fixes for unit tests, back to 50/51 passing. 2012-08-07 14:42:43 -04:00
scottsanderson 8437a28c14 generator-style perf now sends a risk report on receipt of DONE 2012-08-03 21:09:05 -04:00
scottsanderson ace5d05fab tradesim as generator v. 2.0 2012-08-03 14:07:05 -04:00
scottsanderson 14067d8323 commit for fawce 2012-08-01 21:42:55 -04:00
scottsanderson 4768bea646 more progress on tsc 2012-08-01 18:53:09 -04:00
scottsanderson 6cb3516b6b save for attempted merge 2012-08-01 11:12:09 -04:00
Stephen Diehl 7ffdff64a1 Remove other refs to stdlib logging. 2012-07-06 10:47:11 -04:00
fawce 7044040722 removed logging of zero volume orders. 2012-06-18 19:02:14 -04:00
fawce 069dbd1afe removed protocol cruft from transaction transform days. 2012-05-28 21:32:23 -04:00
Stephen Diehl 3ad1f250e6 Cleaned up OOP, first round. 2012-05-16 14:33:16 -04:00
Stephen Diehl d503ce465a Merge branch 'refactor'
Conflicts:
	zipline/finance/trading.py
	zipline/lines.py
2012-05-15 14:04:05 -04:00
fawce 3bb03e0f8c converting to handle_data nomenclature. 2012-05-14 16:49:05 -04:00
fawce de0cfd4072 fixed bugs in transform calculations. 2012-05-14 15:31:51 -04:00
Stephen Diehl e04415e63f Remove all namedicts. 2012-05-14 11:35:43 -04:00
Stephen Diehl 8b95aebcf2 Refactor lots of things. 2012-05-14 10:57:40 -04:00
Stephen Diehl 133d9c03af One test passing, progress! 2012-05-10 16:38:04 -04:00