Created
March 3, 2018 14:46
-
-
Save ddoctorx/f531b2d3c354d4b578a287f83912c69d to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/humihuyiwu
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 charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
// current -> 进场金额, quit -> 退出价格 | |
function bet(current, quit) { | |
console.log('进场价格:' + current + '元') | |
console.log('离场价格:' + quit + '元') | |
// 承受风险不能超过 1R - 总资本的1% (防止破产风险发生) | |
var R = 2000 | |
var total = 200000 | |
// 亏损比例 = (退出价格 - 进场价格) / 进场价格 * 100% | |
var LossRatio = ((quit - current) / current * 100).toFixed(2) | |
console.log('1R的承受亏损比例:' + LossRatio + '%') | |
// 下注数量(手) = 1R / 每手亏损金额((current - quit) * 100) | |
var sum = (2000 / ((current - quit) * 100)).toFixed(2) | |
console.log('允许下注:' + sum + '手') | |
// 下注金额(元) = 进场价格 * 下注手数 * 100 | |
var result = (current * sum * 100).toFixed(2) | |
console.log('下注金额:' + result) | |
if ( result / total > 0.2 ) { | |
console.log('单次下注比例不能超过总资产 1/5') | |
} | |
console.log('==========================================') | |
} | |
bet(32.88, 25.04) | |
bet(27.36, 25.38) | |
// 1R = 2000 | |
// 当前价格 10 | |
// 止损价格 9 | |
// 运行止损比例 | |
// var radio = (10 - 9) / 10 * 100 + '%' | |
// 1股 损失 1快 | |
// 1收(100股) 损失 100快 | |
// 总共允许损失 2000块 | |
// var count = 2000 / 100 + '手' | |
// console.log(count) | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">// current -> 进场金额, quit -> 退出价格 | |
function bet(current, quit) { | |
console.log('进场价格:' + current + '元') | |
console.log('离场价格:' + quit + '元') | |
// 承受风险不能超过 1R - 总资本的1% (防止破产风险发生) | |
var R = 2000 | |
var total = 200000 | |
// 亏损比例 = (退出价格 - 进场价格) / 进场价格 * 100% | |
var LossRatio = ((quit - current) / current * 100).toFixed(2) | |
console.log('1R的承受亏损比例:' + LossRatio + '%') | |
// 下注数量(手) = 1R / 每手亏损金额((current - quit) * 100) | |
var sum = (2000 / ((current - quit) * 100)).toFixed(2) | |
console.log('允许下注:' + sum + '手') | |
// 下注金额(元) = 进场价格 * 下注手数 * 100 | |
var result = (current * sum * 100).toFixed(2) | |
console.log('下注金额:' + result) | |
if ( result / total > 0.2 ) { | |
console.log('单次下注比例不能超过总资产 1/5') | |
} | |
console.log('==========================================') | |
} | |
bet(32.88, 25.04) | |
bet(27.36, 25.38) | |
// 1R = 2000 | |
// 当前价格 10 | |
// 止损价格 9 | |
// 运行止损比例 | |
// var radio = (10 - 9) / 10 * 100 + '%' | |
// 1股 损失 1快 | |
// 1收(100股) 损失 100快 | |
// 总共允许损失 2000块 | |
// var count = 2000 / 100 + '手' | |
// console.log(count) | |
</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
// current -> 进场金额, quit -> 退出价格 | |
function bet(current, quit) { | |
console.log('进场价格:' + current + '元') | |
console.log('离场价格:' + quit + '元') | |
// 承受风险不能超过 1R - 总资本的1% (防止破产风险发生) | |
var R = 2000 | |
var total = 200000 | |
// 亏损比例 = (退出价格 - 进场价格) / 进场价格 * 100% | |
var LossRatio = ((quit - current) / current * 100).toFixed(2) | |
console.log('1R的承受亏损比例:' + LossRatio + '%') | |
// 下注数量(手) = 1R / 每手亏损金额((current - quit) * 100) | |
var sum = (2000 / ((current - quit) * 100)).toFixed(2) | |
console.log('允许下注:' + sum + '手') | |
// 下注金额(元) = 进场价格 * 下注手数 * 100 | |
var result = (current * sum * 100).toFixed(2) | |
console.log('下注金额:' + result) | |
if ( result / total > 0.2 ) { | |
console.log('单次下注比例不能超过总资产 1/5') | |
} | |
console.log('==========================================') | |
} | |
bet(32.88, 25.04) | |
bet(27.36, 25.38) | |
// 1R = 2000 | |
// 当前价格 10 | |
// 止损价格 9 | |
// 运行止损比例 | |
// var radio = (10 - 9) / 10 * 100 + '%' | |
// 1股 损失 1快 | |
// 1收(100股) 损失 100快 | |
// 总共允许损失 2000块 | |
// var count = 2000 / 100 + '手' | |
// console.log(count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment