Created
August 5, 2023 12:48
-
-
Save dashaluna/33544656872a2a4cdee5a07e5ad9f454 to your computer and use it in GitHub Desktop.
GSheet script for plotting daily P/L
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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