Skip to content

Commit 9ae9ced

Browse files
author
Aaron
authored
Merge branch 'dev' into webhook-blocks
2 parents a489b80 + 99490d1 commit 9ae9ced

File tree

42 files changed

+2093
-421
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2093
-421
lines changed

.github/stale.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Configuration for probot-stale - https://github.com/probot/stale
2+
3+
# Limit to only `issues`
4+
only: issues
5+
6+
# Number of days of inactivity before an Issue or Pull Request is closed.
7+
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
8+
daysUntilClose: 14
9+
10+
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
11+
exemptLabels:
12+
- bug
13+
- "technical issues"
14+
- "feature request"
15+
16+
17+
# Label to use when marking an issue as stale
18+
staleLabel: stale
19+
20+
# Comment to post when marking as stale. Set to `false` to disable
21+
markComment: false
22+
23+
# Comment to post when closing a stale Issue or Pull Request.
24+
closeComment: >
25+
This issue has been automatically closed since there has not been
26+
any recent activity. Please open a new issue for related bugs.
27+
28+
# Limit the number of actions per hour, from 1-30. Default is 30
29+
limitPerRun: 30

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ install: npm ci
55
cache:
66
directories:
77
- node_modules
8+
script: travis_retry npm test

src/botPage/bot/Interface/MiscInterface.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export default Interface =>
2929
notifyTelegram: this.notifyTelegram,
3030
getTotalRuns : () => this.tradeEngine.getTotalRuns(),
3131
getBalance : type => this.tradeEngine.getBalance(type),
32-
getTotalProfit: () => this.tradeEngine.getTotalProfit(),
32+
getTotalProfit: toString =>
33+
this.tradeEngine.getTotalProfit(toString, this.tradeEngine.tradeOptions.currency),
3334
};
3435
}
3536
};

src/botPage/bot/Interface/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default class Interface extends ToolsInterface(TicksInterface(class {}))
3737
};
3838
}
3939
getBotInterface() {
40-
const getDetail = i => createDetails(this.get('contract'))[i];
40+
const getDetail = (i, pipSize) => createDetails(this.get('contract'), pipSize)[i];
4141

4242
return {
4343
init : (...args) => this.tradeEngine.init(...args),
@@ -50,7 +50,7 @@ export default class Interface extends ToolsInterface(TicksInterface(class {}))
5050
sellAtMarket : () => this.tradeEngine.sellAtMarket(),
5151
getSellPrice : () => this.getSellPrice(),
5252
isResult : result => getDetail(10) === result,
53-
readDetails : i => getDetail(i - 1),
53+
readDetails : i => getDetail(i - 1, this.tradeEngine.getPipSize()),
5454
};
5555
}
5656
sleep(arg = 1) {

src/botPage/bot/Interpreter.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,10 @@ export default class Interpreter {
149149
}
150150
terminateSession() {
151151
this.$scope.api.disconnect();
152-
globalObserver.emit('bot.stop');
153152
this.stopped = true;
153+
154+
globalObserver.emit('bot.stop');
155+
globalObserver.setState({ isRunning: false });
154156
}
155157
stop() {
156158
if (this.bot.tradeEngine.isSold === false && !this.isErrorTriggered) {

src/botPage/bot/TradeEngine/Ticks.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,30 @@ export default Engine =>
3131
tickListenerKey = key;
3232
}
3333
}
34-
getTicks() {
35-
return new Promise(resolve =>
36-
this.$scope.ticksService
37-
.request({ symbol: this.symbol })
38-
.then(ticks => resolve(ticks.map(o => o.quote)))
39-
);
34+
getTicks(toString = false) {
35+
return new Promise(resolve => {
36+
this.$scope.ticksService.request({ symbol: this.symbol }).then(ticks => {
37+
const pipSize = this.getPipSize();
38+
const ticksList = ticks.map(o => {
39+
if (toString) {
40+
return o.quote.toFixed(pipSize);
41+
}
42+
return o.quote;
43+
});
44+
45+
resolve(ticksList);
46+
});
47+
});
4048
}
41-
getLastTick(raw) {
49+
getLastTick(raw, toString = false) {
4250
return new Promise(resolve =>
43-
this.$scope.ticksService
44-
.request({ symbol: this.symbol })
45-
.then(ticks => resolve(raw ? getLast(ticks) : getLast(ticks).quote))
51+
this.$scope.ticksService.request({ symbol: this.symbol }).then(ticks => {
52+
let lastTick = raw ? getLast(ticks) : getLast(ticks).quote;
53+
if (toString && !raw) {
54+
lastTick = lastTick.toFixed(this.getPipSize());
55+
}
56+
resolve(lastTick);
57+
})
4658
);
4759
}
4860
getLastDigit() {

src/botPage/bot/TradeEngine/Total.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,14 @@ export default Engine =>
8686
const accountStat = this.getAccountStat();
8787
return accountStat.totalRuns;
8888
}
89-
getTotalProfit() {
89+
getTotalProfit(toString, currency) {
9090
const accountStat = this.getAccountStat();
91-
return Number(accountStat.totalProfit);
91+
return toString && accountStat.totalProfit !== 0
92+
? roundBalance({
93+
currency,
94+
balance: +accountStat.totalProfit,
95+
})
96+
: +accountStat.totalProfit;
9297
}
9398
/* eslint-enable */
9499
checkLimits(tradeOption) {

src/botPage/bot/TradeEngine/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export default class TradeEngine extends Balance(Purchase(Sell(OpenContract(Prop
9292
}
9393

9494
globalObserver.emit('bot.running');
95+
globalObserver.setState({ isRunning: true });
9596

9697
this.tradeOptions = expectTradeOptions(tradeOptions);
9798

src/botPage/bot/__tests__/block-tests/tools-test/Misc.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('Misc. tools', () => {
1717
Bot.notify({ message: 'Test', className: 'info'})
1818
watch('before')
1919
result.totalRuns = Bot.getTotalRuns();
20-
result.totalProfit = Bot.getTotalProfit();
20+
result.totalProfit = Bot.getTotalProfit(false, null);
2121
result.balance = Bot.getBalance('NUM')
2222
result.balanceStr = Bot.getBalance('STR')
2323
`
@@ -47,7 +47,9 @@ describe('Misc. tools', () => {
4747
});
4848

4949
it('Notify', () => {
50-
const { notify: { className, message } } = observed;
50+
const {
51+
notify: { className, message },
52+
} = observed;
5153

5254
expect(className).equal('info');
5355
expect(message).equal('Test');

src/botPage/bot/tools.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export const doUntilDone = (f, types) => {
134134
});
135135
};
136136

137-
export const createDetails = contract => {
137+
export const createDetails = (contract, pipSize) => {
138138
const { sell_price: sellPrice, buy_price: buyPrice, currency } = contract;
139139
const profit = Number(roundBalance({ currency, balance: sellPrice - buyPrice }));
140140
const result = profit < 0 ? 'loss' : 'win';
@@ -151,6 +151,8 @@ export const createDetails = contract => {
151151
+contract.exit_tick,
152152
+(contract.barrier ? contract.barrier : 0),
153153
result,
154+
(+contract.entry_tick).toFixed(pipSize),
155+
(+contract.exit_tick).toFixed(pipSize),
154156
];
155157
};
156158

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy