-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update: GeneralLedger et al #9
Comments
You should provide subclasses of assets and subclasses of liabilities. An option to buy a thing is an asset that is quite different from the asset that is ownership of that thing. A tax liability is distinct from others. |
Hi Jeffrey, Yes. Of course you are right 👍 An asset group would be an instance of a DebitGroup and an asset account would be an instance of a DebitAccount. Similarly, a liability group would be an instance of a CreditGroup and a liability account would be an instance of a CreditAccount. See the example I provided. "assets" is a DebitGroup, "cash" is a DebitAccount" under "assets", "liabilities" is a CreditGroup and "payable" is a CreditAccount under "liabilities". Initially, I hard coded "Assets" and "Liabilities". The most common breakdown is "Assets", "Liabilities", "Revenue", "Expenses" and "Equity", but this is in no way universal, e.g. France is quite different. This design is flexible enough to handle any breakdown based on double-entry accounting. A general ledger is structured like a tree where you only post entries to the leaves. |
PS: I think it will help a lot to see an example of how a "GeneralLedger" can be used to build up "FinancialStatements" such as a "BalanceSheet" and "IncomeStatement". That is on the TODO list 😅 |
@EricForgy - quite a set of commits over the last 24 hours! Nice work. I will spend some more time with this and give this more thought, especially the overall structure. Before I forget, I wanted to jot down a few notes about the Ledger in particular:
|
On the general structure:
|
Wow! Thanks for the quick review and feedback 🙌😃
Yes. Not only that, since you also work in insurance, you might appreciate that I'd like to be able to look at the balance sheet under different bases. An insurer has at least three different balance sheets:
These three balance sheets often have sensitivities in opposing directions, which makes risk management for an insurer fun / challenging 😊 One example is Korea. The regulator in Korea restricts the liability duration, so no matter what is the economic duration, it will have a shorter statutory duration. This leads to situations where you need to balance being duration matched under a statutory basis with being duration matched under an economic basis. You can't have both. That is not even considering the various accounting bases, e.g. hold to maturity, available for sale, etc 😊 I didn't get much into my motivation, but my goal is to be able to support / simulate large multi-national, multi-currency corporations (likely insurers, but for these packages it shouldn't matter). I'd also like to look at one entity's balance sheet through the eyes of another jurisdiction, e.g. I'd like to look at a Malaysian insurer under Hong Kong's captial adequacy regime. Initially, I bounced back and forth between calling the type We can always consider name changes etc, but for the time being, a subledger could be thought of as an instance of BUT... maybe this design is flawed. Maybe an I value your opinion on this. Nothing is set in stone for sure. I just thought it would be good to have some working code to help the conversation along 😊 If, at the end of the day, everything I did so far is thrown out, that is fine as long as it is replaced with something better 😊
I agree 100%. I should clarify what I mean by
Yes. I agree 100%. All entries need to be stored. It is the right thing to do and required for audit purposes 😊
💯👍
Yes. Let's think about the right way to do this 👍 It is certainly a solvable problem. The way I've thought of it is we can have a "current" ledger with all balances just representing their "current" amount (not "current" as in "current assets" 😅) and the history available elsewhere in memory and persisted somewhere. The footprint for the transactions is pretty small, so I am not too concerned about memory. We should be able to handle billions without hassle. As always, open to suggestions. Another motivation, which is nonstandard, is that I want to be able to handle real-time reporting. When a policy is bought, its impact flows instantaneously to the balance sheet and shows up on a dashboard. That will be an important demo 😊 Real-time balance sheets pose interesting challenges. What do you do with depreciation? Depreciation is constantly changing. Do we need an entry every millisecond to update a depreciation account? The answer is "No" of course, so we need to think of ways to make this work and I have ideas. Happy to discuss 😊 |
Yes. Good point! You are correct of course. I didn't think of that 🤔 I might be inclined to consider
Good point! And good idea 👍🤔 I should sit down and read that paper one of these days 😅 But yeah, the concept seems similar. Making
Sure. Anything is on the table. This looks nice: https://github.com/JuliaGizmos/Observables.jl Maybe Markets.jl is just some sugar to construct some
Sure. Happy to consider this change. The argument makes sense. Maybe give me some time to think about it 👍
I haven't worked this out yet. It is still just a placeholder so we can think it through, but, yeah, that is the idea. |
PS: Thanks again for the quick feedback and suggestions. This is awesome 😊🙌 |
@alecloudenback, you brought up a lot of interesting points and suggestions. Thank you for that 👍 Countries and CurrenciesOne idea you floated was to change the totem pole and effectively subsume We should not make a decision based on that, but it brings up a good point. In some cases, we want to think of a Similarly, in some cases, we want to think of So I am still inclined to keep Entities and JurisdictionsYou also raised a good point about the order of I initially named I dropped the [Edit: Here is a good Wikipedia article - Legal Entity] Restucturing GeneralLedgersI agree with you. More thought is required here. I am definitely open to restructuring and happy to dispose of my first attempt if we can come up with something better. Your points helped me realize my design was flawed and thinking about how to fix it now. Thank you for your feedback 🙌 |
Hi, Thank you for stimulating the Finance domain in Julia, and for all the contributions you've made open. Disclaimer: I'm not an accountant, but I've worked with them. Reading the roadmap the ambitions are high - which is great. In terms of accounting I wonder if it might not be useful to first focus on a General Journal. I know journals have fallen out of favor in practice, but here maybe the can be useful. Specifically, with a GJ record/source of truth you could be quite aggressive in refactoring the accounts setup (GL), and replaying treatments. Also with a GJ as a source of truth you could migrate GJ versions/formats and have a complete record of past in the new format. Ack GJ size would be large (TB?) in some use cases, but we're at the point where that is not an obstacle/objection. Final a GJ is a much simpler beast to define. The effort then goes into creating import utilities, example creating a interface utility to generate a journal able to be imported in to xero, etc. etc. Ack this is speculation, but I'd appreciate any thoughts on gotha's I've overlooked, etc. |
Oh hi @taqtiqa-mark 👋 It's really great to hear some thoughts and feedback. You and I are in the same boat. I'm not an accountant either, but I work with them 😊 I do also feel that accounting should be at the core of a JuliaFinance "ecosystem". I think there may be a semantic issue though. What is the difference between a GJ and a GL? 😅 I've been working on GeneralLedgers.jl although I got distracted with some work on WebSockets.jl, Figures.jl and StochasticDiff.jl, but would like to come back to this soon. I think of the GL as the primordial record of truth and all financial reports can be derived from the GL. If you are saying that is also the case of GJ, I wonder if we are talking about the same thing? 😅
I agree 💯😊 This was my goal with GeneralLedgers.jl, i.e. to eventually be able to import / export to / from popular accounting packages 😊🙏 I suspect we are thinking the same thing, but I will look into it 👍 Thank you again for your comments and welcome to JuliaFinance 😊 Edit: Found these while googling |
I think of the GJ as a log file, nothing more, just rows of data. The idea would be that if we can get consensus and buy in, apps that trade would log their transactions using the JuliaFinance GJ conventions (JF-GJ) - the JF-GJ output would be little more than a pretty printer (KIS). If we used convention of configuration it should be possible to get a JF-GJ that can be quite generic. Sorry have to run..... |
Thanks @taqtiqa-mark 👍 I did a little reading (see links above) on the difference between general journal and general ledger. I agree with you that we need a general journal and it would help with interfaces with other accounting packages. I might summarize it this way: The general journal is a chronological record of transactions (double entries). The general ledger is a record of balances together with groups of similar accounts. GeneralLedgers.jl already has an |
I think so. I'm not convinced a GL is needed - at this point.
Pretty much coincides with my understanding - I'm not sure it even needs to be chronological, but that can be worked out. I think the main points are (unordered):
Hope that helps. |
A GL is needed if you want to build an accounting framework that accomodates financial models written in Julia natively (which is what I want to do) 😊 My goal is not to be able to plug into accounting software. I will build accounting software in Julia 🤓
For sure. Thanks 👍 |
🙇♂️ |
Hi guys 👋
I am not an accountant (not even close), but nonetheless, I feel like accounting is core to finance and should be baked into whatever we do here in some way from the beginning.
Along those lines, I just created a simple accounting package: GeneralLedgers.jl
As I noted here #7, all these packages are registered in the new
JuliaFinance
registry so you will need to add this registry to use them via:and then you should be able to add them as usual, e.g.
pkg> add GeneralLedgers
I included a very simple example function:
At its core, there is just one main
Account
type, but it uses (my understanding) of Holy traits to dispatch on five primary subaccount types:GeneralLedger
: Top-levelAccount
. Has no parent. Has children. Journal entries cannot be posted directly to aGeneralLedger
. Note: Since we use double-entry booking, the balance of theGeneralLedger
should always be zero since debits = credits.DebitGroup
: Has a parent. Has children. Journal entries cannot be posted directly toDebitGroups
, but for the purpose of aggregating children, it is treated as a debit account, i.e. a debit child increases the balance while a credit child decreases the balance.CreditGroup
: Has a parent. Has children. Journal entries cannot be posted directly toCreditGroups
, but for the purpose of aggregating children, it is treated as a credit account, i.e. a debit child decreases the balance while a credit child increases the balance.DebitAccount
: Has a parent. Has no children. Journal entries can be posted directly to aDebitAccount
. Debit entries increase the balance and credit entries decrease the balance.CreditAccount
: Has a parent. Has no children. Journal entries can be posted directly to aCreditAccount
. Debit entries decrease the balance and credit entries increase the balance.The example contains a journal
Entry
and we can
post
theEntry
to theGeneralLedger
as follows:Early drafts of this package had an internal
Cash
type defined. As we have discussed elsewhere, we need to take care and agree on some terminology. For the purposes of this package (and hopefully this organization),Thought in this way,
Currency
is a kind ofFinancialInstrument
soCash
is a special case of a more general concept ofPositions
ofFinancialInstruments
.I did a bit of meditating over the weekend and came up with a hierarchy. Not set in stone and open for discussion, but I think we need something like this.
At the top are very simple and lean
Countries
andCurrencies
. These are kind of primordial types on top of which most others are built.Sitting under these we have
Markets
. As I've described elsewhere, I see aMarket
as a kind of living provider of market quotes, e.g. yield curves, stock prices, implied volatilities, etc. ultimately to be used to priceFinancialInstruments
.Sitting under
Markets
, we haveJurisdictions
. AJurisdiction
could be a country, state / province, county, city / municipality, etc. DifferentJurisdictions
can have different laws / regulations, different tax treatments, different capital adequacy requirements, etc. These all have impacts on accounting.Sitting under
Jurisdictions
. we haveEntities
. AnEntity
is basically an issuer ofFinancialInstruments
. These could be governement treasuries, central banks, municipalities, corporations, etc. This is also where we could keep info about counterparties such as credit ratings, etc.Finally, sitting under
Entities
, we haveFinancialInstruments
. Based on conversations here, on Slack and on Discourse, I think most people will be interested inFinancialInstruments
. That is the "quant" stuff, i.e. defining and pricing (possibly complex) financial instruments.This is also where there is a large possibility to overlap with Miletus.jl since a
FinancialInstrument
is a contract. I suspect we'll need to do a lot of bikeshedding aroundFinancialInstruments
, but it is my hope that we can have other packages spring up to extendFinancialinstruments
in such a way that it still plays nice with the underlying accounting stuff.Next, we have
Positions
sitting underFinancialInstruments
.Positions
is a generalization ofCash
to accommodate a position in eitherCurrency
or aFinancialInstrument
.At the bottom of the totem pole, we have
GeneralLedgers
- as described above - sitting underPositions
. So the entire totem pole looks likeCountries
/Currencies
Markets
Jurisdictions
Entities
FinancialInstruments
Positions
GeneralLedgers
All these are still skeletal with the most flesh on
GeneralLedgers
, but I wanted to get something out there working so we can start an important discussion and map things out.I hope this is helpful and I look forward to feedback / questions / suggestions / etc.
Take care! 😊
The text was updated successfully, but these errors were encountered: