Last active
July 8, 2025 12:37
-
-
Save sadiqsalau/e19f938c78b5387e6691458b2232b7da to your computer and use it in GitHub Desktop.
AI Earn - TP Calculator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getPercentage = (amount) => { | |
if (amount >= 300) { | |
return 6.5 / 100; | |
} else if (amount >= 20) { | |
return 6 / 100; | |
} else { | |
return 5.5 / 100; | |
} | |
}; | |
const getProfit = (amount) => getPercentage(amount) * amount; | |
const getDate = (i = 0) => | |
new Date(Date.now() + i * 1000 * 60 * 60 * 24).toDateString(); | |
const INITIAL_CAPITAL = 237; | |
const DAYS = 20; | |
/** Static */ | |
const INVESTMENT_DURATION = 20; | |
const REINVEST_DURATION = 15; | |
const REINVEST = true; | |
let investments = [ | |
{ | |
amount: INITIAL_CAPITAL, | |
start: 1, | |
ends: INVESTMENT_DURATION, | |
startDate: getDate(), | |
endDate: getDate(INVESTMENT_DURATION), | |
}, | |
]; | |
let balance = 0; | |
let tp = 0; | |
for (let i = 1; i <= DAYS; i++) { | |
investments = investments.filter((item) => item.ends >= i); | |
tp = investments.reduce((result, item) => result + item.amount, 0); | |
balance += getProfit(tp); | |
if (REINVEST && REINVEST_DURATION >= i && balance >= 1) { | |
investments.push({ | |
amount: balance, | |
start: i, | |
ends: i + INVESTMENT_DURATION, | |
startDate: getDate(i), | |
endDate: getDate(i + INVESTMENT_DURATION), | |
}); | |
balance = 0; | |
} | |
} | |
console.table(investments); | |
console.log("Initial Investment:", INITIAL_CAPITAL); | |
console.log("Duration Per Investment:", INVESTMENT_DURATION); | |
console.log("Total Days:", DAYS); | |
console.log("Reinvested?:", REINVEST); | |
console.log("Reinvested Days:", REINVEST_DURATION); | |
console.log("TP:", tp); | |
console.log("Balance:", balance); | |
console.log("Profit Per Day:", getPercentage(tp) * tp); | |
let profit = 0; | |
let lastDate; | |
for (let i = DAYS + 1; ; i++) { | |
investments = investments.filter((item) => item.ends >= i); | |
if (!investments.length) { | |
lastDate = getDate(i - 1); | |
break; | |
} | |
tp = investments.reduce((result, item) => result + item.amount, 0); | |
profit += getProfit(tp); | |
} | |
console.log("Total Profit:", profit); | |
console.log("Last Date:", lastDate); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const INITIAL_CAPITAL = 100; | |
const DAYS = 30; | |
/** Static */ | |
const REINVEST = true; | |
const PERCENTAGE = 0.04; | |
const INVESTMENT_DURATION = 30; | |
const getDate = (i = 0) => | |
new Date(Date.now() + i * 1000 * 60 * 60 * 24).toDateString(); | |
let investments = [ | |
{ | |
amount: INITIAL_CAPITAL, | |
start: 1, | |
ends: INVESTMENT_DURATION, | |
startDate: getDate(), | |
endDate: getDate(INVESTMENT_DURATION), | |
}, | |
]; | |
let balance = 0; | |
let tp = 0; | |
for (let i = 1; i <= DAYS; i++) { | |
investments = investments.filter((item) => item.ends >= i); | |
tp = investments.reduce((result, item) => result + item.amount, 0); | |
balance += PERCENTAGE * tp; | |
if (REINVEST && balance >= 1) { | |
investments.push({ | |
amount: balance, | |
start: i, | |
ends: i + INVESTMENT_DURATION, | |
startDate: getDate(i), | |
endDate: getDate(i + INVESTMENT_DURATION), | |
}); | |
balance = 0; | |
} | |
} | |
console.table(investments); | |
console.log("TP:", tp); | |
console.log("Balance:", balance); | |
console.log("Profit Per Day:", PERCENTAGE * tp); | |
let profit = 0; | |
let lastDate; | |
for (let i = DAYS + 1; ; i++) { | |
investments = investments.filter((item) => item.ends >= i); | |
if (!investments.length) { | |
lastDate = getDate(i - 1); | |
break; | |
} | |
tp = investments.reduce((result, item) => result + item.amount, 0); | |
profit += PERCENTAGE * tp; | |
} | |
console.log("Total Profit:", profit); | |
console.log("Last Date:", lastDate); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Manual Reinvestment Simulator</title> | |
<style> | |
body { font-family: sans-serif; padding: 20px; background: #f4f4f4; } | |
input, button { padding: 8px; margin: 5px; font-size: 1rem; } | |
table { width: 100%; margin-top: 20px; border-collapse: collapse; background: white; } | |
th, td { padding: 6px 12px; border: 1px solid #ccc; text-align: center; } | |
h2 { margin-top: 30px; } | |
</style> | |
</head> | |
<body> | |
<h1>Manual Reinvestment Simulator</h1> | |
<label>Start Date: <input type="date" id="startDate" /></label> | |
<label>Initial Capital ($): <input type="number" id="capital" value="237" /></label> | |
<button onclick="simulate()">Run Simulation</button> | |
<div id="output"></div> | |
<script> | |
function simulate() { | |
const START_DATE = new Date(document.getElementById('startDate').value); | |
const INITIAL_CAPITAL = parseFloat(document.getElementById('capital').value); | |
const DAYS = 24; | |
const INVESTMENT_DURATION = 20; | |
const REINVEST_DURATION = DAYS; | |
const REINVEST = true; | |
const getPercentage = (amount) => { | |
if (amount >= 300) return 6.5 / 100; | |
else if (amount >= 20) return 6 / 100; | |
return 5.5 / 100; | |
}; | |
const getProfit = (amount) => getPercentage(amount) * amount; | |
const getDate = (i = 0) => { | |
const d = new Date(START_DATE.getTime() + i * 86400000); | |
return d.toDateString(); | |
}; | |
let investments = [ | |
{ | |
amount: INITIAL_CAPITAL, | |
start: 0, | |
ends: INVESTMENT_DURATION, | |
startDate: getDate(), | |
endDate: getDate(INVESTMENT_DURATION), | |
}, | |
]; | |
let balance = 0, tp = 0; | |
for (let i = 1; i <= DAYS; i++) { | |
tp = investments.reduce((sum, item) => sum + item.amount, 0); | |
balance += getProfit(tp); | |
if (REINVEST && REINVEST_DURATION >= i && balance >= 1) { | |
investments.push({ | |
amount: balance, | |
start: i, | |
ends: i + INVESTMENT_DURATION, | |
startDate: getDate(i), | |
endDate: getDate(i + INVESTMENT_DURATION), | |
}); | |
balance = 0; | |
} | |
} | |
let resultHTML = ` | |
<h2>Investments Table</h2> | |
<table><tr><th>#</th><th>Amount</th><th>Start</th><th>End</th><th>Start Date</th><th>End Date</th></tr>`; | |
investments.forEach((inv, i) => { | |
resultHTML += `<tr><td>${i + 1}</td><td>$${inv.amount.toFixed(2)}</td><td>${inv.start}</td><td>${inv.ends}</td><td>${inv.startDate}</td><td>${inv.endDate}</td></tr>`; | |
}); | |
resultHTML += `</table>`; | |
let profit = 0, extraDays = [], lastDate = '', takenProfit = 0; | |
for (let i = DAYS + 1; ; i++) { | |
investments = investments.filter(item => item.ends >= i); | |
if (!investments.length) { | |
lastDate = getDate(i - 1); | |
break; | |
} | |
tp = investments.reduce((sum, item) => sum + item.amount, 0); | |
const dayProfit = getProfit(tp); | |
profit += dayProfit; | |
extraDays.push({ day: i, profit: dayProfit, date: getDate(i), taken: i <= 30 }); | |
if (i <= 30) takenProfit += dayProfit; | |
} | |
resultHTML += ` | |
<h2>Summary</h2> | |
<p><strong>Initial Capital:</strong> $${INITIAL_CAPITAL}</p> | |
<p><strong>Investment Duration:</strong> ${INVESTMENT_DURATION} days</p> | |
<p><strong>Simulation Days:</strong> ${DAYS}</p> | |
<p><strong>Reinvested:</strong> ${REINVEST}</p> | |
<p><strong>Total Profit (After Day ${DAYS}):</strong> $${profit.toFixed(2)}</p> | |
<p><strong>Profit Withdrawn by Day 30:</strong> $${takenProfit.toFixed(2)}</p> | |
<p><strong>Final Maturity Date:</strong> ${lastDate}</p> | |
<h2>Profit After Reinvestment Period</h2> | |
<table><tr><th>Day</th><th>Date</th><th>Daily Profit</th><th>Withdrawn?</th></tr>`; | |
extraDays.forEach(row => { | |
resultHTML += `<tr><td>${row.day}</td><td>${row.date}</td><td>$${row.profit.toFixed(2)}</td><td>${row.taken ? '✅' : '❌'}</td></tr>`; | |
}); | |
resultHTML += `</table>`; | |
document.getElementById('output').innerHTML = resultHTML; | |
} | |
</script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const START_DATE=new Date("07-02-2025"); | |
const INITIAL_CAPITAL = 237; | |
const DAYS = 24; | |
/** Static */ | |
const INVESTMENT_DURATION = 20; | |
const REINVEST_DURATION = DAYS; | |
const REINVEST = true; | |
const getPercentage = (amount) => { | |
if (amount >= 300) { | |
return 6.5 / 100; | |
} else if (amount >= 20) { | |
return 6 / 100; | |
} else { | |
return 5.5 / 100; | |
} | |
}; | |
const getProfit = (amount) => getPercentage(amount) * amount; | |
const getDate = (i = 0) => | |
new Date(START_DATE.getTime() + i * 1000 * 60 * 60 * 24).toDateString(); | |
let investments = [ | |
{ | |
amount: INITIAL_CAPITAL, | |
start: 0, | |
ends: INVESTMENT_DURATION, | |
startDate: getDate(), | |
endDate: getDate(INVESTMENT_DURATION), | |
}, | |
]; | |
let balance = 0; | |
let tp = 0; | |
for (let i = 1; i <= DAYS; i++) { | |
tp = investments.reduce((result, item) => result + item.amount, 0); | |
balance += getProfit(tp); | |
if (REINVEST && REINVEST_DURATION >= i && balance >= 1) { | |
investments.push({ | |
amount: balance, | |
start: i, | |
ends: i + INVESTMENT_DURATION, | |
startDate: getDate(i), | |
endDate: getDate(i + INVESTMENT_DURATION), | |
}); | |
balance = 0; | |
} | |
} | |
console.table(investments); | |
console.log("Initial Investment:", INITIAL_CAPITAL); | |
console.log("Duration Per Investment:", INVESTMENT_DURATION); | |
console.log("Total Days:", DAYS); | |
console.log("Reinvested?:", REINVEST); | |
console.log("Reinvested Days:", REINVEST_DURATION); | |
console.log("TP:", tp); | |
console.log("Balance:", balance); | |
console.log("Profit Per Day:", getProfit(tp)); | |
let profit = 0; | |
let extraDays = []; | |
let lastDate; | |
let takenProfit=0; | |
for (let i = DAYS + 1; ; i++) { | |
investments = investments.filter((item) => item.ends >= i); | |
if (!investments.length) { | |
lastDate = getDate(i - 1); | |
break; | |
} | |
tp = investments.reduce((result, item) => result + item.amount, 0); | |
profit += getProfit(tp); | |
extraDays.push({ | |
day: i, | |
profit: getProfit(tp), | |
date: getDate(i), | |
taken: i<=30 | |
}); | |
if(i <=30){ | |
takenProfit += getProfit(tp); | |
} | |
} | |
console.log("Total Profit:", profit); | |
console.log("Last Date:", lastDate); | |
console.log("Taken Profit:", takenProfit); | |
console.table(extraDays); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment