Last active
December 29, 2020 11:12
-
-
Save saru2020/8ffbaeaa1a0e26093208d96789f2e731 to your computer and use it in GitHub Desktop.
Free Share Calc[Used to calculate the selling price of a stock given the no of bought shares & no of sold shares]// source https://jsbin.com/fopixis
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> | |
<head> | |
<meta name="description" content="[add your bin description]"> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>Free Share Calc</title> | |
</head> | |
<body> | |
Calc to calculate the profit required to get 1 free stock/share | |
<script id="jsbin-javascript"> | |
let buyPrice = 3496.67 | |
let buyQuantity = 3 | |
// let sellPrice = 6900 | |
let sellQuantity = 2 | |
var profit = 0 | |
// profit = (sellPrice * sellQuantity) - (buyPrice * sellQuantity) | |
// console.log('profit: ' + profit) | |
let investedCapital = buyPrice * buyQuantity | |
//profit - investedCapital = requiredProfitForFreeShare | |
// var freeSharePrice = profit | |
var tempSellPrice = 0 | |
while(parseInt(profit) <= parseInt(buyPrice)) { | |
tempSellPrice += 1 | |
profit = (tempSellPrice * sellQuantity) - (investedCapital - buyPrice) | |
// console.log(tempSellPrice) | |
// console.log(profit) | |
} | |
// console.log('investedCapital: ' + investedCapital) | |
// console.log('profit: ' + profit) | |
console.log('The Final Sell Price should be: ' + tempSellPrice) | |
// console.log('some') | |
profit = (tempSellPrice * sellQuantity) - (buyPrice * sellQuantity) | |
console.log('Takehome profit: ' + profit) | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">let buyPrice = 3496.67 | |
let buyQuantity = 3 | |
// let sellPrice = 6900 | |
let sellQuantity = 2 | |
var profit = 0 | |
// profit = (sellPrice * sellQuantity) - (buyPrice * sellQuantity) | |
// console.log('profit: ' + profit) | |
let investedCapital = buyPrice * buyQuantity | |
//profit - investedCapital = requiredProfitForFreeShare | |
// var freeSharePrice = profit | |
var tempSellPrice = 0 | |
while(parseInt(profit) <= parseInt(buyPrice)) { | |
tempSellPrice += 1 | |
profit = (tempSellPrice * sellQuantity) - (investedCapital - buyPrice) | |
// console.log(tempSellPrice) | |
// console.log(profit) | |
} | |
// console.log('investedCapital: ' + investedCapital) | |
// console.log('profit: ' + profit) | |
console.log('The Final Sell Price should be: ' + tempSellPrice) | |
// console.log('some') | |
profit = (tempSellPrice * sellQuantity) - (buyPrice * sellQuantity) | |
console.log('Takehome profit: ' + profit)</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
let buyPrice = 3496.67 | |
let buyQuantity = 3 | |
// let sellPrice = 6900 | |
let sellQuantity = 2 | |
var profit = 0 | |
// profit = (sellPrice * sellQuantity) - (buyPrice * sellQuantity) | |
// console.log('profit: ' + profit) | |
let investedCapital = buyPrice * buyQuantity | |
//profit - investedCapital = requiredProfitForFreeShare | |
// var freeSharePrice = profit | |
var tempSellPrice = 0 | |
while(parseInt(profit) <= parseInt(buyPrice)) { | |
tempSellPrice += 1 | |
profit = (tempSellPrice * sellQuantity) - (investedCapital - buyPrice) | |
// console.log(tempSellPrice) | |
// console.log(profit) | |
} | |
// console.log('investedCapital: ' + investedCapital) | |
// console.log('profit: ' + profit) | |
console.log('The Final Sell Price should be: ' + tempSellPrice) | |
// console.log('some') | |
profit = (tempSellPrice * sellQuantity) - (buyPrice * sellQuantity) | |
console.log('Takehome profit: ' + profit) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment