global: add sell side risk ratio

This commit is contained in:
k
2024-09-21 14:22:27 +02:00
parent c8ded4ddb3
commit 2befa58fce
4 changed files with 147 additions and 84 deletions
+4
View File
@@ -9,6 +9,10 @@
<!-- ![Image of the kibō Web App version 0.4.1](./assets/v0.4.1.jpg) -->
## Datasets
- Added `Sell Side Risk Ratio` to all entities
## Website
- Fixed service worker not passing 304 (not modified) response and instead serving cached responses
+29 -1
View File
@@ -3,8 +3,9 @@ use allocative::Allocative;
use crate::{
datasets::{AnyDataset, ComputeData, InsertData, MinInitialStates},
states::RealizedState,
structs::{AnyBiMap, BiMap, Price},
structs::{AnyBiMap, AnyDateMap, BiMap, Price},
utils::ONE_MONTH_IN_DAYS,
DateMap,
};
#[derive(Default, Allocative)]
@@ -26,6 +27,8 @@ pub struct RealizedSubDataset {
cumulative_realized_loss: BiMap<f32>,
cumulative_net_realized_profit_and_loss: BiMap<f32>,
cumulative_net_realized_profit_and_loss_1m_net_change: BiMap<f32>,
realized_value: BiMap<f32>,
sell_side_risk_ratio: DateMap<f32>,
}
impl RealizedSubDataset {
@@ -63,6 +66,8 @@ impl RealizedSubDataset {
1,
&f("cumulative_net_realized_profit_and_loss_1m_net_change"),
),
realized_value: BiMap::new_bin(1, &f("realized_value")),
sell_side_risk_ratio: DateMap::new_bin(1, &f("sell_side_risk_ratio")),
};
s.min_initial_states
@@ -177,6 +182,19 @@ impl RealizedSubDataset {
&mut self.cumulative_net_realized_profit_and_loss,
ONE_MONTH_IN_DAYS,
);
self.realized_value.multi_insert_add(
heights,
dates,
&mut self.realized_profit,
&mut self.realized_loss,
);
self.sell_side_risk_ratio.multi_insert_percentage(
dates,
&mut self.realized_value.date,
&mut market_cap.date,
);
}
}
@@ -214,9 +232,14 @@ impl AnyDataset for RealizedSubDataset {
&self.cumulative_realized_loss,
&self.cumulative_net_realized_profit_and_loss,
&self.cumulative_net_realized_profit_and_loss_1m_net_change,
&self.realized_value,
]
}
fn to_computed_date_map_vec(&self) -> Vec<&(dyn AnyDateMap + Send + Sync)> {
vec![&self.sell_side_risk_ratio]
}
fn to_computed_mut_bi_map_vec(&mut self) -> Vec<&mut dyn AnyBiMap> {
vec![
&mut self.negative_realized_loss,
@@ -226,6 +249,11 @@ impl AnyDataset for RealizedSubDataset {
&mut self.cumulative_realized_loss,
&mut self.cumulative_net_realized_profit_and_loss,
&mut self.cumulative_net_realized_profit_and_loss_1m_net_change,
&mut self.realized_value,
]
}
fn to_computed_mut_date_map_vec(&mut self) -> Vec<&mut dyn AnyDateMap> {
vec![&mut self.sell_side_risk_ratio]
}
}
+111 -80
View File
@@ -3411,7 +3411,7 @@ lazySignals.then((importedSignals) => {
},
{
scale,
name: `PNL`,
name: `PNL - Profit And Loss`,
title: `${title} Realized Profit And Loss`,
description: "",
unit: "US Dollars",
@@ -3433,7 +3433,7 @@ lazySignals.then((importedSignals) => {
},
{
scale,
name: `Net PNL`,
name: `Net PNL - Net Profit And Loss`,
title: `${title} Net Realized Profit And Loss`,
description: "",
unit: "US Dollars",
@@ -3462,92 +3462,102 @@ lazySignals.then((importedSignals) => {
],
},
{
scale,
name: `Cumulative Profit`,
title: `${title} Cumulative Realized Profit`,
description: "",
unit: "US Dollars",
icon: "🎊",
bottom: [
name: "Cumulative",
tree: [
{
title: "Cumulative Realized Profit",
color: colors.profit,
datasetPath: `${scale}-to-${datasetPrefix}cumulative-realized-profit`,
scale,
name: `Profit`,
title: `${title} Cumulative Realized Profit`,
description: "",
unit: "US Dollars",
icon: "🎊",
bottom: [
{
title: "Cumulative Realized Profit",
color: colors.profit,
datasetPath: `${scale}-to-${datasetPrefix}cumulative-realized-profit`,
},
],
},
{
scale,
name: "Loss",
title: `${title} Cumulative Realized Loss`,
description: "",
unit: "US Dollars",
icon: "☠️",
bottom: [
{
title: "Cumulative Realized Loss",
color: colors.loss,
datasetPath: `${scale}-to-${datasetPrefix}cumulative-realized-loss`,
},
],
},
{
scale,
name: `Net PNL`,
title: `${title} Cumulative Net Realized Profit And Loss`,
description: "",
unit: "US Dollars",
icon: "",
bottom: [
{
title: "Cumulative Net Realized PNL",
type: "Baseline",
datasetPath: `${scale}-to-${datasetPrefix}cumulative-net-realized-profit-and-loss`,
},
],
},
{
scale,
name: `Net PNL 30 Day Change`,
title: `${title} Cumulative Net Realized Profit And Loss 30 Day Change`,
description: "",
unit: "US Dollars",
icon: "🗓️",
bottom: [
{
title: "Cumulative Net Realized PNL 30d Change",
datasetPath: `${scale}-to-${datasetPrefix}cumulative-net-realized-profit-and-loss-1m-net-change`,
type: "Baseline",
},
],
},
],
},
{
scale,
name: "Cumulative Loss",
title: `${title} Cumulative Realized Loss`,
description: "",
unit: "US Dollars",
icon: "☠️",
bottom: [
name: "Value",
tree: [
{
title: "Cumulative Realized Loss",
color: colors.loss,
datasetPath: `${scale}-to-${datasetPrefix}cumulative-realized-loss`,
scale,
name: `Created`,
title: `${title} Value Created`,
description: "",
unit: "US Dollars",
icon: "",
bottom: [
{
title: "Value",
color: colors.profit,
datasetPath: `${scale}-to-${datasetPrefix}value-created`,
},
],
},
],
},
{
scale,
name: `Cumulative Net PNL`,
title: `${title} Cumulative Net Realized Profit And Loss`,
description: "",
unit: "US Dollars",
icon: "",
bottom: [
{
title: "Cumulative Net Realized PNL",
type: "Baseline",
datasetPath: `${scale}-to-${datasetPrefix}cumulative-net-realized-profit-and-loss`,
},
],
},
{
scale,
name: `Cumulative Net PNL 30 Day Change`,
title: `${title} Cumulative Net Realized Profit And Loss 30 Day Change`,
description: "",
unit: "US Dollars",
icon: "🗓️",
bottom: [
{
title: "Cumulative Net Realized PNL 30d Change",
datasetPath: `${scale}-to-${datasetPrefix}cumulative-net-realized-profit-and-loss-1m-net-change`,
type: "Baseline",
},
],
},
{
scale,
name: `Value Created`,
title: `${title} Value Created`,
description: "",
unit: "US Dollars",
icon: "",
bottom: [
{
title: "Value",
color: colors.profit,
datasetPath: `${scale}-to-${datasetPrefix}value-created`,
},
],
},
{
scale,
name: `Value Destroyed`,
title: `${title} Value Destroyed`,
description: "",
unit: "US Dollars",
icon: "☄️",
bottom: [
{
title: "Value",
color: colors.loss,
datasetPath: `${scale}-to-${datasetPrefix}value-destroyed`,
scale,
name: `Destroyed`,
title: `${title} Value Destroyed`,
description: "",
unit: "US Dollars",
icon: "☄️",
bottom: [
{
title: "Value",
color: colors.loss,
datasetPath: `${scale}-to-${datasetPrefix}value-destroyed`,
},
],
},
],
},
@@ -3571,6 +3581,27 @@ lazySignals.then((importedSignals) => {
},
],
},
.../** @satisfies {PartialPresetTree} */ (
scale === "date"
? [
{
scale,
name: `Sell Side Risk Ratio`,
title: `${title} Sell Side Risk Ratio`,
description: "",
unit: "Percentage",
icon: "🥵",
bottom: [
{
title: "Ratio",
datasetPath: `${scale}-to-${datasetPrefix}sell-side-risk-ratio`,
color,
},
],
},
]
: []
),
],
};
}
+3 -3
View File
File diff suppressed because one or more lines are too long