My Python skills are pretty limited, so it's likely I am missing what's obvious, but I don't understand what the purpose of this library is. "Modeling financial instruments" is vague; is it for backtesting? Calculating option pay-offs? Tracking portfolio P&L? Risk management? Is there an example of what you would use it for?
I can see the Portfolio class, but it somewhat confusingly uses "Trades" to describe more complex positions (I had assumed a Trade was selling or buying an instrument), and the instruments included are fairly limited. I don't see any bonds, currencies, interest rates, swaps, and others but it looks like an early work in progress, so that's fine. Is it meant to be a generic toolkit to cover the vast majority of financial instruments? I don't understand how characteristics of the instruments are calculated/updated or aggregated into Portfolios.
Some sample code/projects would help me immensely in understanding! (Again, I blame my lack of Python skills).
Finstruments is an instrument definition library, meaning that you can build the specifications of an instrument. Currently, this library is primarily useful for serialization and deserialization to and from JSON, but it can also be used for backtesting, option payoffs, tracking portfolio P&L, risk management, API integration, and document storage.
Regarding the Portfolio class, I opted to distinguish trades from positions. This is useful for tracking and organizational purposes. For example, if you enter into a straddle, it's useful to combine the put and call into one "trade" instead of just a bunch of random positions.
This is a very early work-in-progress, so I would suggest checking back in over the coming weeks for additional instruments and usage details.
Thanks for sharing. Your library seems to be a bit more extensive, including not only definitions but also modeling. Might be useful as a reference point if I integrate other functionality such as pricing.
There is the Common Domain Model [1] that might be worth looking into. The accurate specification of the vast range of financial instruments is quite a challenge.
> The CDM is a model for financial products, trades in those products, and the lifecycle events of those trades. It is an open source standard that aligns data, systems and processes and is available as code in multiple languages for easy implementation across technologies.
Thanks for sharing. Unfortunately doesn't look to support Python natively, and it looks quite complex for my purposes of instrument definitions, but it seems useful as a reference point.
The scrolling animation / progress indicator thingy on your blog seems broken by the way. It quickly moves out of the visible view on a pretty normal setup (24" FHD screen, Linux, Firefox).
Financial data, as in a time series of prices? It really depends on your budget, desired overhead, and amount of data. Some funds store data in flat files (broken down by date, instrument, ticker, etc), others use time series databases, such as ClickHouse or Kdb+. Using flat files is probably the simplest and most cost effective while still enabling you to store a massive amount of data, but using a database obviously enables querying and analytics.
QuantLib is an bloated library built in C++ and ported over to Python. The design is unintuitive, lacks modularity, and employs a number of hacks, such as locks. My goal is to build an intuitive, simple, and modular alternative for users that care more about the coding experience.
My Python skills are pretty limited, so it's likely I am missing what's obvious, but I don't understand what the purpose of this library is. "Modeling financial instruments" is vague; is it for backtesting? Calculating option pay-offs? Tracking portfolio P&L? Risk management? Is there an example of what you would use it for?
I can see the Portfolio class, but it somewhat confusingly uses "Trades" to describe more complex positions (I had assumed a Trade was selling or buying an instrument), and the instruments included are fairly limited. I don't see any bonds, currencies, interest rates, swaps, and others but it looks like an early work in progress, so that's fine. Is it meant to be a generic toolkit to cover the vast majority of financial instruments? I don't understand how characteristics of the instruments are calculated/updated or aggregated into Portfolios.
Some sample code/projects would help me immensely in understanding! (Again, I blame my lack of Python skills).
My apologies for the basic questions!
Finstruments is an instrument definition library, meaning that you can build the specifications of an instrument. Currently, this library is primarily useful for serialization and deserialization to and from JSON, but it can also be used for backtesting, option payoffs, tracking portfolio P&L, risk management, API integration, and document storage.
Regarding the Portfolio class, I opted to distinguish trades from positions. This is useful for tracking and organizational purposes. For example, if you enter into a straddle, it's useful to combine the put and call into one "trade" instead of just a bunch of random positions.
This is a very early work-in-progress, so I would suggest checking back in over the coming weeks for additional instruments and usage details.
For those interested in this space, a couple of related libraries in Julia:
https://github.com/JuliaComputing/Miletus.jl
https://github.com/JuliaActuary/FinanceModels.jl
I’m the author of the second one, so am always interested to see discussions on financial modeling libraries.
Thanks for sharing. Your library seems to be a bit more extensive, including not only definitions but also modeling. Might be useful as a reference point if I integrate other functionality such as pricing.
There is the Common Domain Model [1] that might be worth looking into. The accurate specification of the vast range of financial instruments is quite a challenge.
> The CDM is a model for financial products, trades in those products, and the lifecycle events of those trades. It is an open source standard that aligns data, systems and processes and is available as code in multiple languages for easy implementation across technologies.
[1] https://github.com/finos/common-domain-model
Thanks for sharing. Unfortunately doesn't look to support Python natively, and it looks quite complex for my purposes of instrument definitions, but it seems useful as a reference point.
Finstruments introductory article: https://kyleloomis.com/articles/financial-instrument-library
The scrolling animation / progress indicator thingy on your blog seems broken by the way. It quickly moves out of the visible view on a pretty normal setup (24" FHD screen, Linux, Firefox).
Thanks for the note! I removed this for now... will fix later.
I'd have to use it first to comment on it, but thanks so far. Article makes a good impression.
Let me know your thoughts and how it could be improved.
Do you have any recommendations on how to store financial data?
Financial data, as in a time series of prices? It really depends on your budget, desired overhead, and amount of data. Some funds store data in flat files (broken down by date, instrument, ticker, etc), others use time series databases, such as ClickHouse or Kdb+. Using flat files is probably the simplest and most cost effective while still enabling you to store a massive amount of data, but using a database obviously enables querying and analytics.
Thanks
The reference in this domain is Quantlib. I don't understand how this library adds value
QuantLib is an bloated library built in C++ and ported over to Python. The design is unintuitive, lacks modularity, and employs a number of hacks, such as locks. My goal is to build an intuitive, simple, and modular alternative for users that care more about the coding experience.
I imagine this will immediately be folded into some LLM daytrading app
Likely...
Do you have an example of a convertible bond?
Not yet, I will work to add this soon.
Will check it out.