Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Sara / Updated dependency packages #3504

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated devdependecy packages part6 & fixed eslint errors
  • Loading branch information
sara-fs committed Jan 9, 2022
commit 01987dfb42fef7a229f818abf800bad9a4de4e9c
5 changes: 3 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
},
"requireConfigFile": false
},
"extends": [
"binary",
Expand Down
7,362 changes: 2,247 additions & 5,115 deletions package-lock.json

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"devDependencies": {
"@babel/cli": "^7.16.7",
"@babel/core": "^7.16.7",
"@babel/eslint-parser": "^7.16.5",
"@babel/plugin-proposal-class-properties": "^7.16.7",
"@babel/plugin-proposal-object-rest-spread": "^7.16.7",
"@babel/polyfill": "^7.4.4",
Expand All @@ -47,7 +48,7 @@
"app-module-path": "^2.2.0",
"babel-core": "^6.26.3",
"babel-eslint": "^10.0.1",
"babel-jest": "^27.4.5",
"babel-jest": "^27.4.6",
"babel-loader": "^8.2.3",
"binary-live-api": "^29.0.1",
"binary-utils": "^4.23.0",
Expand All @@ -56,13 +57,13 @@
"deep-diff": "^1.0.2",
"del": "^4.1.1",
"es6-plato": "^1.2.2",
"eslint": "^4.14.0",
"eslint-config-airbnb": "^16.1.0",
"eslint": "^8.6.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-binary": "^1.0.2",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.5.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.28.0",
"file-saver": "^2.0.2",
"gulp": "^4.0.2",
"gulp-clean-css": "^4.3.0",
Expand All @@ -80,7 +81,7 @@
"husky": "^7.0.4",
"i18next-scanner": "^2.9.2",
"immutable": "^4.0.0",
"jest": "^27.4.5",
"jest": "^27.4.6",
"jquery": "^3.6.0",
"jquery-ui": "^1.13.0",
"jquery-ui-css": "^1.11.5",
Expand All @@ -99,7 +100,7 @@
"redux": "^4.1.2",
"redux-thunk": "^2.4.1",
"sha1": "^1.1.1",
"trackjs": "^3.10.1",
"trackjs": "^2.13.0",
"vinyl-paths": "^2.1.0",
"webpack": "^3.12.0",
"webpack-cli": "^4.9.1",
Expand Down
2 changes: 2 additions & 0 deletions src/botPage/bot/CliTools.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* eslint-disable */
import Observer from '../../common/utils/observer';
import Interpreter from './Interpreter';
import TicksService from '../common/TicksService';
import { generateLiveApiInstance } from '../../common/appId';
/* eslint-enable */

export const createScope = () => {
const observer = new Observer();
Expand Down
1 change: 1 addition & 0 deletions src/botPage/bot/Interface/IndicatorsInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default Interface =>
macda: (input, config, field) => this.decorate(macda, input, config).map(r => r[field]),
};
}

decorate(f, input, config, ...args) {
const pipSize = this.tradeEngine.getPipSize();

Expand Down
9 changes: 9 additions & 0 deletions src/botPage/bot/Interface/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
/* eslint-disable */
import TradeEngine from '../TradeEngine';
import { noop, createDetails } from '../tools';
import TicksInterface from './TicksInterface';
import ToolsInterface from './ToolsInterface';
/* eslint-enable */

/**
* Bot - Bot Module
* @namespace Bot
*/

/* eslint-disable no-promise-executor-return */
export default class Interface extends ToolsInterface(TicksInterface(class {})) {
constructor($scope) {
super();
Expand All @@ -16,6 +19,7 @@ export default class Interface extends ToolsInterface(TicksInterface(class {}))
this.observer = $scope.observer;
this.$scope = $scope;
}

getInterface(name = 'Global') {
if (name === 'Bot') {
return {
Expand All @@ -36,6 +40,7 @@ export default class Interface extends ToolsInterface(TicksInterface(class {}))
},
};
}

getBotInterface() {
const getDetail = (i, pipSize) => createDetails(this.tradeEngine.data.contract, pipSize)[i];

Expand All @@ -54,6 +59,7 @@ export default class Interface extends ToolsInterface(TicksInterface(class {}))
readDetails : i => getDetail(i - 1, this.tradeEngine.getPipSize()),
};
}

sleep(arg = 1) {
return new Promise(
r =>
Expand All @@ -64,14 +70,17 @@ export default class Interface extends ToolsInterface(TicksInterface(class {}))
noop
);
}

getProposal(contractType) {
return this.tradeEngine.data.proposals.find(
proposal =>
proposal.contractType === contractType &&
proposal.purchaseReference === this.tradeEngine.getPurchaseReference()
);
}

getSellPrice() {
return this.tradeEngine.getSellPrice();
}
}
/* eslint-enable no-promise-executor-return */
10 changes: 10 additions & 0 deletions src/botPage/bot/Interpreter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import JSInterpreter from 'js-interpreter';
/* eslint-disable */
import { createScope } from './CliTools';
/* eslint-enable */
import Interface from './Interface';
import { clone } from '../common/clone';
import { observer as globalObserver } from '../../common/utils/observer';
Expand Down Expand Up @@ -48,6 +50,7 @@ export default class Interpreter {
constructor() {
this.init();
}

init() {
this.$scope = createScope();
this.bot = new Interface(this.$scope);
Expand All @@ -56,6 +59,7 @@ export default class Interpreter {
this.revert(watchName === 'before' ? this.beforeState : this.duringState)
);
}

run(code) {
const initFunc = (interpreter, scope) => {
const botInterface = this.bot.getInterface('Bot');
Expand Down Expand Up @@ -160,17 +164,20 @@ export default class Interpreter {
this.loop();
});
}

loop() {
if (this.stopped || !this.interpreter.run()) {
this.onFinish(this.interpreter.pseudoToNative(this.interpreter.value));
}
}

revert(state) {
this.interpreter.restoreStateSnapshot(state);
// eslint-disable-next-line no-underscore-dangle
this.interpreter.paused_ = false;
this.loop();
}

terminateSession() {
const { socket } = this.$scope.api;
if (socket.readyState === 0) {
Expand All @@ -186,6 +193,7 @@ export default class Interpreter {
globalObserver.emit('bot.stop');
globalObserver.setState({ isRunning: false });
}

stop() {
if (this.bot.tradeEngine.isSold === false && !this.isErrorTriggered) {
globalObserver.register('contract.status', contractStatus => {
Expand All @@ -198,6 +206,7 @@ export default class Interpreter {
this.terminateSession();
}
}

createAsync(interpreter, func) {
const asyncFunc = (...args) => {
const callback = args.pop();
Expand Down Expand Up @@ -225,6 +234,7 @@ export default class Interpreter {
Object.defineProperty(asyncFunc, 'length', { value: MAX_ACCEPTABLE_FUNC_ARGS + 1 });
return interpreter.createAsyncFunction(asyncFunc);
}

hasStarted() {
return !this.stopped;
}
Expand Down
1 change: 1 addition & 0 deletions src/botPage/bot/TradeEngine/Balance.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default Engine =>
info({ accountID: this.accountInfo.loginid, balance: balanceStr });
});
}

// eslint-disable-next-line class-methods-use-this
getBalance(type) {
const balance = globalObserver.getState('balance');
Expand Down
7 changes: 7 additions & 0 deletions src/botPage/bot/TradeEngine/OpenContract.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ export default Engine =>
}
});
}

waitForAfter() {
return new Promise(resolve => {
this.afterPromise = resolve;
});
}

subscribeToOpenContract(contractId = this.contractId) {
if (this.contractId !== contractId) {
this.resetSubscriptionTimeout();
Expand All @@ -66,16 +68,19 @@ export default Engine =>
observer.emit('Error', error);
});
}

resetSubscriptionTimeout(timeout = this.getContractDuration() + AFTER_FINISH_TIMEOUT) {
this.cancelSubscriptionTimeout();
this.subscriptionTimeout = setInterval(() => {
this.subscribeToOpenContract();
this.resetSubscriptionTimeout(timeout);
}, timeout * 1000);
}

cancelSubscriptionTimeout() {
clearTimeout(this.subscriptionTimeout);
}

setContractFlags(contract) {
const {
is_expired: isExpired,
Expand All @@ -92,9 +97,11 @@ export default Engine =>

this.hasEntryTick = Boolean(entryTick);
}

expectedContractId(contractId) {
return this.contractId && contractId === this.contractId;
}

getSellPrice() {
const { bid_price: bidPrice, buy_price: buyPrice, currency } = this.data.contract;
return Number(roundBalance({ currency, balance: Number(bidPrice) - Number(buyPrice) }));
Expand Down
8 changes: 8 additions & 0 deletions src/botPage/bot/TradeEngine/Proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default Engine =>
this.proposalTemplates = tradeOptionToProposal(tradeOption, this.getPurchaseReference());
this.renewProposalsOnPurchase();
}

selectProposal(contractType) {
const { proposals } = this.data;

Expand Down Expand Up @@ -58,13 +59,16 @@ export default Engine =>
currency: this.tradeOption.currency,
};
}

renewProposalsOnPurchase() {
this.unsubscribeProposals().then(() => this.requestProposals());
}

clearProposals() {
this.data.proposals = [];
this.store.dispatch(clearProposals());
}

requestProposals() {
Promise.all(
this.proposalTemplates.map(proposal =>
Expand All @@ -88,6 +92,7 @@ export default Engine =>
)
).catch(e => this.$scope.observer.emit('Error', e));
}

observeProposals() {
this.listen('proposal', response => {
const { passthrough, proposal } = response;
Expand All @@ -102,6 +107,7 @@ export default Engine =>
}
});
}

unsubscribeProposals() {
const { proposals } = this.data;
const removeForgetProposalById = forgetProposalId => {
Expand All @@ -127,6 +133,7 @@ export default Engine =>
})
);
}

checkProposalReady() {
// Proposals are considered ready when the proposals in our memory match the ones
// we've requested from the API, we determine this by checking the passthrough of the response.
Expand All @@ -147,6 +154,7 @@ export default Engine =>
}
}
}

isNewTradeOption(tradeOption) {
if (!this.tradeOption) {
this.tradeOption = tradeOption;
Expand Down
5 changes: 5 additions & 0 deletions src/botPage/bot/TradeEngine/Purchase.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,13 @@ export default Engine =>
delayIndex++
).then(onSuccess);
}

/* eslint-disable */
getPurchaseReference = () => purchaseReference;


regeneratePurchaseReference = () => {
purchaseReference = getUUID();
};
/* eslint-enable */
};
1 change: 1 addition & 0 deletions src/botPage/bot/TradeEngine/Sell.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default Engine =>
isSellAtMarketAvailable() {
return this.contractId && !this.isSold && this.isSellAvailable && !this.isExpired;
}

sellAtMarket() {
// Prevent calling sell twice
if (this.store.getState().scope !== DURING_PURCHASE) {
Expand Down
Loading
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