Skip to content

Instantly share code, notes, and snippets.

@vnegi10
Created May 10, 2024 10:23
Show Gist options
  • Save vnegi10/2cd72e9c117c787d612c4db4c4b80e0b to your computer and use it in GitHub Desktop.
Save vnegi10/2cd72e9c117c787d612c4db4c4b80e0b to your computer and use it in GitHub Desktop.
theme toc
dashboard
false

Relative performance

import {plotBreakdownChange, plotValueChange} from "./components/plots.js";
import {createClubbedStack, convertDates, getTopPerformer} from "./components/helpers.js";
import * as Inputs from "npm:@observablehq/inputs";
const breakdown = FileAttachment("./data/value.json").json();
const weeklyObj = getTopPerformer(breakdown, 7);
const monthlyObj = getTopPerformer(breakdown, 30);
 
   

Last 7 days top performer [ticker, %]

    ${weeklyObj.maxName}, ${weeklyObj.maxChange}  
 
   

Last 30 days top performer [ticker, %]

    ${monthlyObj.maxName}, ${monthlyObj.maxChange}  
const clubbedStack = createClubbedStack(breakdown)
const date = view(
    Inputs.date({
        label: "Select starting date for comparison",
        min: clubbedStack[0].time,
        max: clubbedStack[clubbedStack.length - 1].time
        }));
   
${resize((width) => plotValueChange(convertDates(breakdown), date, {width}))}
   
${resize((width) => plotBreakdownChange(clubbedStack, date, {width}))}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment