Replies: 3 comments 3 replies
-
Some random thoughts from someone who hasn't been intimately involved in Zipline's development (so I can't really give any historical context to the underlying Zipline constraints) but as someone who has shoe-horned an existing environment to operate with Zipline.... Just looking at the scehma for futures - it appears there was never really a "2 character root_symbol" limitation - I guess that was some sort of hard-coded convention somewhere along the way, probably by a US-centric person who hadn't considered much outside of USA (where only 2 letters are used). Some additional mechanism to replace the hardcoded slippage values would probably be helpful as these can certainly change over time. SQLite is a good choice because of its lightweight nature and its ubiquitous nature Since it's only used for the security data (and the vast bulk of the data - pricing) it's not really a bottleneck, and requiring postgresql would be an overkill for most people. Some additional metadata fields would be helpful.. even a free-form json-type approach adopted by many NoSQL databases could provide an extensible - perhaps even a .json file on disk.... On the futures side there have been variations in tick size over the years, sometimes mid-contract, so that's a consideration. Also, margins can and do vary over time. We don't expose any of the historical margin rates (we don't have a complete set, and the exact dates they change are difficult to determine). It's probably not much of an issue, other than producing a nice equity graph. In my experience, experienced futures trades want to know their per-contract-traded trading stats, not "how much money can I make with a starting balance of X", which is obviously predicated by margin values. Dates as integers are OK as long as you can show the entire range of values applicable. I believe integer was chosen simply because it's a small-in-RAM structure (32 bit), but I believe SQLite will expand it to 64 bit as required for overflow. Perhaps more interesting is how smaller non-daily time periods are handled (with, or without timezone data). Time format conversion does take a reasonable amount of CPU, so choice is important here. Volume truncation is only evident in securities that have significant amounts of reverse splits. For the most part, using a float gives "good enough" accuracy (6-7 significant figures) but could of course be extended (e.g. a double precision floating point) further at the cost of RAM, reduction in effectiveness of CPU cache, and of course storage. The same issues exist for pricing data too. Regarding database/schema upgrades - Zipline has been doing this for a while now (Zipline 1.0 was different to 1.3 etc.) - I don't think there's any need for databases to have any sort of backward compatibility/downgrade capability. Cheers, |
Beta Was this translation helpful? Give feedback.
-
@RichardDale , Thanks for your feedback. postgresql is indeed an overkill for a majority of users and adds complexity on top, but I believe that it could bring zipline to another level. Maybe we should see if dropping some of these types limitations or at least making them easily configurable for the user makes more sense. FYI zipline already does have the capability via sqlalchemy to do databases migrations, I am just not sure how useful it is for anyone to keep and test these old versions. |
Beta Was this translation helpful? Give feedback.
-
Looks like there is already an implementation of postgres for zipline within zipline-trader: https://zipline-trader.readthedocs.io/en/latest/database-backend.html. As an aside i did extract the live trading portion of zipline-trader into a separate module to work with zipline-reloaded, if people are interested. |
Beta Was this translation helpful? Give feedback.
-
DataPortal
in zipline would be quite amenable to a conversion topydanticattrs models and would even make some of the code less verbose (validators, settings, ...). attrs is great simplifies the code in many places (slots, validators, etc)Beta Was this translation helpful? Give feedback.
All reactions