Skip to content

Commit

Permalink
Merge pull request #26 from likhith-deriv/likhith/fix-call-proposal-o…
Browse files Browse the repository at this point in the history
…n-strike-change

likhith/fix: 🐛 call proposal API on strike change
  • Loading branch information
akmal-deriv authored Jan 20, 2023
2 parents 485a5a6 + 9e1f892 commit 31e92f5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/trader/src/Stores/Modules/Trading/trade-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ export default class TradeStore extends BaseStore {
}

onProposalResponse(response) {
const { contract_type, duration_unit } = response.echo_req;
const { contract_type } = response.echo_req;
const prev_proposal_info = getPropertyValue(this.proposal_info, contract_type) || {};
const obj_prev_contract_basis = getPropertyValue(prev_proposal_info, 'obj_contract_basis') || {};

Expand Down Expand Up @@ -1080,11 +1080,17 @@ export default class TradeStore extends BaseStore {
const { barrier_choices, max_stake, min_stake } = response.error.details;
this.setStakeBoundary(contract_type, min_stake, max_stake);
this.setStrikeChoices(barrier_choices);
if (duration_unit !== 'd' && !this.strike_price_choices.includes(this.barrier_1)) {
if (!this.strike_price_choices.includes(this.barrier_1)) {
// Since on change of duration `proposal` API call is made which returns a new set of barrier values.
// The new list is set and the mid value is assigned
const index = Math.floor(this.strike_price_choices.length / 2);
this.barrier_1 = this.strike_price_choices[index];
this.onChange({
target: {
name: 'barrier_1',
value: this.barrier_1,
},
});
}
}

Expand Down

0 comments on commit 31e92f5

Please sign in to comment.