Zipline: Refactor Futures base class to Derivative

Created on 28 Jul 2016  路  2Comments  路  Source: quantopian/zipline

Securities were refactored to Assets in this PR on the following reasoning:

This change is so the terminology is consistent and correct when Asset is extended to asset types that are not securities, such as futures.

While this is not incorrect, it is also not accurate. Futures is a derivative, whose value is based on the price of an underlying asset.
from (wikipedia)

Because it is a function of an underlying asset, a futures contract is a derivative product.

The same goes for forwards, options, swaps, and warrants.

While the rather nuanced term "asset classes" separates equity and bond instruments (where the equity futures could be considered assets), the cdef class Asset represents something that holds value. A Future object has no intrinsic value, but is a contract on the underlying Asset.

Refactoring and separating Assets and Derivatives clarifies the distinction for further developers who wish to add new classes.

API Design Assets Futures Refactoring

Most helpful comment

Separating Assets and Derivatives seems sensible, and we could also go a step further: making them both subclasses of a base class Contract or Instrument.

There's an interesting article on representing financial contracts in code here (note however that they do not combine Stocks and Bonds into a single Asset class, but this seems like a potential option.)

Given the pervasive use of the word "asset" in the codebase, we could perhaps delay this refactor until the introduction of other derivative products.

All 2 comments

Separating Assets and Derivatives seems sensible, and we could also go a step further: making them both subclasses of a base class Contract or Instrument.

There's an interesting article on representing financial contracts in code here (note however that they do not combine Stocks and Bonds into a single Asset class, but this seems like a potential option.)

Given the pervasive use of the word "asset" in the codebase, we could perhaps delay this refactor until the introduction of other derivative products.

I am writing a new bundle for BitMEX, the cryptocurrency derivative exchange, which features a high fluidity Bitcoin swap contract.

https://github.com/nerdDan/zipline-bitmex

But I am not sure if I should define the swap contract as Equity or Future since there's no Swap yet in Zipline.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ikfdarba picture ikfdarba  路  4Comments

mosfiqur-rahman picture mosfiqur-rahman  路  4Comments

freddiev4 picture freddiev4  路  3Comments

Monsieurvishal picture Monsieurvishal  路  5Comments

sluo1989 picture sluo1989  路  8Comments