I’m developing a web app on Glide that functions as a fantasy league for the cryptocurrency market. Users start with $1 billion to invest in a portfolio by buying and selling assets.
Each transaction they make creates a row in the “Orders” sheet.
My challenge is figuring out how to track which tokens each user holds and their quantities. How can I set up my sheets to dynamically track each user’s holdings after every transaction?
How would you present this in the front end?
Can I assume that you would first select a player, and then navigate to a screen that would present a table with a list of tokens that player holds, and the current balance of each?
That would be just a matter of relation + rollup to get the balance, and “unique” to show only one row for each token at that point, but yeah, need more context here.
Users participate in a “Crypto Fantasy League” by creating portfolios composed of crypto tokens.
Users can view available tokens and use a buy/sell button for each token to open an edit screen.
This screen includes a number entry field where they can specify the amount of tokens to buy or sell.
Every submitted transaction creates a row in the “Orders” table (Glide Table) with details such as “User ID, Token ID, and Quantity Transacted” (as shown in the attached image).
My question is: Is it possible, by creating a relationship between the “Orders” and “Users” tables, or in some other way, to have all the portfolio-related information in the “Users” table?
For example, if a user has made three transactions:
Bought +10 tokens of A
Bought +10 tokens of B
Sold -5 tokens of A
I would like the “Users” table to reflect that the user owns 5 tokens of A and 10 tokens of B.
Create a query pointing to that same table, filter by token iD is this row > token ID and User ID is this row > user ID.
Add a rollup column on top of that query, target the math_Token quantity and do a sum, you should get your total quantity of a token for a user here.
Add a single value column on top of the query, get back the first rowID.
In your users table, add a relation to the orders table that matches multiple records using the User ID.
On the front end, add a collection component that is powered by the users relation with the orders table, filter by rowID is “first rowID” (from the single value column) so that we have “unique” records, then the quantity would come from the rollup.