Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 17 additions & 3 deletions www/js/pages/transaction-detail/transaction-detail.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,20 @@
function TransactionDetail($scope, $timeout, appStateService, websocketService) {
const vm = this;
vm.currency = sessionStorage.getItem("currency");
vm.fractionalLength = 2;
const activeSymbols = JSON.parse(sessionStorage.getItem("all_active_symbols"));
const id = sessionStorage.getItem("id");
const contractId = parseInt(id);
const extraParams = {
req_id: contractId
};

const getFractionalLength = (floatNumber) => {
const stringNumber = floatNumber.toString();
const decimalLength = stringNumber.indexOf(".");
return stringNumber.length - decimalLength - 1;
};

const sendDetailsRequest = () => {
if (appStateService.isLoggedin) {
websocketService.sendRequestFor.openContract(id, extraParams);
Expand All @@ -32,10 +41,15 @@
$scope.$on("proposal:open-contract", (e, proposal_open_contract, req_id) => {
const proposalOpenContract = proposal_open_contract;
const reqId = req_id;

if (reqId === contractId) {
$scope.$applyAsync(() => {
vm.contract = proposalOpenContract;
});
const activeSymbol =
activeSymbols.find((activeSymbol) => activeSymbol.symbol === proposalOpenContract.underlying);
const pip = activeSymbol.pip || 0.01;
vm.fractionalLength = getFractionalLength(pip);
vm.contract = proposalOpenContract;
$scope.$apply();

}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ <h1 class="reference">
<li class="list" ng-if="vm.contract.entry_spot">
<ul class="statement-list">
<li class="statement-element">{{'transaction-details.entry_spot' | translate}}</li>
<li class="statement-element last-statement-element right">{{vm.contract.entry_spot}}</li>
<li class="statement-element last-statement-element right"
ng-bind="vm.contract.entry_spot | number : vm.fractionalLength"></li>
</ul>
</li>
<li class="list" ng-if="vm.contract.barrier">
Expand All @@ -87,7 +88,9 @@ <h1 class="reference">
<li class="list" ng-if="vm.contract.exit_tick">
<ul class="statement-list">
<li class="statement-element">{{'transaction-details.exit_spot' | translate}}</li>
<li class="statement-element last-statement-element right">{{vm.contract.exit_tick}}</li>
<li class="statement-element last-statement-element right"
ng-bind="vm.contract.exit_tick | number : vm.fractionalLength">
</li>
</ul>
</li>
<li class="list" ng-if="vm.contract.exit_tick_time">
Expand Down
29 changes: 21 additions & 8 deletions www/js/share/services/chart.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,13 @@ angular.module("binary").factory("chartService", $rootScope => {
let historyData = [];

const addTick = function addTick(tick) {
const options = JSON.parse(localStorage.options);
const pip = options.underlying.pip;
const fractionalLength = utils.fractionalLength(pip);
if (parseInt(tick.epoch) > parseInt(historyData.slice(-1)[0].time)) {
historyData.push({
time : tick.epoch,
price: tick.quote
price: parseFloat(tick.quote).toFixed(fractionalLength)
});
historyData.shift();
}
Expand Down Expand Up @@ -500,33 +503,43 @@ angular.module("binary").factory("chartService", $rootScope => {
};

const addRegions = function addRegions(lastTime, lastPrice) {
const options = JSON.parse(localStorage.options);
const pip = options.underlying.pip;
const fractionalLength = utils.fractionalLength(pip);

if (hasEntrySpot() && broadcastable) {
if (tickPriceList.length === 0) {
if (contract.entrySpotTime !== lastTime && betweenExistingSpots(lastTime)) {
tickPriceList.push(parseFloat(contract.entrySpotPrice));
if (utils.conditions[contract.type](contract.barrier, contract.entrySpotPrice,
const entrySpotPrice = parseFloat(contract.entrySpotPrice).toFixed(fractionalLength);
const barrier = parseFloat(contract.barrier).toFixed(fractionalLength);
tickPriceList.push(entrySpotPrice);

if (utils.conditions[contract.type](barrier, entrySpotPrice,
tickPriceList, contract.selectedTick)) {
contract.result = "win";
} else {
contract.result = "lose";
}
$rootScope.$broadcast("contract:spot", contract, contract.entrySpotPrice);
$rootScope.$broadcast("contract:spot", contract, entrySpotPrice);
} else {
tickPriceList.push(parseFloat(lastPrice));
tickPriceList.push(parseFloat(lastPrice).toFixed(fractionalLength));
}
} else {
tickPriceList.push(parseFloat(lastPrice));
tickPriceList.push(parseFloat(lastPrice).toFixed(fractionalLength));
}

if (betweenExistingSpots(lastTime)) {
if (utils.conditions[contract.type](contract.barrier, lastPrice,
const barrier = parseFloat(contract.barrier).toFixed(fractionalLength);
const lastPriceFloat = parseFloat(lastPrice).toFixed(fractionalLength);

if (utils.conditions[contract.type](barrier, lastPriceFloat,
tickPriceList, contract.selectedTick)) {
contract.result = "win";
} else {
contract.result = "lose";
}

$rootScope.$broadcast("contract:spot", contract, lastPrice);
$rootScope.$broadcast("contract:spot", contract, lastPriceFloat);

if (isFinished() && broadcastable) {
tickPriceList = [];
Expand Down