Created
October 22, 2018 19:13
-
-
Save kalepail/411b04f7278b63ee5c5769574a6dc10d to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/yiyasom
This file contains 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> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script src="https://cdn.jsdelivr.net/lodash/4/lodash.min.js"></script> | |
<script id="jsbin-javascript"> | |
'use strict'; | |
var i = 0; | |
var price = 0.249999; | |
var p = 0; | |
var start = 60000; | |
var progress = 0; | |
var sales = []; | |
while (start > progress) { | |
var sum = start * ((i + 1) / 1000); | |
var diff = start - progress; | |
if (sum > diff) sum = diff; | |
p = price - i / 20000; | |
sales.push({ | |
price: p, | |
amount: sum, | |
total: p * sum | |
}); | |
progress += sum; | |
i++; | |
} | |
console.log('\n' + sales.length + ' trades\n' + price + ' start\n' + p + ' end\n' + _.sum(_.map(sales, 'total')) + ' w/feature\n' + price * start + ' w/o feature\n' + (price * start - _.sum(_.map(sales, 'total'))) + ' diff\n'); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">let i = 0 | |
let price = 0.249999 | |
let p = 0 | |
let start = 60000 | |
let progress = 0 | |
const sales = [] | |
while (start > progress) { | |
let sum = start * ((i+1) / 1000) | |
let diff = start - progress | |
if (sum > diff) | |
sum = diff | |
p = price - i / 20000 | |
sales.push({ | |
price: p, | |
amount: sum, | |
total: p * sum | |
}) | |
progress += sum | |
i++ | |
} | |
console.log(` | |
${sales.length} trades | |
${price} start | |
${p} end | |
${_.sum(_.map(sales, 'total'))} w/feature | |
${price * start} w/o feature | |
${price * start - _.sum(_.map(sales, 'total'))} diff | |
`)</script></body> | |
</html> |
This file contains 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
'use strict'; | |
var i = 0; | |
var price = 0.249999; | |
var p = 0; | |
var start = 60000; | |
var progress = 0; | |
var sales = []; | |
while (start > progress) { | |
var sum = start * ((i + 1) / 1000); | |
var diff = start - progress; | |
if (sum > diff) sum = diff; | |
p = price - i / 20000; | |
sales.push({ | |
price: p, | |
amount: sum, | |
total: p * sum | |
}); | |
progress += sum; | |
i++; | |
} | |
console.log('\n' + sales.length + ' trades\n' + price + ' start\n' + p + ' end\n' + _.sum(_.map(sales, 'total')) + ' w/feature\n' + price * start + ' w/o feature\n' + (price * start - _.sum(_.map(sales, 'total'))) + ' diff\n'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment