Bitcoin Treasury Charts

Joey Karczewski
June 11, 2021

In honor of Bitcoin skyrocketing to over $60,000 for the first time a couple weeks ago, I created  Bitcoin Treasury Charts to graph the growth of stocks invested in BTC compared to the cost of BTC.

You can check out the project here: https://www.bitcointreasurycharts.com

image

Recently, Bitcoin has seen more and more corporate interest, and this will most likely be pivotal to its growth moving forward.

The general sentiment is that, as more companies add Bitcoin to their balance sheets, it’ll create a positive feedback loop - the price of Bitcoin will increase and as it does so, more & more companies will be enticed to buy BTC, further increasing the currency’s price and signaling to other companies that it’s a sound investment. However, having a volatile asset on your balance sheet means potentially increasing the volatility of your stock price. Thus, the general correlation between BTC and a stock price is important for shareholders, and those looking to gain exposure to Bitcoin through these companies, as well as CFOs looking for empirical data about other companies who’ve added BTC to their balance sheet. Additionally, stocks with Bitcoin on their balance sheet can act as an intermediary for those looking to participate in options on Bitcoin.

I couldn’t find any sites that charted theses correlations so I decided to take a stab at it using Retool!

How

1. The Backend setup
Knowing that, I wanted to make this project as dynamic and as quick as possible, I decided to move the calculations and complexity to Google sheets. I chose Google sheets because I knew that I didn’t have that much complex or unstructured data and wanted quick access to it, as I didn’t plan to update it using Retool, nor wanted to faff around with editing more complex databases. I also knew that I could use Google finance equations to chart daily stock prices & have them automatically updated every 20 minutes.

image


Above is my main sheet - to keep things as quick & neat as possible, this sheet uses sheet references to pull in information from separate sheets (say sheet one more time), each named after one of the companies invested in BTC. My Retool table only pulls in information from this main sheet. This way my front end doesn’t get overloaded with data and my Retool app stays super speedy

I make use of a pretty common & useful Retool dashboard layout as my front end (see first picture). As mentioned, I use a single Google sheets read query to pull in my main table. When a user selects a row in the table, I use a second query to pull in the associated Sheet by the Companies name. Here is a screenshot of my second query:

image


Below shows you what it looks like in my Google Sheet tabs. I’ll probs have to change my setup (like changing to an actual DB) when more than ~50 companies add Bitcoin to their balance sheets, but this works for now


image

In my first iteration of the app, I pulled in nearly all information (including stock points) in one query which took maybe 9 or 10 seconds to load. This two query strategy shortens it to 1 or 2 seconds and might be helpful in your Retool apps in some fashion if they have a large amount of data.

As for the company pages, I pretty much just dump all of the information that I’d like to have into separate columns. Here is an example below.

image

For the stock price charts, I use a simple Google Finance formula to display the stocks price for each day since the purchase of Bitcoin: =GOOGLEFINANCE(E2,“price”,L2,TODAY()). The rest of the information I scrounged from the web

. I’m still missing quite a bit, but Retool has enabled me to focus on collecting the data instead of debugging/creating the app.

Using my second query, I pull this information to be used on Retool!

Front End

My Retool app is fundamentally only two components, the table with data about each company and a container to display more details about the selected company. I’ll walk through a couple sections of the front end setup for those that are curious.

Dynamic Plotly Chart
While Retool still advertises their Plotly component as a beta feature, I’ve found that these are some of the most useful components in my apps. To make the chart comparing the selected company’s stock price to BTC while also displaying their purchases, I started with a basic plotly chart, and edited the JSON according to the Plotly Javascript Docs.

Here is my data Tab:

Click to View

For this to work properly, I had to change the dating format to be the same across the board: I did this in a transformer using moment, a JS library that Retool makes available:> var x = {{companyselecttable1.data.map(d=>d.Date)}}

return x.map((i) => moment(i).format(‘YYYY-MM-DD’))

Here is my Layout Tab

Click to View

This was taken all from plotly’s docs - mainly this: https://plotly.com/javascript/multiple-axes/ 1

Key Value Map

This data pulls directly from the table and dynamically changes according to the selected row.

Here is its Data Value:

Click to View

App Tricks

  • Displayed Columns Option - This feature allows users to select the columns they’d like to display in the table. To do this in your own app, you’ll want to add a multiselect component & set the values to be equal to the column names of your table. Next, set each table column to “Dynamically show key” and set the value to be: {{_.includes(multiselectcomponentname.value,“ColumnName”)}}. This makes it so that whenever your column name is selected, it appears in the table- ultimately giving users the ability to show/hide a table’s column.
  • Full Screen - I knew that I wanted the app to be full width so I set a text element to: ".retool-canvas { max-width: none !important; } " - you can check out a post I did about custom CSS HERE and Retool’s CSS post HERE

General Takeaways & Thoughts
All-in-all, what I think this project highlights best is the speed at which you can create apps with Retool. From start to finish this project only took about ~20 hours to make - most of that was collecting data for my app to display. I was also able to create this app using only a limited amount of JavaScript - only fixing small formatting problems or adding references.

As for negatives, the only sticking points I’m finding with my apps is query times and the lack of customization with some pre-made components.

On a different note, I think that Retool could help empower traditional small- to medium-sized companies ,who currently face an increasingly saturated market of software products that are aimed to improve their business and internal processes. The common penny-wise pound-foolish piecemeal approach of uncalculated tech adoption often sees these non-technical companies choosing inappropriate tech solutions, ultimately leading to overly complicated processes and additional cost. When the person who feels the pain is also the one empowered to be a part in building the solution (which low-code environments like Retool enable), I think that unique and extraordinarily powerful tools (and ultimately successful companies) would be the result. As services like Retool keep reducing their learning curve, I feel that more & more non-technical companies will forego these expensive software solutions and just build their own personalized tool based off of their own intuition & needs. If its as easy as plopping a table down, connecting a query and making an action (also not having to navigate someone else’s UI), companies would be silly not to use it. IDK how far we are off from that, but I feel like Retool is a step in the right direction.

I also think that there are a lot of opportunities for different forms of Retool first entrepreneurship outside of the internal tools space.

Hope this quick write up can be of use to somebody!