diff --git a/app/CalendarPage.jsx b/app/CalendarPage.jsx index 2b76ca4..b79ca7b 100644 --- a/app/CalendarPage.jsx +++ b/app/CalendarPage.jsx @@ -153,7 +153,7 @@ const CalendarPage = () => { Education - Curious? Skeptical? Can’t get enough? We have monthly meetups where we teach people what BTC is, why it matters, and how it works. Let us show you how BTW can help YOU! + Curious? Skeptical? Can’t get enough? We have monthly meetups where we teach people what BTC is, why it matters, and how it works. Let us show you how BTC can help YOU! Socialize diff --git a/app/GraphPage.jsx b/app/GraphPage.jsx index 483f9e9..33dd706 100644 --- a/app/GraphPage.jsx +++ b/app/GraphPage.jsx @@ -5,6 +5,7 @@ import { DatePicker } from '@mui/x-date-pickers'; import { LineChart, Line, XAxis, YAxis } from 'recharts'; import { useState } from 'react'; import dayjs from 'dayjs'; +import ProfitDisplay from '@components/ProfitDisplay'; const bitcoinCSV = `Date,Price 09/01/2023,26209.50 @@ -133,14 +134,14 @@ const CSVtoJSON = (csv) => { let dataPointObj = {date: values[0], price: Number(values[1])} monthlyPrices.push(dataPointObj); } - console.log(JSON.stringify(monthlyPrices)); + // console.log(JSON.stringify(monthlyPrices)); return monthlyPrices.reverse(); } const selectPriceDates = (startDateStr, json) => { let startDateObj = new Date(startDateStr); let returnJson = json.filter(obj => new Date(obj.date) >= startDateObj); - console.log(returnJson); + // console.log(returnJson); return returnJson; } @@ -196,12 +197,30 @@ function formatDate(date) { return month + '/' + day + '/' + year; } +const calculateProfitPercent = (startDatePrice, endDatePrice) => { + const startPrice = startDatePrice.price; + const endPrice = endDatePrice.price; + console.log("start: " + startPrice); + console.log("end: " + endPrice); + return endPrice / startPrice; +} + +const getProfit = (principle, percentChange) => { + if (principle === -1) { + return 0; + } + const profit = principle * percentChange; + console.log(profit); + return profit; +} + const GraphPage = () => { const [selectedDate, setSelectedDate] = useState(dayjs("01/01/2014")); + const [investmentAmount, setInvestmentAmount] = useState(0); const json = CSVtoJSON(bitcoinCSV); const data = selectPriceDates(selectedDate, json); - + const profitPercent = calculateProfitPercent(data[0], data[data.length - 1]); return ( @@ -219,7 +238,7 @@ const GraphPage = () => { amount - + {setInvestmentAmount(event.target.value)}} /> @@ -229,13 +248,18 @@ const GraphPage = () => { - - - - - - - + + + + + + + + + + + +