Building Analytics Features
August 19, 2024
Analytics Challenge
I've been working on the analytics features, and it's been challenging. Calculating win rates, profit/loss, and other metrics requires aggregating data correctly. I've had to learn about array methods like reduce and filter in more depth.
What I've Built
I created functions to calculate:
- Total profit/loss
- Win rate percentage
- Average win/loss amounts
- Number of trades per account
These calculations update automatically when trades are added or modified.
Dashboard Component
I built a dashboard that displays all these metrics. It's basic, but it shows the key information at a glance. Seeing the data visualized is satisfying.
Data Structure
I've been refining my data structure as I build features. I'm learning that good data structure makes everything else easier. I've refactored the trade data model a few times already.
Challenges
The math for calculating percentages and averages was trickier than expected. I had to handle edge cases like division by zero and empty arrays. These are the kinds of details that separate working code from good code.
Progress Update
The application is starting to feel real. I can add trades, switch accounts, and see analytics. There's still work to do, but it's functional. I'm proud of what I've built so far.
Next Phase
I want to add more features like trade editing and deletion, better data validation, and maybe some charts to visualize performance over time.