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
21 changes: 0 additions & 21 deletions www/js/pages/trade/components/chart/chart.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,6 @@
chartService.destroy();
});

$scope.$on("portfolio", (e, portfolio) => {
const contractId = vm.purchasedContract.contractId;

if ((typeof contractId === "string" && !_.isEmpty(contractId)) || contractId) {
portfolio.contracts.forEach(contract => {
if ((typeof contractId === "string" && contract.contract_id.toString() === contractId) || contract.contract_id === contractId) {
chartService.addContract({
startTime: contract.date_start + 1,
duration : parseInt(vm.proposal.duration),
type :
vm.proposal.tradeType === "Higher/Lower"
? `${contract.contract_type}HL`
: contract.contract_type,
selectedTick: vm.proposal.tradeType === "High/Low Ticks" ? vm.proposal.selected_tick : null,
barrier : vm.proposal.barrier
});
}
});
}
});

$scope.$on("tick", (e, feed) => {
if (feed && feed.echo_req.ticks_history === vm.proposal.symbol) {
chartService.historyInterface.addTick(feed.tick);
Expand Down
35 changes: 26 additions & 9 deletions www/js/pages/trade/components/purchase/purchase.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"appStateService",
"proposalService",
"websocketService",
"chartService",
"$ionicLoading"
];

Expand All @@ -27,6 +28,7 @@
appStateService,
proposalService,
websocketService,
chartService,
$ionicLoading) {
const vm = this;
let forgetRequestId = 0;
Expand All @@ -39,6 +41,7 @@
vm.purchasedContractIndex = -1;
vm.currencyType = "fiat";
vm.isContractFinished = false;
vm.contractType = '';

$scope.$watch(
() => vm.proposal,
Expand Down Expand Up @@ -97,21 +100,32 @@
});

$scope.$on("purchase", (e, response) => {
const purchaseInfo = response.buy;

if (!_.isEmpty(response.buy)) {
vm.showSummary = true;
$scope.$applyAsync(() => {
vm.purchasedContract = {
contractId : response.buy.contract_id,
longcode : response.buy.longcode,
contractId : purchaseInfo.contract_id,
longcode : purchaseInfo.longcode,
payout : vm.proposalResponses[vm.purchasedContractIndex].payout,
cost : response.buy.buy_price,
balance : response.buy.balance_after,
transactionId: response.buy.transaction_id,
cost : purchaseInfo.buy_price,
balance : purchaseInfo.balance_after,
transactionId: purchaseInfo.transaction_id,
profit : parseFloat(vm.proposalResponses[vm.purchasedContractIndex].payout) -
parseFloat(response.buy.buy_price),
parseFloat(purchaseInfo.buy_price),
};
});
websocketService.sendRequestFor.portfolio();
chartService.addContract({
startTime: purchaseInfo.start_time + 1,
duration : parseInt(vm.proposal.duration),
type :
vm.proposal.tradeType === "Higher/Lower"
? `${vm.contractType}HL`
: vm.contractType,
selectedTick: vm.proposal.tradeType === "High/Low Ticks" ? vm.proposal.selected_tick : null,
barrier : vm.proposal.barrier
});
}
});

Expand Down Expand Up @@ -149,7 +163,7 @@
proposal.underlying_symbol,
vm.purchasedContract.payout
);

vm.isContractFinished = true;
sendProposal();
}
Expand Down Expand Up @@ -186,14 +200,17 @@
return `img/trade-icon/${contractType.toLowerCase()}.svg`;
};

vm.purchase = function (contractIndex) {
vm.purchase = function (contractIndex, contract_type) {
$scope.$applyAsync(() => {
vm.isContractFinished = false;
vm.inPurchaseMode = true;
vm.purchasedContractIndex = contractIndex;
appStateService.purchaseMode = true;
appStateService.tradeMode = false;
});
if (contract_type) {
vm.contractType = contract_type;
}
proposalService.purchase(vm.proposalResponses[contractIndex]);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</div>
<div class="row" ng-if="!vm.proposalResponses[$index].hasError">
<div class="col center">
<button class="button button-positive" ng-click="vm.purchase($index)"
<button class="button button-positive" ng-click="vm.purchase($index, contract.contract_type)"
ng-disabled="vm.inPurchaseMode || vm.proposalResponses[$index].isReceiving || vm.proposalResponses.length == 0"
disabled>
{{ "trade.buy" | translate}}
Expand Down
1 change: 1 addition & 0 deletions www/js/share/services/websocket.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ angular
buy : _proposalId,
price: price || 0
};

sendMessage(data);
},
balance() {
Expand Down