Commit Graph
38 Commits
Author SHA1 Message Date
fawceandEddie Hebert 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
fawceandEddie Hebert ca0bce1680 TST: Refactor so tests can exercise internal methods in blotter. 2013-04-18 16:09:24 -04:00
fawceandEddie Hebert 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
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 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 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
Tony WormandEddie Hebert 086679c3d6 ENH: Adds new order types.
Adds the following order types:
- market
- limit
- stop
- stop limit
2013-03-19 14:32:11 -04:00
Eddie Hebert ea11a43f68 MAINT: Removes unneeded assignment in slippage.
`direction` is set on each iteration of the loop,
making the initial assignment unneeded.
2013-03-12 20:37:36 -04:00
Eddie Hebert 43fac333a1 BUG: Fixes check reversal in slippage transact_stub.
Previous commit accidentally flipped the check when converting
to use `allclose`.
2013-03-12 20:34:16 -04:00
Eddie Hebert 2bf285b084 MAINT: More slippage comparison changes for floating point.
Continues conversion of floating point comparisons in slippage to
use numpy's allclose.
2013-03-12 20:28:47 -04:00
Eddie Hebert 27761f9dec MAINT: Uses copysign to extract order direction in FixedSlippage.
Uses copysign instead of division by fabs.
2013-03-12 19:47:01 -04:00
Eddie Hebert 080c54d4dc MAINT: Accounts for possible floating point rounding in slippage.
Uses numpy's allclose instead of straight comparison of floating
points, so that there is some tolerance of floating point rounding.
2013-03-12 19:40:24 -04:00
Eddie Hebert 39cfdaa7c9 MAINT: Updates copyright date of slippage module. 2013-03-12 19:18:52 -04:00
Eddie Hebert f7b4df4a09 MAINT: Uses copysign to extract direction of order.
Instead of using division of the amount by itself to extract
the direction, uses math's copysign.

Should be almost functionally equivalent,
but copysign won't have a possible floating point error leading
the direction to not be exactly 1.
2013-03-12 19:14:02 -04:00
Eddie Hebert d5a0446f7b Moves slippage transactions off of ndict.
So that the datatype is unique.
2013-01-22 20:55:24 -05:00
Richard Frank 1b2f6739e9 Fixed floating-point error in volume share slippage model 2012-11-29 12:13:35 -05:00
Richard Frank c81d6a30d1 Fix to inject log dates from slippage methods. 2012-11-27 12:41:07 -05:00
Eddie Hebert 0617e53d69 Upgrades flake8 from 1.5 -> 1.6
Also, removes flake8 ignores, since the warnings that were
at odds with eachother now work.
2012-11-19 12:49:09 -05:00
Eddie Hebert 7904773d00 Updates flake8 to latest.
The latest flake8 release in now 1.5, which pulls in pep8: 1.3.4a0

The upgrade pep8 has changes to what it picks up as lint.
Making code base compatible, so that new devs can install pep8
from PyPI and not have friction over the version difference.

Currently using these ignores in the config file:

```
[pep8]
ignore = E124,E125,E126
```

Ignoring these since they are difficult to squash while maintaining
an 80 char line length, and appear spurious.
Should address later.

Updates Travis config, README, and pip requirements to reflect change.
2012-10-22 11:57:16 -04:00
Eddie Hebert 95ce2d90cf Removes unused constant and redirection of imports.
Removes TRANSFORM_TYPE from protocol, since it is unused.

Also, removes use of ndict as a member of protocol, since it's
import there was for the TRANSFORM_TYPE. Changed to
utils.protocol_utils instead.
2012-10-15 22:57:06 -04:00
Eddie Hebert 23076ae7f1 Allows for collapsed orders by changing the current order filter.
Changes our filter so that instead of just checking for the current
day, we ensure that orders are before or on the current event time.

This adds a delay, (defaulting to one minute), to the order so that we
avoid filling an order exactly when it is placed.
2012-10-11 13:42:53 -04:00
Eddie Hebert 5e87e174f0 Changes name of filled order variable.
So that we don't replace the orders variable with the list comp.

No functional change, but easier to compare the original and the
results of the list comp when debugging.
2012-10-10 16:19:07 -04:00
Eddie Hebert 9fef466323 Uses min function in place of taking the minimum with an if statement. 2012-10-10 16:19:06 -04:00
Eddie Hebert 69a4e542ea Filters out orders in the future.
Enforcing filling open orders that exist on or before the current event.
2012-10-10 16:19:06 -04:00
Eddie Hebert a220bc4e8f Removes expiration from orders.
Expiration is something that way may want to have in the future,
but this current is implementation is dropping orders that
aren't meant to be expired. So removing expiration, so that all
expected orders are executed.
2012-10-10 16:18:46 -04:00
Eddie Hebert 29a87ef7a2 Normalizes indentation before editing. 2012-10-10 16:11:27 -04:00
Eddie Hebert 98f063464e Adds extra constraint of year to check for day inequality.
The .day member of datetime only gives the number of the day of the
year, which is insufficient when checking for < than.

However in this use, we may just want to check for an 'not equals'
2012-10-10 16:11:16 -04:00
Eddie Hebert ca78b1b9e1 Makes ordering of transaction parameters consistent.
The order of open_orders and event were inconsistent across
invocations. Standardizing on one order.
2012-10-10 16:10:52 -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 9f8fd52b7d fixed bug where commission ignored order direction 2012-10-01 21:46:48 -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 e6b3e8e7b1 adding independent commission modeling. 2012-09-28 23:02:29 -04:00
fawce 518d471a93 fixed slippage was ignoring order direction. 2012-09-17 15:31:59 -04:00
fawce 0bb0df525a pluggable slippage. 2012-09-14 12:33:10 -04:00
fawce 57a1834c5a refactored so that slippage is implemented as pluggable classes. 2012-09-13 21:22:01 -04:00