Skip to content

Commit

Permalink
Default today for Volatility indices
Browse files Browse the repository at this point in the history
  • Loading branch information
easteregg committed May 1, 2019
1 parent 2361ab9 commit 692c76d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/javascript/app_2/Stores/Modules/Trading/Helpers/duration.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,14 @@ export const convertDurationLimit = (value, unit) => {
export const hasIntradayDurationUnit = (duration_units_list) => (
duration_units_list.some(unit => ['m', 'h'].indexOf(unit.value) !== -1)
);

/**
* On switching symbols, end_time value of volatility indices should be set to today
*
* @param {String} symbol
* @param {String} expiry_type
* @returns {*}
*/
export const resetEndTimeOnVolatilityIndices = (symbol, expiry_type) => (
(/^R_/.test(symbol) && expiry_type === 'endtime') ? toMoment(null).format('DD MMM YYYY') : null
);
14 changes: 13 additions & 1 deletion src/javascript/app_2/Stores/Modules/Trading/trade-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import getValidationRules from './Constants/validation-rules';
import { isRiseFallEqual } from './Helpers/allow-equals';
import { setChartBarrier } from './Helpers/chart';
import ContractType from './Helpers/contract-type';
import { convertDurationLimit } from './Helpers/duration';
import {
convertDurationLimit,
resetEndTimeOnVolatilityIndices } from './Helpers/duration';
import { processTradeParams } from './Helpers/process';
import {
createProposalRequests,
Expand Down Expand Up @@ -145,6 +147,16 @@ export default class TradeStore extends BaseStore {
this.onAllowEqualsChange();
},
);

reaction(
() => this.symbol,
() => {
const date = resetEndTimeOnVolatilityIndices(this.symbol, this.expiry_type);
if (date) {
this.expiry_date = date;
}
}
);
}

@action.bound
Expand Down

0 comments on commit 692c76d

Please sign in to comment.