cypher - Modelling time-varying financial exposures in `Neo4j` -
how 1 model kind of data in neo4j
?:
> holdings portfolio holding instrument date balance.usd 1 abc stock 1 share class stock 1 2013-12-31 25360291 2 abc stock 1 share class stock 1 2014-01-31 25302011 3 abc stock 1 share class b stock 1 2013-12-31 12264011 4 abc stock 1 share class b stock 1 2014-01-31 12893201 5 def fund 1 share class eur series 1 fund 1 2013-12-31 21012222 6 def fund 1 share class eur series 1 fund 1 2014-01-31 21632101 7 def fund 1 share class eur series 2 fund 1 2013-12-31 8214325 8 def fund 1 share class eur series 2 fund 1 2014-01-31 8292630 9 def portfolio abc account portfolio abc 2013-12-31 155364592 10 def portfolio abc account portfolio abc 2014-01-31 156202162 > factors instrument factor exposurestrength 1 stock 1 north america: 1.00 2 stock 1 industrials 1.00 3 fund 1 liquidity: low 0.05 4 fund 1 north america 0.70 5 fund 1 europe: eurozone: germany 0.20 6 fund 1 industrials : capital goods: building products 0.25
to give little narrative, portfolio invests changing set of instruments (stocks, bonds, other portfolios ...) time-varying value. instruments in turn sensitive factors, can hierarchical, such sectors (e.g. gics classification), regions/countries, size etc. although not reflected in factors
table above, exposurestrength
can vary time too.
portfolio exposure each factor calculated balance * exposurestrength
. aim later aggregate or slice&dice exposures different factor sets.
i not yet user of neo4j
considering learning cypher
query language, apologies not posting reproducible example yet. curious how complex cypher
snippets kind of problem.
you model time variance creating 1 holdingbalance node connected portfolio , instrument date reference, have :next relationships , @ same time anchored in time-tree quick access of sub-sequences.
something this:
(portfolio)-->(holding)<--(instrument) | v (holdingbalance)<-[:next]-(holdingbalance)-->(day)-->(month)-->(year)
same goes factors
(factor)-->(exposure)<--(instrument) | v (exposurestrength)<-[:next]-(exposurestrength)-->(day)-->(month)-->(year)
i started model graph-gist here, it's not done yet:
Comments
Post a Comment