Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
len.liu
committed
Sep 26, 2021
1 parent
0feb806
commit 1c1b4fa
Showing
17 changed files
with
543 additions
and
7 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
## 正向公式 | ||
|
||
#### 开仓价格 | ||
|
||
开仓价格 = 合约总 USDT 价值/总合约数量 = (数量 1*价格 1 + 数量 1*价格 1 + ...)/总合约数量 | ||
|
||
## 全仓 | ||
|
||
### 做多 | ||
|
||
#### 仓位价值 | ||
|
||
仓位价值 = 数量 * 价格 | ||
|
||
#### 开仓手续费 | ||
|
||
开仓手续费 = 数量*价格*0.00075 | ||
|
||
#### 委托成本 | ||
|
||
委托成本=初始保证金+开仓手续费+平仓手续费 | ||
|
||
#### 初始保证金 | ||
|
||
初始保证金 = 数量*价格/杠杆 | ||
|
||
#### 平仓手续费 | ||
|
||
平仓手续费 = 数量*价格*(杠杆-1)/杠杆 * 0.00075 | ||
|
||
#### 仓位保证金 | ||
|
||
仓位保证金=初始保证金+平仓手续费+AB | ||
|
||
#### 维持保证金 | ||
|
||
维持保证金 = 数量 * 价格 * 0.005 | ||
|
||
#### 破产价 | ||
|
||
破产价 = (仓位价值 - 仓位保证金) / (1 - 0.00075) / 数量 | ||
|
||
#### 强平价 | ||
|
||
强平价 = (仓位价值 - 仓位保证金 + 平仓手续费 + 维持保证金) / 数量 | ||
|
||
#### 未结盈亏 | ||
|
||
未结盈亏=数量 *(市价 - 入场价) | ||
未结盈亏回报率 = 未结盈亏 / 初始保证金 | ||
|
||
#### 止盈止损百分比对应价格 | ||
止盈百分比对应价格 = 未结盈亏/委托成本 = 数量 * (X - 价格)/委托成本 | ||
止损百分比对应价格 = 未结盈亏/委托成本 = 数量 * (价格 - X)/委托成本 | ||
|
||
#### 做空 | ||
#### 仓位价值 | ||
#### 初始保证金 | ||
#### 开仓手续费 | ||
#### 平仓手续费 | ||
平仓手续费 = 数量*价格*(杠杆 + 1)/杠杆 * 0.00075 | ||
#### 委托成本 | ||
#### 维持保证金 | ||
#### 仓位保证金 | ||
#### 破产价 | ||
破产价 = (仓位价值 + 仓位保证金) / (1 + 0.00075) / 数量 | ||
#### 强平价 | ||
强平价 = (仓位价值 + 仓位保证金 - 平仓手续费 - 维持保证金) / 数量 | ||
#### 未结盈亏 | ||
未结盈亏=数量 *(入场价-市价) | ||
未结盈亏回报率 = 未结盈亏/初始保证金 | ||
#### 止盈止损百分比对应价格 | ||
止盈百分比对应价格 = 未结盈亏/委托成本 = 数量 * (价格 - X)/委托成本 | ||
止损百分比对应价格 = 未结盈亏/委托成本 = 数量 * (X - 价格)/委托成本 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
## 正向公式 | ||
|
||
#### 开仓价格 | ||
|
||
开仓价格 = 合约总 USDT 价值/总合约数量 = (数量 1*价格 1 + 数量 1*价格 1 + ...)/总合约数量 | ||
|
||
## 逐仓 | ||
|
||
### 做多 | ||
|
||
#### 仓位价值 | ||
|
||
仓位价值 = 数量 * 价格 | ||
|
||
#### 开仓手续费 | ||
|
||
开仓手续费 = 数量*价格*0.00075 | ||
|
||
#### 委托成本 | ||
|
||
委托成本=初始保证金+开仓手续费+平仓手续费 | ||
|
||
#### 初始保证金 | ||
|
||
初始保证金 = 数量*价格/杠杆 | ||
|
||
#### 平仓手续费 | ||
|
||
平仓手续费 = 数量*价格*(杠杆-1)/杠杆 * 0.00075 | ||
|
||
#### 仓位保证金 | ||
|
||
仓位保证金=初始保证金+平仓手续费+EAM | ||
|
||
#### 维持保证金 | ||
|
||
维持保证金 = 数量 * 价格 * 0.005 | ||
|
||
#### 破产价 | ||
|
||
破产价 = (仓位价值 - 仓位保证金) / (1 - 0.00075) / 数量 | ||
|
||
#### 强平价 | ||
|
||
强平价 = (仓位价值 - 仓位保证金 + 平仓手续费 + 维持保证金) / 数量 | ||
|
||
#### 未结盈亏 | ||
|
||
未结盈亏=数量 *(入场价-市价) | ||
未结盈亏回报率 = 未结盈亏 / 初始保证金 | ||
|
||
#### 止盈止损百分比对应价格 | ||
止盈百分比对应价格 = 未结盈亏/委托成本 = 数量 * (X - 价格)/委托成本 | ||
止损百分比对应价格 = 未结盈亏/委托成本 = 数量 * (价格 - X)/委托成本 | ||
|
||
#### 做空 | ||
#### 仓位价值 | ||
#### 初始保证金 | ||
#### 开仓手续费 | ||
#### 平仓手续费 | ||
平仓手续费 = 数量*价格*(杠杆 + 1)/杠杆 * 0.00075 | ||
#### 委托成本 | ||
#### 维持保证金 | ||
#### 仓位保证金 | ||
#### 破产价 | ||
破产价 = (仓位价值 + 仓位保证金) / (1 + 0.00075) / 数量 | ||
#### 强平价 | ||
强平价 = (仓位价值 + 仓位保证金 - 平仓手续费 - 维持保证金) / 数量 | ||
#### 未结盈亏 | ||
未结盈亏=数量*(入场价-市价) | ||
未结盈亏回报率 = 未结盈亏/初始保证金 | ||
#### 止盈止损百分比对应价格 | ||
止盈百分比对应价格 = 未结盈亏/委托成本 = 数量 * (价格 - X)/委托成本 | ||
止损百分比对应价格 = 未结盈亏/委托成本 = 数量 * (X - 价格)/委托成本 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
## 正向公式 | ||
|
||
#### 开仓价格 | ||
|
||
开仓价格 = 合约总 USDT 价值/总合约数量 = (数量 1*价格 1 + 数量 1*价格 1 + ...)/总合约数量 | ||
|
||
## 全仓 | ||
|
||
### 做多 | ||
|
||
#### 仓位价值 | ||
|
||
仓位价值 = 数量 * 价格 | ||
|
||
#### 开仓手续费 | ||
|
||
开仓手续费 = 数量*价格*0.00075 | ||
|
||
#### 委托成本 | ||
|
||
委托成本=初始保证金+开仓手续费+平仓手续费 | ||
|
||
#### 初始保证金 | ||
|
||
初始保证金 = 数量*价格/杠杆 | ||
|
||
#### 平仓手续费 | ||
|
||
平仓手续费 = 数量*价格*(杠杆-1)/杠杆 * 0.00075 | ||
|
||
#### 仓位保证金 | ||
|
||
仓位保证金=初始保证金+平仓手续费+AB | ||
|
||
#### 维持保证金 | ||
|
||
维持保证金 = 数量 * 价格 * 0.005 | ||
|
||
#### 破产价 | ||
|
||
破产价 = (仓位价值 - 仓位保证金) / (1 - 0.00075) / 数量 | ||
|
||
#### 强平价 | ||
|
||
强平价 = (仓位价值 - 仓位保证金 + 平仓手续费 + 维持保证金) / 数量 | ||
|
||
#### 未结盈亏 | ||
|
||
未结盈亏=数量 *(市价 - 入场价) | ||
未结盈亏回报率 = 未结盈亏 / 初始保证金 | ||
|
||
#### 止盈止损百分比对应价格 | ||
止盈百分比对应价格 = 未结盈亏/委托成本 = 数量 * (X - 价格)/委托成本 | ||
止损百分比对应价格 = 未结盈亏/委托成本 = 数量 * (价格 - X)/委托成本 | ||
|
||
#### 做空 | ||
#### 仓位价值 | ||
#### 初始保证金 | ||
#### 开仓手续费 | ||
#### 平仓手续费 | ||
平仓手续费 = 数量*价格*(杠杆 + 1)/杠杆 * 0.00075 | ||
#### 委托成本 | ||
#### 维持保证金 | ||
#### 仓位保证金 | ||
#### 破产价 | ||
破产价 = (仓位价值 + 仓位保证金) / (1 + 0.00075) / 数量 | ||
#### 强平价 | ||
强平价 = (仓位价值 + 仓位保证金 - 平仓手续费 - 维持保证金) / 数量 | ||
#### 未结盈亏 | ||
未结盈亏=数量 *(入场价-市价) | ||
未结盈亏回报率 = 未结盈亏/初始保证金 | ||
#### 止盈止损百分比对应价格 | ||
止盈百分比对应价格 = 未结盈亏/委托成本 = 数量 * (价格 - X)/委托成本 | ||
止损百分比对应价格 = 未结盈亏/委托成本 = 数量 * (X - 价格)/委托成本 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
## 正向公式 | ||
|
||
#### 开仓价格 | ||
|
||
开仓价格 = 合约总 USDT 价值/总合约数量 = (数量 1*价格 1 + 数量 1*价格 1 + ...)/总合约数量 | ||
|
||
## 逐仓 | ||
|
||
### 做多 | ||
|
||
#### 仓位价值 | ||
|
||
仓位价值 = 数量 * 价格 | ||
|
||
#### 开仓手续费 | ||
|
||
开仓手续费 = 数量*价格*0.00075 | ||
|
||
#### 委托成本 | ||
|
||
委托成本=初始保证金+开仓手续费+平仓手续费 | ||
|
||
#### 初始保证金 | ||
|
||
初始保证金 = 数量*价格/杠杆 | ||
|
||
#### 平仓手续费 | ||
|
||
平仓手续费 = 数量*价格*(杠杆-1)/杠杆 * 0.00075 | ||
|
||
#### 仓位保证金 | ||
|
||
仓位保证金=初始保证金+平仓手续费+EAM | ||
|
||
#### 维持保证金 | ||
|
||
维持保证金 = 数量 * 价格 * 0.005 | ||
|
||
#### 破产价 | ||
|
||
破产价 = (仓位价值 - 仓位保证金) / (1 - 0.00075) / 数量 | ||
|
||
#### 强平价 | ||
|
||
强平价 = (仓位价值 - 仓位保证金 + 平仓手续费 + 维持保证金) / 数量 | ||
|
||
#### 未结盈亏 | ||
|
||
未结盈亏=数量 *(入场价-市价) | ||
未结盈亏回报率 = 未结盈亏 / 初始保证金 | ||
|
||
#### 止盈止损百分比对应价格 | ||
止盈百分比对应价格 = 未结盈亏/委托成本 = 数量 * (X - 价格)/委托成本 | ||
止损百分比对应价格 = 未结盈亏/委托成本 = 数量 * (价格 - X)/委托成本 | ||
|
||
#### 做空 | ||
#### 仓位价值 | ||
#### 初始保证金 | ||
#### 开仓手续费 | ||
#### 平仓手续费 | ||
平仓手续费 = 数量*价格*(杠杆 + 1)/杠杆 * 0.00075 | ||
#### 委托成本 | ||
#### 维持保证金 | ||
#### 仓位保证金 | ||
#### 破产价 | ||
破产价 = (仓位价值 + 仓位保证金) / (1 + 0.00075) / 数量 | ||
#### 强平价 | ||
强平价 = (仓位价值 + 仓位保证金 - 平仓手续费 - 维持保证金) / 数量 | ||
#### 未结盈亏 | ||
未结盈亏=数量*(入场价-市价) | ||
未结盈亏回报率 = 未结盈亏/初始保证金 | ||
#### 止盈止损百分比对应价格 | ||
止盈百分比对应价格 = 未结盈亏/委托成本 = 数量 * (价格 - X)/委托成本 | ||
止损百分比对应价格 = 未结盈亏/委托成本 = 数量 * (X - 价格)/委托成本 |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// 对于给定的二叉树,判断是否存在一条完整路径(从根节点开始,到叶节点结束的连线),其路径上节点的值之和为target,输出布尔值。 | ||
// **举例:下面的树,是否存在一条完整路径,该路径上各个节点之和target=7? | ||
|
||
(() => { | ||
//用多维数组代表题中示例的树,这个数组是按“前序遍历”后排序 | ||
let arrSouce = [6, [2, [-1], [3]], [3, [0]]]; | ||
|
||
/** | ||
* 定义二叉树的结点。根结点和树的数据结构一样, | ||
* 因此只需要定义一个结点(Node)的数据结构即可 | ||
*/ | ||
class Node { | ||
/** | ||
* 构造函数 | ||
* @param {Number} value 当前结点的值 | ||
* @param {Node} left 左子结点 | ||
* @param {Node} right 右子结点 | ||
*/ | ||
constructor(value, left, right) { | ||
if (value != undefined) { | ||
this.value = value; | ||
if (left != undefined) this.left = left; | ||
if (right != undefined) this.right = right; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* 创建一个树 | ||
* @param {Array} arr 一个代表二叉树的多维数组 | ||
*/ | ||
function makeBTree(arr) { | ||
if (arr) { | ||
if (arr.length == 1) { | ||
return new Node(arr[0]); | ||
} | ||
//递归,创建二叉树 | ||
return new Node(arr[0], makeBTree(arr[1]), makeBTree(arr[2])); | ||
} | ||
} | ||
|
||
//创建示例中的二叉树,简洁多了! | ||
let bTree = makeBTree(arrSouce); | ||
|
||
/** | ||
* 主逻辑函数,与第一种解法里代码一样 | ||
* @param {Node} node 树的结点 | ||
* @param {Number} target 题目要求的目标值 | ||
*/ | ||
function hasPathSum(node, target) { | ||
//若根节点无子结点 | ||
if (!node.left && !node.right) { | ||
//直接判断根结点额值是否等于target | ||
return node.value == target; | ||
} | ||
//若有子结点 | ||
else { | ||
//如有左结点 左侧递归 | ||
if (!!node.left) | ||
return hasPathSum(node.left, /*关键*/ target - node.value); | ||
//如有右结点 右侧递归 | ||
if (!!node.right) | ||
return hasPathSum(node.right, /*关键*/ target - node.value); | ||
} | ||
} | ||
|
||
console.log(hasPathSum(bTree, 7)); //>> true | ||
})(); | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
1. 某 div 不设置宽度,那么 width 默认为 auto. | ||
2. 某子元素 div 的 width 为 100%(或者设置为等于父元素宽度的具体值,比如父元素 width 为 100px, | ||
子元素 width 也设置为 100px),则此子元素的宽度 = 父元素 width 值(不包括父元素边框,内边距)+子元素的边框、内边距宽度 | ||
3. 某个 div 的 width 不设置,或者设置为 auto, 子元素的宽度会包含在父元素内,子元素边框、内边距都在不会叠加到子元素的长度上 |
Oops, something went wrong.