Skip to content

Commit

Permalink
Kate / DTRA-178 / Enable Asians contract from SmartTrader (binary-com…
Browse files Browse the repository at this point in the history
…#9050)

* refactor: move trade type from un to supported

* feat: ad contract type check func and add to contract details

* feat: add chart markers settings for contract type

* chore: add style for mobile

* chore: remove gradient

* chore: empty commit

* chore: add gradient for contract details card for desktop

* feat: add chart markers setings and update style

* refactor: apply suggestions

* chore: empty commit

* feat: enable smart trader contract

* refactor: remove rounding for barrier value

* refactor: add swipble component for contract audit mobile and fix style

* refactor: applied suggestions from review

* feat: enable asians contract

* feat: add barrier for asians contract in contract audit

* refactor: update tests

* refactor: checks in contract details file

* chore: impove reg exp

* chore: add reg ex improvement

* fix: change trade type icons

* fix: add entry tick

* chore: empty commit

* chore: empty commit

* fix: conflicts

* chore: remove unnessesary prop
  • Loading branch information
kate-deriv committed Sep 26, 2023
1 parent 013f6d4 commit b830843
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 34 deletions.
16 changes: 8 additions & 8 deletions packages/components/stories/contract-card/statics/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,6 @@ export const getUnsupportedContracts = () => ({
name: 'Low Tick',
position: 'bottom',
},
ASIANU: {
name: 'Asian Up',
position: 'top',
},
ASIAND: {
name: 'Asian Down',
position: 'bottom',
},
LBFLOATCALL: {
name: 'Close-to-Low',
position: 'top',
Expand Down Expand Up @@ -254,6 +246,14 @@ export const getSupportedContracts = is_high_low => ({
name: 'Goes Outside',
position: 'bottom',
},
ASIANU: {
name: 'Asian Up',
position: 'top',
},
ASIAND: {
name: 'Asian Down',
position: 'bottom',
},
});

export const getContractConfig = is_high_low => ({
Expand Down
16 changes: 8 additions & 8 deletions packages/shared/src/utils/constants/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,6 @@ export const getUnsupportedContracts = () =>
name: localize('Low Tick'),
position: 'bottom',
},
ASIANU: {
name: localize('Asian Up'),
position: 'top',
},
ASIAND: {
name: localize('Asian Down'),
position: 'bottom',
},
LBFLOATCALL: {
name: localize('Close-to-Low'),
position: 'top',
Expand Down Expand Up @@ -493,6 +485,14 @@ export const getSupportedContracts = (is_high_low?: boolean) =>
name: localize('Goes Outside'),
position: 'bottom',
},
ASIANU: {
name: localize('Asian Up'),
position: 'top',
},
ASIAND: {
name: localize('Asian Down'),
position: 'bottom',
},
} as const);

export const getContractConfig = (is_high_low?: boolean) => ({
Expand Down
9 changes: 7 additions & 2 deletions packages/shared/src/utils/contract/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ export const isTurbosContract = (contract_type = '') => /TURBOS/i.test(contract_

export const isVanillaContract = (contract_type = '') => /VANILLA/i.test(contract_type);

export const isSmartTraderContract = (contract_type = '') => /RUN|EXPIRY|RANGE|UPORDOWN/i.test(contract_type);
export const isSmartTraderContract = (contract_type = '') => /RUN|EXPIRY|RANGE|UPORDOWN|ASIAN/i.test(contract_type);

export const isAsiansContract = (contract_type = '') => /ASIAN/i.test(contract_type);

export const isCryptoContract = (underlying = '') => underlying.startsWith('cry');

Expand Down Expand Up @@ -103,7 +105,10 @@ export const getAccuBarriersForContractDetails = (contract_info: TContractInfo)

export const getCurrentTick = (contract_info: TContractInfo) => {
const tick_stream = unique(contract_info.tick_stream || [], 'epoch');
const current_tick = isDigitContract(contract_info.contract_type) ? tick_stream.length : tick_stream.length - 1;
const current_tick =
isDigitContract(contract_info.contract_type) || isAsiansContract(contract_info.contract_type)
? tick_stream.length
: tick_stream.length - 1;
return !current_tick || current_tick < 0 ? 0 : current_tick;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('format-response', () => {
display_name: 'Volatility 25 Index',
id: 1234,
indicative: 0,
is_unsupported: true,
is_unsupported: false,
payout: 3500.1,
contract_update: undefined,
purchase: 2500.5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import {
epochToMoment,
getCancellationPrice,
getCurrencyDisplayCode,
hasTwoBarriers,
isAccumulatorContract,
isMobile,
isMultiplierContract,
isSmartTraderContract,
hasTwoBarriers,
isAsiansContract,
isTurbosContract,
isUserSold,
isEndedBeforeCancellationExpired,
Expand Down Expand Up @@ -49,6 +50,7 @@ const ContractDetails = ({ contract_end_time, contract_info, duration, duration_
const show_barrier = !is_vanilla && !isAccumulatorContract(contract_type) && !isSmartTraderContract(contract_type);
const show_duration = !isAccumulatorContract(contract_type) || !isNaN(contract_end_time);
const show_payout_per_point = isTurbosContract(contract_type) || is_vanilla;
const show_strike_barrier = is_vanilla || isAsiansContract(contract_type);
const ticks_duration_text = isAccumulatorContract(contract_type)
? `${tick_passed}/${tick_count} ${localize('ticks')}`
: `${tick_count} ${tick_count < 2 ? localize('tick') : localize('ticks')}`;
Expand Down Expand Up @@ -98,7 +100,7 @@ const ContractDetails = ({ contract_end_time, contract_info, duration, duration_
value={tick_count > 0 ? ticks_duration_text : `${duration} ${duration_unit}`}
/>
)}
{is_vanilla && (
{show_strike_barrier && (
<ContractAuditItem
id='dt_bt_label'
icon={<Icon icon='IcContractStrike' size={24} />}
Expand All @@ -120,6 +122,23 @@ const ContractDetails = ({ contract_end_time, contract_info, duration, duration_
value={getBarrierValue(contract_info) || ' - '}
/>
)}
{hasTwoBarriers(contract_type) && (
<React.Fragment>
{[high_barrier, low_barrier].map((barrier, index) => (
<ContractAuditItem
id={`dt_bt_label_${index + 1}`}
icon={<Icon icon='IcContractStrike' size={24} />}
key={barrier}
label={
high_barrier === barrier
? localize('High barrier')
: localize('Low barrier')
}
value={barrier}
/>
))}
</React.Fragment>
)}
{show_payout_per_point && (
<ContractAuditItem
id='dt_bt_label'
Expand All @@ -130,19 +149,6 @@ const ContractDetails = ({ contract_end_time, contract_info, duration, duration_
)}
</React.Fragment>
)}
{hasTwoBarriers(contract_type) && (
<React.Fragment>
{[high_barrier, low_barrier].map((barrier, index) => (
<ContractAuditItem
id={`dt_bt_label_${index + 1}`}
icon={<Icon icon='IcContractStrike' size={24} />}
key={barrier}
label={high_barrier === barrier ? localize('High barrier') : localize('Low barrier')}
value={barrier}
/>
))}
</React.Fragment>
)}
<ContractAuditItem
id='dt_start_time_label'
icon={<Icon icon='IcContractStartTime' size={24} />}
Expand Down

0 comments on commit b830843

Please sign in to comment.