Skip to main content


Showing posts with the label Google Apps Script tutorials

Stock Correlation Analysis With Google Sheets

Correlation is a statistical relationship that measures how related the movement of one variable is compared to another variable. For example, stock prices fluctuate over time and are correlated accordingly or inversely to one another. Understanding stock correlation and being able to perform analysis are very helpful in managing a stock portfolio investment. In this post, we will look at how to perform stock correlation analysis with Google Sheets. Understanding correlation and its applications in stock investing Stock correlation analysis with Google Sheets Getting started User guide Conclusion Understanding correlation and its applications in stock investing The most familiar correlation measure is the Pearson product-moment correlation coefficient . The strength of the relationship between two variables is expressed numerically between -1 and 1. For example: Two stocks are positively correlated when their prices always go up or go down together. Their coefficient

How to convert column index into letters with Google Apps Script

Although Google Sheets does not provide a ready-to-use function that takes a column index as an input and returns corresponding letters as output, we can still do the task by leveraging other built-in functions ADDRESS , REGEXEXTRACT , INDEX , SPLIT as shown in the post . However, in form of a formula, that solution is not applicable for scripting with Google Apps Script. In this post, we look at how to write a utility function with Google Apps Script that converts column index into corresponding letters. With the solution in the form of a formula , we don't even need to understand how column index and letters map each other. With apps script, we need to understand the mapping to come up with an algorithm. In a spreadsheet, columns are indexed alphabetically, starting from A. Obviously, the first 26 columns correspond to 26 alphabet characters, A to Z. The next 676 columns ( 26*26 ), from 27th to 702nd, are indexed with 2 letters. [AA, AB, ... AY, AZ], [BA, BB, ... BY, BZ],

How to copy data in Google Sheets as HTML table

I often need to extract some sample data in Google Sheets and present it in my blog as an HTML table. However, when copying a selected range in Google Sheets and paste it outside the Google Sheets, I only get plain text. In this post, I explain how to copy data in Google Sheets as an HTML table by writing a small Apps Script program. Concept Implementation Source Code Demo HTML table code HTML table visualization Getting Started Conclusion Concept On a spreadsheet, users select a range that they want to copy as HTML table. With the selected range, users trigger a command Copy AS HTML table . The command can be added to the toolbar, or to the contextual menu, or accessed via a keyboard shortcut. The command is executed to transform the selected range into HTML code for table. The HTML code can be added to the clipboard or can be displayed somewhere so users can copy it manually. The HTML table must consist of all displayed cells of the selected range and the widths

Compare stock portfolio to compound interest saving account

In investing, it is important to define the target that we want to achieve. Many investors like to compare their portfolios with a market index, but is outperforming the market index a good target? It is not a quantitative target to be measurable as market indexes fluctuate daily. I, personally, aim only for 10% growth a year. If at the end of the year, I see my portfolio grows 10%, I am pleased with that result no matter that S&P500 grows 50% the same year. To see if my stock portfolio grows in line with the 10% target, I choose to compare it to a saving account with the same interest. In this post, I will show you how to use a fictive saving account with daily compound interest as the target to benchmark a stock portfolio. Idea Computation Visualization Evolution of target saving account with 5% annual compound interest Evolution of target saving account with 10% annual compound interest Evolution of target saving account with 15% annual compound interest Conclusion

Demo stock portfolio tracker with Google Sheets and Google Data Studio

I am happy to announce the release of LION stock portfolio tracker. It is a personal stock portfolio tracker built with Google Sheets and Google Data Studio. The stock portfolio's transactions are managed in Google Sheets and its performance is monitored interactively on a beautiful dashboard in Google Data Studio. You can try with the demo below and follow the LION stock portfolio tracker guide to create your own personal stock portfolio tracker with Google Sheets and Google Data Studio. Demo dashboard Demo spreadsheet Guide Disclaimer Demo dashboard Demo spreadsheet Guide LION Stock Portfolio Tracker - Guide Disclaimer The post and the LION stock portfolio tracker are only for informational purposes and not for trading purposes or financial advice. It is your responsibility to use the LION stock portfolio tracker for managing your investment. I shall not be liable for any damages relating to your use of the LION stock portfolio tracker.

Compare stock portfolio to market indexes

As investors, we always want to see our portfolio grows over time. If a portfolio made a 1000$ of gain in one year, is it good enough? Should we gauge the portfolio's performance against an alternative investment, for instance, a market index? Should we aim to beat that index? In this post, we will see how to compare a stock portfolio to market indexes by using Google Sheets, Apps Script, and Google Data Studio. Select market indexes to compare Method to compare Guides Prepare data with Google Sheets and Apps Script Visualize benchmark in Google Data Studio Demo Conclusion Note References Select market indexes to compare In the context of stock investment, investors can compare the performance of their portfolios over a period of time with an alternative investment such as a market index, a portfolio of another investor, or even a single stock if they don't want any diversification, etc. In general, a market index is a good benchmark because it represents t

Compute daily evolutions of a stock portfolio with Google Sheets and Apps Script

When it comes to investment, it is not only important to know the up-to-date state of portfolio but also to track its evolution day by day. We need to know on a specific day, how much money has been invested in the portfolio, the current market value of owned shares, the available cash and the current profit. Visualizing those historical data points on a time-based graph helps us to identify which transactions were good and which were bad. This post shows how to compute automatically those historical data points by using data in Transactions sheet and the built-in GOOGLEFINANCE function of Google Sheets. A sample spreadsheet can be found in this post Demo stock portfolio tracker with Google Sheets . You can take a look at the sample spreadsheet to have an idea of how the data is organized and related. It is possible to make a copy of the spreadsheet to study it thoroughly. Concept Fetch historical data with GOOGLEFINANCE Automate with Apps Script Create a historical data sheet