Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V20190521_1 #79

Merged
merged 9 commits into from
May 21, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@ class ContractDrawer extends Component {
currency,
exit_tick,
is_sold,
payout,
profit,
sell_price,
} = this.props.contract_info;
const { contract_info } = this.props;
const exit_spot = isUserSold(contract_info) ? '-' : exit_tick;

return (
<ContractCard contract_info={contract_info}>
<ContractCardHeader>
Expand All @@ -64,7 +63,7 @@ class ContractDrawer extends Component {
<ContractCardBody>
<ProfitLossCardContent
pl_value={+profit}
payout={+payout}
payout={+sell_price}
currency={currency}
/>
</ContractCardBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class PositionsDrawerCard extends React.PureComponent {
onClickRemove,
openContract,
result,
sell_price,
sell_time,
server_time,
status,
Expand Down Expand Up @@ -136,7 +137,7 @@ class PositionsDrawerCard extends React.PureComponent {
</div>
</div>
<div className='positions-drawer-card__indicative'>
<Money amount={indicative} currency={currency} />
<Money amount={sell_price || indicative} currency={currency} />
<div className={classNames(
'positions-drawer-card__indicative--movement', {
'positions-drawer-card__indicative--movement-complete': !!result,
Expand Down
14 changes: 8 additions & 6 deletions src/javascript/app/App/Components/Layout/Header/menu-links.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ const MenuLinks = ({ is_logged_in, items }) => (
null
:
<BinaryLink key={idx} to={item.link_to} className='header__menu-link' active_class='header__menu-link--active'>
{item.text &&
<span title={item.text} className='header__menu-link-text'>{item.icon}{item.text}{item.logo}</span>
}
{item.image &&
<span className='header__menu-link-text'>{item.image}{item.logo}</span>
}
<React.Fragment>
{item.text &&
<span title={item.text} className='header__menu-link-text'>{item.icon}{item.text}{item.logo}</span>
}
{item.image &&
<span className='header__menu-link-text'>{item.image}{item.logo}</span>
}
</React.Fragment>
</BinaryLink>
))
}
Expand Down
102 changes: 67 additions & 35 deletions src/javascript/app/Constants/contract.js
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand All @@ -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');
Original file line number Diff line number Diff line change
Expand Up @@ -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));
21 changes: 20 additions & 1 deletion src/javascript/app/Stores/Modules/Portfolio/portfolio-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export default class PortfolioStore extends BaseStore {
this.positions[i].is_valid_to_sell = isValidToSell(contract_response);
this.positions[i].result = getDisplayStatus(contract_response);
this.positions[i].sell_time = getEndTime(contract_response) || contract_response.current_spot_time; // same as exit_spot, use latest spot time if no exit_tick_time
this.positions[i].sell_price = contract_response.sell_price;
this.positions[i].status = 'complete';

// fix for missing barrier and entry_spot
Expand All @@ -176,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) {
Expand Down Expand Up @@ -246,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);
Expand Down