Skip to content

Instantly share code, notes, and snippets.

@dashaluna
Created August 5, 2023 12:48
Show Gist options
  • Save dashaluna/33544656872a2a4cdee5a07e5ad9f454 to your computer and use it in GitHub Desktop.
Save dashaluna/33544656872a2a4cdee5a07e5ad9f454 to your computer and use it in GitHub Desktop.
GSheet script for plotting daily P/L
function plotDailyPL() {
//read the counter (#) in cell A1 of History, number in cell is the row of column to input data
var counter = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("History").getRange("E2");
// record DATE in cell A#
var date = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("History").getRange("D"+counter.getValue());
date.setValue(new Date(new Date().getFullYear(),new Date().getMonth(), new Date().getDate()));
//read portfolio value in "Portfolio Sheet"
var portfolioValue = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Portfolio").getRange("I18");
var value = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("History").getRange("E"+counter.getValue());
value.setValue(portfolioValue.getValue());
//+1 to the counter in cell A1
counter.setValue(counter.getValue() + 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment