mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-09 18:18:14 -07:00
parser: added ratio and co datasets
This commit is contained in:
@@ -16,28 +16,45 @@ impl AddressCohortsRealizedStates {
|
||||
realized_data: &AddressRealizedData,
|
||||
liquidity_classification: &LiquidityClassification,
|
||||
) -> color_eyre::Result<()> {
|
||||
let profit = realized_data.profit;
|
||||
let loss = realized_data.loss;
|
||||
let realized_profit = realized_data.profit;
|
||||
let realized_loss = realized_data.loss;
|
||||
let value_created = realized_data.value_created;
|
||||
let value_destroyed = realized_data.value_destroyed;
|
||||
|
||||
let split_profit = liquidity_classification.split(profit.to_cent() as f64);
|
||||
let split_loss = liquidity_classification.split(loss.to_cent() as f64);
|
||||
let split_realized_profit =
|
||||
liquidity_classification.split(realized_profit.to_cent() as f64);
|
||||
let split_realized_loss = liquidity_classification.split(realized_loss.to_cent() as f64);
|
||||
let split_value_created = liquidity_classification.split(value_created.to_cent() as f64);
|
||||
let split_value_destroyed =
|
||||
liquidity_classification.split(value_destroyed.to_cent() as f64);
|
||||
|
||||
let iterate = move |state: &mut SplitByLiquidity<RealizedState>| -> color_eyre::Result<()> {
|
||||
state.all.iterate(profit, loss);
|
||||
state.all.iterate(
|
||||
realized_profit,
|
||||
realized_loss,
|
||||
value_created,
|
||||
value_destroyed,
|
||||
);
|
||||
|
||||
state.illiquid.iterate(
|
||||
Price::from_cent(split_profit.illiquid as u64),
|
||||
Price::from_cent(split_loss.illiquid as u64),
|
||||
Price::from_cent(split_realized_profit.illiquid as u64),
|
||||
Price::from_cent(split_realized_loss.illiquid as u64),
|
||||
Price::from_cent(split_value_created.illiquid as u64),
|
||||
Price::from_cent(split_value_destroyed.illiquid as u64),
|
||||
);
|
||||
|
||||
state.liquid.iterate(
|
||||
Price::from_cent(split_profit.liquid as u64),
|
||||
Price::from_cent(split_loss.liquid as u64),
|
||||
Price::from_cent(split_realized_profit.liquid as u64),
|
||||
Price::from_cent(split_realized_loss.liquid as u64),
|
||||
Price::from_cent(split_value_created.liquid as u64),
|
||||
Price::from_cent(split_value_destroyed.liquid as u64),
|
||||
);
|
||||
|
||||
state.highly_liquid.iterate(
|
||||
Price::from_cent(split_profit.highly_liquid as u64),
|
||||
Price::from_cent(split_loss.highly_liquid as u64),
|
||||
Price::from_cent(split_realized_profit.highly_liquid as u64),
|
||||
Price::from_cent(split_realized_loss.highly_liquid as u64),
|
||||
Price::from_cent(split_value_created.highly_liquid as u64),
|
||||
Price::from_cent(split_value_destroyed.highly_liquid as u64),
|
||||
);
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -4,11 +4,21 @@ use crate::structs::Price;
|
||||
pub struct RealizedState {
|
||||
pub realized_profit: Price,
|
||||
pub realized_loss: Price,
|
||||
pub value_created: Price,
|
||||
pub value_destroyed: Price,
|
||||
}
|
||||
|
||||
impl RealizedState {
|
||||
pub fn iterate(&mut self, realized_profit: Price, realized_loss: Price) {
|
||||
pub fn iterate(
|
||||
&mut self,
|
||||
realized_profit: Price,
|
||||
realized_loss: Price,
|
||||
value_created: Price,
|
||||
value_destroyed: Price,
|
||||
) {
|
||||
self.realized_profit += realized_profit;
|
||||
self.realized_loss += realized_loss;
|
||||
self.value_created += value_created;
|
||||
self.value_destroyed += value_destroyed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,9 @@ impl UTXOCohortsSentStates {
|
||||
let previous_value = previous_price * amount_sent;
|
||||
let current_value = current_price * amount_sent;
|
||||
|
||||
state.realized.value_destroyed += previous_value;
|
||||
state.realized.value_created += current_value;
|
||||
|
||||
match previous_value.cmp(¤t_value) {
|
||||
Ordering::Less => {
|
||||
state.realized.realized_profit += current_value - previous_value;
|
||||
|
||||
Reference in New Issue
Block a user