Portfolio tracking applications help investors monitor the performance of their digital assets in real time. These systems track how much cryptocurrency a user owns, calculate the total portfolio value, and show profit or loss based on the latest market prices. Popular platforms such as CoinMarketCap and CoinGecko provide portfolio-tracking features that allow users to manage multiple assets, including Bitcoin, Ethereum, and Solana.
This article explains the logical concept, database structure, backend API, and frontend implementation required to build a cryptocurrency portfolio tracking application.
Understanding the Portfolio Tracking Concept
A portfolio tracker stores the number of coins owned by a user and calculates the current value using live market prices.
Example portfolio data
| Coin | Quantity | Current Price | Total Value |
|---|
| Bitcoin | 0.5 | $68421 | $34210.5 |
| Ethereum | 2 | $3800 | $7600 |
| Solana | 10 | $150 | $1500 |
Total Portfolio Value = Sum of all asset values.
Logical workflow of the system
User enters coin and quantity
↓
Application stores the portfolio in a database
↓
Backend fetches live prices from crypto API
↓
System calculates total value of each asset
↓
Portfolio dashboard displays updated values
This logic allows the portfolio value to update automatically whenever the market price changes.
Database Structure
A simple database table is used to store the portfolio.
SQL Table
CREATE TABLE CryptoPortfolio
(
Id INT IDENTITY(1,1) PRIMARY KEY,
CoinName VARCHAR(50),
Symbol VARCHAR(10),
Quantity DECIMAL(18,4)
)
Example data
| Id | CoinName | Symbol | Quantity |
|---|
| 1 | Bitcoin | btc | 0.5 |
| 2 | Ethereum | eth | 2 |
| 3 | Solana | sol | 10 |
Backend Implementation (ASP.NET Web API)
The backend performs three main tasks:
CryptoPortfolioController.cs
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using System.Data.SqlClient;
using System.Configuration;
namespace CryptoPortfolioAPI.Controllers
{
public class PortfolioController : ApiController
{
string conn = ConfigurationManager.ConnectionStrings["db"].ConnectionString;
[HttpGet]
[Route("api/portfolio")]
public async Task<IHttpActionResult> GetPortfolio()
{
List<object> portfolio = new List<object>();
using (SqlConnection con = new SqlConnection(conn))
{
con.Open();
SqlCommand cmd = new SqlCommand("SELECT CoinName,Symbol,Quantity FROM CryptoPortfolio", con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
portfolio.Add(new
{
coin = dr["CoinName"].ToString(),
symbol = dr["Symbol"].ToString(),
quantity = dr["Quantity"]
});
}
}
string api = "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum,solana&vs_currencies=usd";
HttpClient client = new HttpClient();
var response = await client.GetStringAsync(api);
return Ok(new { portfolio, prices = response });
}
}
}
Backend Logic Explanation
The backend retrieves the user’s portfolio from the database. It then calls the crypto market API to obtain current prices. The portfolio data and price data are combined and returned to the frontend for calculation and display.
Frontend Implementation (Portfolio Dashboard)
The frontend displays the portfolio table and calculates asset values.
index.html
<!DOCTYPE html>
<html>
<head>
<title>Crypto Portfolio Tracker</title>
<style>
body{
font-family:Arial;
background:#f5f7fa;
text-align:center;
}
.container{
width:800px;
margin:auto;
margin-top:50px;
background:white;
padding:30px;
border-radius:10px;
box-shadow:0 0 10px #ccc;
}
table{
width:100%;
border-collapse:collapse;
}
th,td{
padding:12px;
border-bottom:1px solid #eee;
}
th{
background:#f2f2f2;
}
.total{
font-weight:bold;
font-size:20px;
margin-top:20px;
}
</style>
</head>
<body>
<div class="container">
<h1>My Crypto Portfolio</h1>
<table>
<thead>
<tr>
<th>Coin</th>
<th>Quantity</th>
<th>Price</th>
<th>Total Value</th>
</tr>
</thead>
<tbody id="portfolioTable"></tbody>
</table>
<div id="totalValue" class="total"></div>
</div>
<script>
function loadPortfolio()
{
fetch("/api/portfolio")
.then(res=>res.json())
.then(data=>{
let portfolio = data.portfolio;
let prices = JSON.parse(data.prices);
let table="";
let totalPortfolio=0;
for(let i=0;i<portfolio.length;i++)
{
let coin = portfolio[i];
let price = prices[coin.symbol]?.usd || 0;
let value = coin.quantity * price;
totalPortfolio += value;
table += `
<tr>
<td>${coin.coin}</td>
<td>${coin.quantity}</td>
<td>$${price}</td>
<td>$${value.toFixed(2)}</td>
</tr>
`;
}
document.getElementById("portfolioTable").innerHTML = table;
document.getElementById("totalValue").innerHTML = "Total Portfolio Value: $" + totalPortfolio.toFixed(2);
});
}
loadPortfolio();
setInterval(loadPortfolio,10000);
</script>
</body>
</html>
Portfolio Calculation Logic
The frontend calculates the total portfolio value using the following formula.
Total Asset Value = Quantity × Current Price
Example
Bitcoin quantity = 0.5
Bitcoin price = $68421
Portfolio value for Bitcoin
0.5 × 68421 = $34210.5
The application calculates this value for every asset and sums them to determine the overall portfolio value.
Key Features of a Portfolio Tracking App
Asset tracking for multiple cryptocurrencies
Real-time price updates
Total portfolio value calculation
Simple dashboard interface
Automatic refresh with live market data
Possible Advanced Features
Real portfolio tracking systems usually include more advanced capabilities.
Historical profit and loss charts
Asset allocation visualization
Multiple currency conversion
Portfolio performance analytics
Mobile-friendly dashboard
User authentication and account management
Use Cases
Crypto investment tracking
Personal financial management
Crypto trading analytics
Institutional asset monitoring
Conclusion
Portfolio tracking applications are essential tools for cryptocurrency investors. By combining database storage, backend APIs, and dynamic frontend dashboards, developers can build powerful portfolio management systems that automatically update asset values using live market data. With additional features such as charts, analytics, and user authentication, the system can evolve into a full-featured crypto investment platform.