diff --git a/src/javascript/app/Constants/contract.js b/src/javascript/app/Constants/contract.js index 10b86200ff87..eda0cd7c26d2 100644 --- a/src/javascript/app/Constants/contract.js +++ b/src/javascript/app/Constants/contract.js @@ -1,6 +1,38 @@ import { localize } from '_common/localize'; -const getContractConfig = is_high_low => ({ +const getUnsupportedContracts = () => ({ + EXPIRYMISS: { + name : localize('Ends Outside'), + position: 'top', + }, + EXPIRYRANGE: { + name : localize('Ends Between'), + position: 'bottom', + }, + RANGE: { + name : localize('Stays Between'), + position: 'top', + }, + UPORDOWN: { + name : localize('Goes Outside'), + position: 'bottom', + }, + RESETCALL: { + name : localize('Reset Call'), + position: 'top', + }, + RESETPUT: { + name : localize('Reset Put'), + position: 'bottom', + }, + TICKHIGH: { + name : localize('High Tick'), + position: 'top', + }, + TICKLOW: { + name : localize('Low Tick'), + position: 'bottom', + }, ASIANU: { name : localize('Asian Up'), position: 'top', @@ -9,6 +41,37 @@ const getContractConfig = is_high_low => ({ name : localize('Asian Down'), position: 'bottom', }, + LBFLOATCALL: { + name : localize('Close-Low'), + position: 'top', + }, + LBFLOATPUT: { + name : localize('High-Close'), + position: 'top', + }, + LBHIGHLOW: { + name : localize('High-Low'), + position: 'top', + }, + CALLSPREAD: { + name : localize('Call Spread'), + position: 'top', + }, + PUTSPREAD: { + name : localize('Put Spread'), + position: 'bottom', + }, + RUNHIGH: { + name : localize('Only Ups'), + position: 'top', + }, + RUNLOW: { + name : localize('Only Downs'), + position: 'bottom', + }, +}); + +const getContractConfig = is_high_low => ({ CALL: { name : is_high_low ? localize('Higher') : localize('Rise'), position: 'top', @@ -49,38 +112,6 @@ const getContractConfig = is_high_low => ({ name : localize('Under'), position: 'bottom', }, - EXPIRYMISS: { - name : localize('Ends Outside'), - position: 'top', - }, - EXPIRYRANGE: { - name : localize('Ends Between'), - position: 'bottom', - }, - EXPIRYRANGEE: { - name : localize('Ends Between'), - position: 'top', - }, - LBFLOATCALL: { - name : localize('Close-Low'), - position: 'top', - }, - LBFLOATPUT: { - name : localize('High-Close'), - position: 'bottom', - }, - LBHIGHLOW: { - name : localize('High-Low'), - position: 'top', - }, - RANGE: { - name : localize('Stays Between'), - position: 'top', - }, - UPORDOWN: { - name : localize('Goes Outside'), - position: 'bottom', - }, ONETOUCH: { name : localize('Touch'), position: 'top', @@ -89,7 +120,8 @@ const getContractConfig = is_high_low => ({ name : localize('No Touch'), position: 'bottom', }, + ...getUnsupportedContracts(), }); -export const getContractTypeDisplay = (type, is_high_low = false) => (getContractConfig(is_high_low)[type].name); -export const getContractTypePosition = (type, is_high_low = false) => (getContractConfig(is_high_low)[type].position); +export const getContractTypeDisplay = (type, is_high_low = false) => (getContractConfig(is_high_low)[type] ? getContractConfig(is_high_low)[type].name : ''); +export const getContractTypePosition = (type, is_high_low = false) => (getContractConfig(is_high_low)[type] ? getContractConfig(is_high_low)[type].position : 'top'); diff --git a/src/javascript/app/Modules/Reports/Containers/open-positions.jsx b/src/javascript/app/Modules/Reports/Containers/open-positions.jsx index b5409867ba6f..53e427c60839 100644 --- a/src/javascript/app/Modules/Reports/Containers/open-positions.jsx +++ b/src/javascript/app/Modules/Reports/Containers/open-positions.jsx @@ -93,6 +93,6 @@ export default connect( is_loading : modules.portfolio.is_loading, onMount : modules.portfolio.onMount, onUnmount : modules.portfolio.onUnmount, - totals : modules.portfolio.totals, + totals : modules.portfolio.active_positions_totals, }) )(withRouter(OpenPositions)); diff --git a/src/javascript/app/Stores/Modules/Portfolio/portfolio-store.js b/src/javascript/app/Stores/Modules/Portfolio/portfolio-store.js index 04295437b234..527bf56ca03e 100644 --- a/src/javascript/app/Stores/Modules/Portfolio/portfolio-store.js +++ b/src/javascript/app/Stores/Modules/Portfolio/portfolio-store.js @@ -177,7 +177,7 @@ export default class PortfolioStore extends BaseStore { if (isUserSold(contract_response)) this.positions[i].exit_spot = '-'; this.positions[i].is_loading = false; - } + }; @action.bound pushNewPosition(new_pos) { @@ -247,6 +247,24 @@ export default class PortfolioStore extends BaseStore { }; } + @computed + get active_positions_totals() { + let indicative = 0; + let payout = 0; + let purchase = 0; + + this.active_positions.forEach((portfolio_pos) => { + indicative += (+portfolio_pos.indicative); + payout += (+portfolio_pos.payout); + purchase += (+portfolio_pos.purchase); + }); + return { + indicative, + payout, + purchase, + }; + } + @computed get active_positions() { return this.positions.filter((portfolio_pos) => !portfolio_pos.result);