Skip to content

Add NUPL feature to block nodes#41

Merged
VJalili merged 32 commits into
B1AAB:mainfrom
VJalili:tx-market-value
Apr 12, 2026
Merged

Add NUPL feature to block nodes#41
VJalili merged 32 commits into
B1AAB:mainfrom
VJalili:tx-market-value

Conversation

@VJalili

@VJalili VJalili commented Apr 1, 2026

Copy link
Copy Markdown
Collaborator

Net Unrealized Profit and Loss (NUPL) is a highly informative metric for market sentiment in quant analysis. However, this feature cannot be computed using on-chain data alone, as it requires the fiat value of a UTxO's BTC at the time of its creation. Therefore, to compute this metric, two major improvements are implemented in this PR:

  • Retrieving UTxOs at a given block: This requires tracking when a TxO is spent, and then retrieving the ones that were created before a given block and spent after it. Because EBA processes each block independently—and tracking a spent TxO depends on inputs from other transactions and potentially other blocks—determining when a TxO is spent requires a post-initial iteration process. Once this tracking is complete, an index recording when a TxO was created and spent is necessary to find UTxOs at a given block height. Txo spending is determined post-traverse, and implemented in Resolve Txo spending post-traverse  #43; this PR adds the required index.

  • Integrating off-chain data: The fiat value of BTC is not tracked on-chain; it is market data that requires an additional post-traversal process to integrate. This PR takes the first step in supporting off-chain data, starting with fiat values.

Leveraging these two improvements, this PR enables the computation of NUPL for every block.

Limitations

The downside of this method is that it requires multiple iterations through the edges for different tasks. This approach is extremely slow even at a relatively small scale; for context, processing 1 million edges took approximately one hour, whereas the graph at full scale contains roughly 40 billion edges.

Ideally this method should be implemented as a database server-side task (currently implemented using database drivers, that involves data transfer to client side), or on the raw data pre-bulk import. #43 implements some of the required tasks on the graph serializations before database import, which runs significantly faster than its equivalent neo4j-based queries.

@VJalili
VJalili marked this pull request as ready for review April 12, 2026 14:27
@VJalili
VJalili merged commit 82832f9 into B1AAB:main Apr 12, 2026
2 checks passed
@VJalili
VJalili deleted the tx-market-value branch April 12, 2026 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant