theme | toc |
---|---|
dashboard |
false |
import {plotBreakdownChange, plotValueChange} from "./components/plots.js";
import {createClubbedStack, convertDates, getTopPerformer} from "./components/helpers.js";
name: Deploy to GitHub pages | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: ["main"] | |
schedule: | |
- cron: "30 */2 * * *" |
export function getTopPerformer(breakdown, num_days) { | |
const changeArray = [] | |
for (let i = 0; i < names.length; i++) { | |
const changeObj = { | |
name: names[i], | |
change: (breakdown[breakdown.length - 1][names[i]] - | |
breakdown[breakdown.length - 1 - num_days][names[i]]) | |
/ breakdown[breakdown.length - 1- num_days][names[i]] |
export function plotValueChange(breakdown, date, {width} = {}) { | |
const bisector = d3.bisector((i) => breakdown[i].time); | |
const basis = (I, Y) => Y[I[bisector.center(I, date)]]; | |
return Plot.plot({ | |
style: "overflow: visible;", | |
y: { | |
//type: "log", |
export function plotBreakdownChange(stackArray, date, {width} = {}) { | |
const bisector = d3.bisector((i) => stackArray[i].time); | |
const basis = (I, Y) => Y[I[bisector.center(I, date)]]; | |
return Plot.plot({ | |
style: "overflow: visible;", | |
y: { | |
//type: "log", |
export function getPertChange(breakdown, num_days) { | |
const change = (breakdown[breakdown.length - 1].value - | |
breakdown[breakdown.length - 1 - num_days].value) | |
/ breakdown[breakdown.length - 1- num_days].value | |
// Change % | |
const pert_change = change * 100; | |
// Round off to first digit after decimal |
export function plotBreakdownArea(stackArray, {width} = {}) { | |
return Plot.plot({ | |
width, | |
//title: "Portfolio breakdown", | |
x: {label: "Time [days]"}, | |
y: {grid: true, label: "Value [euros]", domain: [0, domain_max]}, | |
color: {legend: true}, | |
marks: [ | |
Plot.areaY(stackArray, { |
export function plotBreakdownBar(stackArray, {width} = {}) { | |
return Plot.plot({ | |
width, | |
//title: "Portfolio breakdown", | |
x: {label: "Time [days]"}, | |
y: {grid: true, label: "Value [euros]", domain: [0, domain_max]}, | |
color: {legend: true}, | |
marks: [ | |
Plot.rectY(stackArray, { |
import * as Plot from "npm:@observablehq/plot"; | |
import * as d3 from "https://cdn.jsdelivr.net/npm/d3@7/+esm"; | |
const domain_max = 30000 | |
export function plotValue(breakdown, {width} = {}) { | |
return Plot.plot({ | |
width, | |
//title: "Total portfolio value", |