<commit_before>const moment               = require('moment');
const commonTrading        = require('./common');
const displayPriceMovement = require('./common_independent').displayPriceMovement;
const getStartDateNode     = require('./common_independent').getStartDateNode;
const getTradingTimes      = require('./common_independent').getTradingTimes;
const Contract             = require('./contract');
const Defaults             = require('./defaults');
const getLookBackFormula   = require('./lookback').getFormula;
const isLookback           = require('./lookback').isLookback;
const Client               = require('../../base/client');
const BinarySocket         = require('../../base/socket');
const formatMoney          = require('../../common/currency').formatMoney;
const CommonFunctions      = require('../../../_common/common_functions');
const localize             = require('../../../_common/localize').localize;
const getPropertyValue     = require('../../../_common/utility').getPropertyValue;

/*
 * Price object handles all the functions we need to display prices
 *
 * We create Price proposal that we need to send to server to get price,
 * longcode and all other information that we need to get the price for
 * current contract
 *
 *
 * Usage:
 *
 * `socket.send(Price.proposal())` to send price proposal to server
 * `Price.display()` to display the price details returned from server
 */
const Price = (() => {
    let type_display_id_mapping = {};
    let form_id                 = 0;
    let is_resubscribing        = false;

    const createProposal = (type_of_contract) => {
        const proposal = {
            proposal : 1,
            subscribe: 1,
        };

        const contract_type = type_of_contract;
        const start_date    = getStartDateNode();
        const start_time    = CommonFunctions.getElementById('time_start');
        const underlying    = CommonFunctions.getElementById('underlying');
        const amount_type   = CommonFunctions.getElementById('amount_type');
        const currency      = CommonFunctions.getVisibleElement('currency');
        const payout        = CommonFunctions.getElementById('amount');
        const expiry_type   = CommonFunctions.getElementById('expiry_type');
        const duration      = CommonFunctions.getElementById('duration_amount');
        const duration_unit = CommonFunctions.getElementById('duration_units');
        const end_date      = CommonFunctions.getElementById('expiry_date');
        const barrier       = CommonFunctions.getElementById('barrier');
        const high_barrier  = CommonFunctions.getElementById('barrier_high');
        const low_barrier   = CommonFunctions.getElementById('barrier_low');
        const prediction    = CommonFunctions.getElementById('prediction');
        const selected_tick = CommonFunctions.getElementById('selected_tick');
        const multiplier    = CommonFunctions.getElementById('multiplier');

        if (payout && CommonFunctions.isVisible(payout) && payout.value) {
            proposal.amount = parseFloat(payout.value);
        }

        if (multiplier && CommonFunctions.isVisible(multiplier) && multiplier.value) {
            const multiplier_value = parseFloat(multiplier.value);
            proposal.amount = multiplier_value;
            if (multiplier_value > 1000) {
                proposal.error = {
                    message: localize('Maximum multiplier of 1000.'),
                };
            }
        }

        if (amount_type && CommonFunctions.isVisible(amount_type) && amount_type.value
            && !isLookback(type_of_contract)) {
            proposal.basis = amount_type.value;
        }

        if (isLookback(type_of_contract)) {
            proposal.basis = 'multiplier';
        }

        if (contract_type) {
            proposal.contract_type = type_of_contract;
        }

        if (currency && (currency.value || currency.getAttribute('value'))) {
            proposal.currency = currency.value || currency.getAttribute('value');
        }

        if (underlying && underlying.value) {
            proposal.symbol = underlying.value;
        }

        if (start_date && CommonFunctions.isVisible(start_date) && start_date.value !== 'now') {
            const time     = start_time.value.split(':');
            const set_time = moment.utc(Number(start_date.value) * 1000).hour(time[0]).minute(time[1]);

            proposal.date_start = set_time ? set_time.unix() : undefined;
        }

        if (expiry_type && CommonFunctions.isVisible(expiry_type) && expiry_type.value === 'duration') {
            proposal.duration      = parseInt(duration.value);
            proposal.duration_unit = duration_unit.value;
        } else if (expiry_type && CommonFunctions.isVisible(expiry_type) && expiry_type.value === 'endtime') {
            const end_date2 = end_date.getAttribute('data-value');
            let end_time2   = Defaults.get('expiry_time');
            if (!end_time2) {
                const trading_times = getTradingTimes();
                const trading_times_end_date2 = getPropertyValue(trading_times, [end_date2, underlying.value]);
                if (trading_times_end_date2 && trading_times_end_date2.length && trading_times_end_date2[0] !== '--') {
                    if (trading_times_end_date2.length > 1) {
                        end_time2 = trading_times_end_date2[1];
                    } else {
                        end_time2 = trading_times_end_date2;
                    }
                }
            }

            proposal.date_expiry   = moment.utc(`${end_date2} ${(end_time2 || '23:59:59')}`).unix();
            // For stopping tick trade behaviour
            proposal.duration_unit = 'm';
        }

        if (barrier && CommonFunctions.isVisible(barrier) && barrier.value) {
            proposal.barrier = barrier.value;
        }

        if (high_barrier && CommonFunctions.isVisible(high_barrier) && high_barrier.value) {<commit_msg>added barrier value to request<commit_after>const moment               = require('moment');
const commonTrading        = require('./common');
const displayPriceMovement = require('./common_independent').displayPriceMovement;
const getStartDateNode     = require('./common_independent').getStartDateNode;
const getTradingTimes      = require('./common_independent').getTradingTimes;
const Contract             = require('./contract');
const Defaults             = require('./defaults');
const getLookBackFormula   = require('./lookback').getFormula;
const isLookback           = require('./lookback').isLookback;
const Client               = require('../../base/client');
const BinarySocket         = require('../../base/socket');
const formatMoney          = require('../../common/currency').formatMoney;
const CommonFunctions      = require('../../../_common/common_functions');
const localize             = require('../../../_common/localize').localize;
const getPropertyValue     = require('../../../_common/utility').getPropertyValue;

/*
 * Price object handles all the functions we need to display prices
 *
 * We create Price proposal that we need to send to server to get price,
 * longcode and all other information that we need to get the price for
 * current contract
 *
 *
 * Usage:
 *
 * `socket.send(Price.proposal())` to send price proposal to server
 * `Price.display()` to display the price details returned from server
 */
const Price = (() => {
    let type_display_id_mapping = {};
    let form_id                 = 0;
    let is_resubscribing        = false;

    const createProposal = (type_of_contract) => {
        const proposal = {
            proposal : 1,
            subscribe: 1,
        };

        const contract_type = type_of_contract;
        const start_date    = getStartDateNode();
        const start_time    = CommonFunctions.getElementById('time_start');
        const underlying    = CommonFunctions.getElementById('underlying');
        const amount_type   = CommonFunctions.getElementById('amount_type');
        const currency      = CommonFunctions.getVisibleElement('currency');
        const payout        = CommonFunctions.getElementById('amount');
        const expiry_type   = CommonFunctions.getElementById('expiry_type');
        const duration      = CommonFunctions.getElementById('duration_amount');
        const duration_unit = CommonFunctions.getElementById('duration_units');
        const end_date      = CommonFunctions.getElementById('expiry_date');
        const barrier       = CommonFunctions.getElementById('barrier');
        const high_barrier  = CommonFunctions.getElementById('barrier_high');
        const low_barrier   = CommonFunctions.getElementById('barrier_low');
        const prediction    = CommonFunctions.getElementById('prediction');
        const selected_tick = CommonFunctions.getElementById('selected_tick');
        const multiplier    = CommonFunctions.getElementById('multiplier');

        if (payout && CommonFunctions.isVisible(payout) && payout.value) {
            proposal.amount = parseFloat(payout.value);
        }

        if (multiplier && CommonFunctions.isVisible(multiplier) && multiplier.value) {
            const multiplier_value = parseFloat(multiplier.value);
            proposal.amount = multiplier_value;
            if (multiplier_value > 1000) {
                proposal.error = {
                    message: localize('Maximum multiplier of 1000.'),
                };
            }
        }

        if (amount_type && CommonFunctions.isVisible(amount_type) && amount_type.value
            && !isLookback(type_of_contract)) {
            proposal.basis = amount_type.value;
        }

        if (isLookback(type_of_contract)) {
            proposal.basis = 'multiplier';
        }

        if (contract_type) {
            proposal.contract_type = type_of_contract;
        }

        if (currency && (currency.value || currency.getAttribute('value'))) {
            proposal.currency = currency.value || currency.getAttribute('value');
        }

        if (underlying && underlying.value) {
            proposal.symbol = underlying.value;
        }

        if (start_date && CommonFunctions.isVisible(start_date) && start_date.value !== 'now') {
            const time     = start_time.value.split(':');
            const set_time = moment.utc(Number(start_date.value) * 1000).hour(time[0]).minute(time[1]);

            proposal.date_start = set_time ? set_time.unix() : undefined;
        }

        if (expiry_type && CommonFunctions.isVisible(expiry_type) && expiry_type.value === 'duration') {
            proposal.duration      = parseInt(duration.value);
            proposal.duration_unit = duration_unit.value;
        } else if (expiry_type && CommonFunctions.isVisible(expiry_type) && expiry_type.value === 'endtime') {
            const end_date2 = end_date.getAttribute('data-value');
            let end_time2   = Defaults.get('expiry_time');
            if (!end_time2) {
                const trading_times = getTradingTimes();
                const trading_times_end_date2 = getPropertyValue(trading_times, [end_date2, underlying.value]);
                if (trading_times_end_date2 && trading_times_end_date2.length && trading_times_end_date2[0] !== '--') {
                    if (trading_times_end_date2.length > 1) {
                        end_time2 = trading_times_end_date2[1];
                    } else {
                        end_time2 = trading_times_end_date2;
                    }
                }
            }

            proposal.date_expiry   = moment.utc(`${end_date2} ${(end_time2 || '23:59:59')}`).unix();
            // For stopping tick trade behaviour
            proposal.duration_unit = 'm';
        }

        if (barrier && CommonFunctions.isVisible(barrier)) {
            proposal.barrier = barrier.value;
        }

        if (high_barrier && CommonFunctions.isVisible(high_barrier) && high_barrier.value) {
{'fraction_non_alphanumeric': 0.11522393048128342, 'fraction_numerical': 0.006851604278074866, 'mean_word_length': 2.4692753623188404, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '397998', 'n_tokens_mistral': 3156, 'n_tokens_neox': 3061, 'n_words': 609}