Skip to content

Commit 29c1689

Browse files
author
ETY001
committed
增加教程, 补上limit功能
1 parent 9ed673b commit 29c1689

7 files changed

Lines changed: 130 additions & 11 deletions

File tree

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
</head>
88
<body>
99
<div id="app"></div>
10+
<div style="display: none;"><script src="https://s13.cnzz.com/z_stat.php?id=1263028038&web_id=1263028038" language="JavaScript"></script></div>
1011
<script src="./static/stellar-sdk.min.js"></script>
1112
<!-- built files will be auto injected -->
1213
</body>

src/components/Home.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
</template>
179179

180180
<script>
181-
const version = 'v0.0.2'
181+
const version = 'v0.0.3'
182182
const intervalTime = 5
183183
const bookLimit = 30
184184
let assetNative = new StellarSdk.Asset.native()
@@ -442,6 +442,10 @@ export default {
442442
buyOrder (tag=false) {
443443
let buyOrderPrice = this.fixNum(1 / (this.buyPrice * (1 - this.buyRate / 100)), 7)
444444
let buyOrderAmount = this.fixNum(this.orderTotal, 7)
445+
if (parseFloat(this.myXLM) >= parseFloat(this.limitXLM / this.sellPrice)) {
446+
// 当持有的XLM多于XLM上限,则停止买入
447+
return
448+
}
445449
if (buyOrderAmount > this.myCNY) {
446450
if (tag === true) {
447451
this.sellOrder()
@@ -480,6 +484,10 @@ export default {
480484
sellOrder () {
481485
let sellOrderPrice = this.fixNum(this.sellPrice * (1 + this.sellRate / 100), 7)
482486
let sellOrderAmount = this.fixNum(this.orderTotal / sellOrderPrice, 7)
487+
if (parseFloat(this.myCNY) >= parseFloat(this.limitCNY)) {
488+
// 当前持有cny多于cny上限停止下卖单
489+
return
490+
}
483491
// console.log(sellOrderAmount)
484492
if (sellOrderAmount > this.myXLM) {
485493
return
@@ -563,7 +571,7 @@ export default {
563571
</script>
564572

565573
<!-- Add "scoped" attribute to limit CSS to this component only -->
566-
<style>
574+
<style scoped>
567575
.el-row {
568576
margin-top: 10px;
569577
}

src/components/TopNav.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<el-col :span="20" :offset="2">
44
<el-menu theme="dark" :default-active="activeIndex" :router="true" class="el-menu-demo" mode="horizontal" @select="handleSelect">
55
<el-menu-item index="/">首页</el-menu-item>
6-
<!--<el-menu-item index="setting">设置</el-menu-item>-->
6+
<el-menu-item index="tutorial">教程</el-menu-item>
77
</el-menu>
88
</el-col>
99
</el-row>
@@ -13,7 +13,7 @@
1313
export default {
1414
data () {
1515
return {
16-
activeIndex: '/'
16+
activeIndex: this.$route.name
1717
}
1818
},
1919
methods: {
@@ -22,7 +22,7 @@
2222
switch (key) {
2323
case '/':
2424
break
25-
case 'setting':
25+
case 'tutorial':
2626
break
2727
}
2828
}

src/components/Tutorial.vue

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<template>
2+
<el-row>
3+
<el-col :span="20" :offset="2">
4+
<div>
5+
<h1>
6+
<strong>教程</strong><br/>
7+
</h1>
8+
<p>
9+
机器人的目的就是为了增加市场的流动性。当前的算法就是以比当前价低x%的价格下买单,高y%的价格下卖单。
10+
</p>
11+
<p>
12+
<br/>
13+
</p>
14+
<ol class=" list-paddingleft-2" style="list-style-type: decimal;">
15+
<li>
16+
<p>
17+
第一次访问,需要增加你的钱包信息,具体如下图,
18+
</p>
19+
<p>
20+
<img src="/static/1.png" title="" alt="" width="500" height=""/>
21+
</p>
22+
<p>
23+
在『1』的位置是你的钱包地址,在『2』的位置是私钥,网关地址请使用RippleFox的网关,『GAREELUB43IRHWEASCFBLKHURCGMHE5IF6XSE7EXDLACYHGRHM43RFOX』。
24+
</p>
25+
</li>
26+
<li>
27+
<p>
28+
交易参数的设置可以参考下图
29+
</p>
30+
<p>
31+
<img src="/static/2.png" width="500" height="" title="" alt=""/>
32+
</p>
33+
<p>
34+
(1)图中『买入比』为2%,就是机器人自动下买单的价格是根据当前的『Buy Price』0.14925,降低2%下单,也就是 <em><b>0.14925 * (1 - 2%) = 0.146265</b></em>;
35+
</p>
36+
<p>
37+
(2)图中『卖出比』为2%,同上的道理,就是卖单价格为 <em><b>0.152 * (1 + 2%) = 0.15504</b></em>;
38+
</p>
39+
<p>
40+
(3)图中订单价值(CNY)为1,说明下单的时候,最后订单的价值为1CNY。比如图中的情况下买单,最后就是以 0.146265 的价格买入 6.8369 个 XLM,价值大约 1CNY,卖单的道理同买单;
41+
</p>
42+
<p>
43+
(4)图中CNY上限为100,代表当前还可以下卖单,因为当前拥有的CNY是 0.8017302 ,不足100,同理,XLM上限为100CNY,那么以现在的卖出的价格 0.152 来计算,上限是 <em><b>100 / 0.152 = 657.894737 XLM</b></em>,而当前拥有 8083.4478679 个XLM,所以不再下买单。
44+
</p>
45+
</li>
46+
<li>
47+
<p>
48+
设置完后,点击保存配置,然后手动刷新页面,就能看到已经可以读取到网关的交易数据了。点击『机器人状态』旁边的按钮,就可以启动机器人开始交易了。
49+
</p>
50+
</li>
51+
</ol>
52+
<p>
53+
<br/>
54+
</p>
55+
<p>
56+
<strong>其他注意事项:</strong>
57+
</p>
58+
<ol class=" list-paddingleft-2" style="list-style-type: decimal;">
59+
<li>
60+
<p>
61+
请尽量新开个钱包来使用机器人,<strong><br/></strong>
62+
</p>
63+
</li>
64+
<li>
65+
<p>
66+
当前功能仅在钱包只信任了RIppleFox网关下测试通过,并且只持有XLM和CNY。
67+
</p>
68+
</li>
69+
<li>
70+
<p>
71+
需要全程保持浏览器的这个页面是开着,机器人才会自动下单,
72+
</p>
73+
</li>
74+
<li>
75+
<p>
76+
仅在Chrome浏览器下测试,请优先使用Chrome。<br/>
77+
</p>
78+
</li>
79+
</ol>
80+
<p>
81+
<br/>
82+
</p>
83+
<p>
84+
如有疑问,通过Telegram可以找到我,<a href="https://t.me/ety001" target="_self">https://t.me/ety001</a>,&nbsp;或者微博:<a href="http://weibo.com/ety001">http://weibo.com/ety001</a>
85+
</p>
86+
<p>
87+
接受捐赠:恒星钱包地址为,<span style="color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 14px;">GCRF5BWQLVAEDIE4J25KJ5XKC3JI5XKPCT2BA7PZD7B2SW3LSPVX5ENC</span>。
88+
</p>
89+
<p>
90+
<br/>
91+
</p>
92+
</div>
93+
</el-col>
94+
</el-row>
95+
</template>
96+
<script>
97+
export default {
98+
name: 'tutorial',
99+
data () {
100+
return {
101+
}
102+
},
103+
mounted () {
104+
}
105+
}
106+
</script>
107+
108+
<!-- Add "scoped" attribute to limit CSS to this component only -->
109+
<style scoped>
110+
</style>

src/router/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Vue from 'vue'
22
import Router from 'vue-router'
33
import Home from '@/components/Home'
4-
// import Setting from '@/components/Setting'
4+
import Tutorial from '@/components/Tutorial'
55

66
Vue.use(Router)
77

@@ -11,11 +11,11 @@ export default new Router({
1111
path: '/',
1212
name: '/',
1313
component: Home
14+
},
15+
{
16+
path: '/tutorial',
17+
name: 'tutorial',
18+
component: Tutorial
1419
}
15-
// {
16-
// path: '/setting',
17-
// name: 'setting',
18-
// component: Setting
19-
// }
2020
]
2121
})

static/1.png

441 KB
Loading

static/2.png

136 KB
Loading

0 commit comments

Comments
 (0)