示例#1
0
def supplier_blotter_ndf():
    json_sorted_currencies = get_currencies_sorted()
    return render_template(
        'supplier-blotter-ndf.html',
        sorted_currencies=json_sorted_currencies,
        halt="halt-quoting.html",
    )
示例#2
0
def spreads_ndf_get():
    search_by_group = request.args.get('search_by', '').lower() == 'group'
    key = request.args.get('key', '').upper()

    sorted_currencies = json.loads(get_currencies_sorted())

    with open(get_data_path('RobotFX_Client_Spreads.json')) as json_file:
        all_spreads = json.load(json_file)

        try:
            if search_by_group:
                all_spreads = all_spreads['GroupSpreads']
            else:
                all_spreads = all_spreads['CounterpartySpreads']

            spreads_by_product = all_spreads[key]
            spreads = spreads_by_product['FXNDF']
        except KeyError:
            spreads = {'Spreads': {}}
            with open(
                    get_data_path('RobotFX_NDFTimeBuckets.json')) as json_file:
                buckets_l = json.load(json_file).get('TimeBuckets')
                buckets = [value['EndDay'] for value in buckets_l]
                spreads['Buckets'] = buckets
            for ccy in sorted_currencies:
                spreads['Spreads'][ccy] = {'BUYSELL': [None] * len(buckets)}

    result = {'spreads_catalog': spreads, 'currencies': sorted_currencies}
    return jsonify(result)
示例#3
0
def supplier_control():
    with open(get_data_path('RobotFX_FXSupplierControl.json')) as json_file:
        currencies_config = json.load(json_file)

    json_sorted_currencies = get_currencies_sorted()
    return render_template(
        'supplier-control.html',
        currencies_config=json.dumps(currencies_config),
        sorted_currencies=json_sorted_currencies,
    )
示例#4
0
def config():
    with open(get_data_path('RobotFX_SpotConfig.json')) as json_file:
        spot_config = json.load(json_file)
        cutoff_times = spot_config['CutOffTimes']

        with open(get_data_path('RobotFX_Currencies.json')) as currencies_json_file:
            cur_data = json.load(currencies_json_file)
            for cur in cutoff_times['Primary']:
                cutoff_times['Primary'][cur]['ViewPriority'] = cur_data[cur]['ViewPriority']

    with open(get_data_path('RobotFX_NDFTimeBuckets.json')) as json_file:
        time_buckets_data = json.load(json_file)
        time_buckets = time_buckets_data['TimeBuckets']

    counterparties = []
    with open(get_data_path('RobotFX_LegalEntities.json')) as json_file:
        legal_entities_data = json.load(json_file)
        for (key, obj) in legal_entities_data.items():
            counterparties.append(
                {
                    'Id': len(counterparties) + 1,
                    'Alias': obj['Alias'],
                    'Counterparty': obj['CounterpartyName'],
                    'Cnpj': key,
                    'MarketType': obj['FXMarketType'],
                    'DefaultTransaction': obj['DefaultFXTransaction'],
                    'Products': obj['Products'],
                }
            )

    counterparties = sorted(counterparties, key=lambda cparty: cparty['Alias'])

    # groups = []
    with open(get_data_path('RobotFX_LegalEntitiesRelationships.json')) as json_file:
        groups_data = json.load(json_file)
        groups_data = groups_data.get('Groups_Spreads', {})
        spot_groups = groups_data.get('FXSPOT', {})
        ndf_groups = groups_data.get('FXNDF', {})

    spot_timeout = databus.get('TradingParameters/Engine_Global_Parameters/FXSPOT/RFQ_Timeout')
    ndf_timeout = databus.get('TradingParameters/Engine_Global_Parameters/FXNDF/RFQ_Timeout')

    json_sorted_currencies = get_currencies_sorted()
    return render_template(
        'config-main.html',
        cutoff_times=json.dumps(cutoff_times),
        time_buckets=json.dumps(time_buckets),
        counterparties=json.dumps(counterparties),
        spot_groups=json.dumps(spot_groups),
        ndf_groups=json.dumps(ndf_groups),
        currencies=json.dumps(cur_data),
        spot_timeout=json.dumps(spot_timeout),
        ndf_timeout=json.dumps(ndf_timeout),
        sorted_currencies=json_sorted_currencies,
    )
示例#5
0
def trading_parameters_ndf():
    trading_parameters = databus.get_dict('TradingParameters')
    engine_parameters = json.dumps(
        trading_parameters["Engine_Global_Parameters"]["FXNDF"])
    currency_keys = json.dumps(trading_parameters["CurrencyKeys"])
    counterparty_list = []
    leg_entities = databus.get_dict('LegalEntities')
    if leg_entities is None:
        leg_entities = {}
    trad_counterparties = trading_parameters['CounterpartyKeys']
    common_cp_keys = tuple(k for k, v in leg_entities.items()
                           if 'FXNDF' in v['Products'])
    for cp_key in common_cp_keys:
        trad_value = trad_counterparties[cp_key]['FXNDF']
        validate_kyc_rule = update_validate_rule(trad_value['ValidateKYC'],
                                                 'KYC', cp_key, True)
        validate_isda_rule = update_validate_rule(trad_value['ValidateISDA'],
                                                  'ISDA', cp_key, True)
        counterparty_list.append({
            'cter_prty_id':
            cp_key,
            'counterparty':
            leg_entities[cp_key]["CounterpartyName"],
            'upper_limit_dc':
            trad_value['UpperLimitDays2Maturity'],
            'automatic_flow':
            trad_value['AutoFlow'],
            'validate_kyc':
            validate_kyc_rule,
            'validate_isda':
            validate_isda_rule,
        })

    with open(get_data_path('RobotFX_Users.json')) as json_file:
        user_data = json.load(json_file)
        user_id = session.get("user_id", None)
        username = get_username(user_id)
        if username not in user_data:
            return render_template('404.html')

        response_data = user_data[username]
        allow_validate = response_data['allow_validate'].lower() == 'yes'

    validate_parameters = get_validate_parameters()

    json_sorted_currencies = get_currencies_sorted()
    return render_template(
        'trading-parameters-ndf.html',
        engine_parameters=engine_parameters,
        currency_keys=currency_keys,
        counterparty_data=json.dumps(counterparty_list),
        sorted_currencies=json_sorted_currencies,
        allow_validate=json.dumps(allow_validate),
        validate_parameters=json.dumps(validate_parameters),
    )
示例#6
0
def statistics_spot():
    fx_product = "SPOT"
    session = SessionMaker()
    currencies = get_currencies_sorted_list()
    daily_stats_dict = get_daily_stats(session, fx_product, currencies)
    session.close()
    daily_stats_json = json.dumps(daily_stats_dict)
    sorted_currencies = get_currencies_sorted()

    return render_template("statistics-spot.html",
                           daily_stats=daily_stats_json,
                           sorted_currencies=sorted_currencies)
示例#7
0
def spreads_spot_get():
    search_by_group = request.args.get('search_by', '').lower() == 'group'
    key = request.args.get('key', '').upper()

    sorted_currencies = json.loads(get_currencies_sorted())

    with open(get_data_path('RobotFX_Client_Spreads.json')) as json_file:
        all_spreads = json.load(json_file)
        all_spreads = all_spreads[
            'GroupSpreads' if search_by_group else 'CounterpartySpreads']

        try:
            spreads = all_spreads[key]['FXSPOT']
        except KeyError:
            spreads = {
                currency: {
                    'SELL': [None] * 3,
                    'BUY': [None] * 3
                }
                for currency in sorted_currencies
            }

    result = {'spreads': spreads, 'currencies': sorted_currencies}
    return jsonify(result)
示例#8
0
def supplier_blotter_spot():
    return render_template(
        'supplier-blotter-spot.html',
        sorted_currencies=get_currencies_sorted(),
        halt="halt-quoting.html",
    )
示例#9
0
def blotter_spot():
    json_sorted_currencies = get_currencies_sorted()
    return render_template('blotter-spot.html',
                           sorted_currencies=json_sorted_currencies)
示例#10
0
def trading_parameters_spot():
    cash_limits_initialized = databus.get(
        'System/Status/Trading/SPOT/Initialized')
    trading_parameters = databus.get_dict('TradingParameters')
    engine_parameters = trading_parameters["Engine_Global_Parameters"][
        "FXSPOT"]
    currency_keys = trading_parameters["CurrencyKeys"]
    leg_entities = databus.get_dict('LegalEntities')
    if leg_entities is None:
        leg_entities = {}
    trad_counterparties = trading_parameters['CounterpartyKeys']
    common_cp_keys = tuple(k for k, v in leg_entities.items()
                           if 'FXSPOT' in v['Products'])
    counterparty_list = []
    for cp_key in common_cp_keys:
        trad_value = trad_counterparties[cp_key]['FXSPOT']
        validate_kyc_rule = update_validate_rule(trad_value['ValidateKYC'],
                                                 'KYC', cp_key, False)
        counterparty_list.append({
            'cter_prty_id':
            cp_key,
            'counterparty':
            leg_entities[cp_key]["CounterpartyName"],
            'automatic_flow':
            trad_value['AutoFlow'],
            'validate_kyc':
            validate_kyc_rule,
        })
    json_sorted_currencies = get_currencies_sorted()
    cash_limits_logs = {}

    if cash_limits_initialized:
        cash_limits_logs = databus.get_dict('CashLimits/Logs')
        pre_trading_ini_bal = {}
        for currency, maturity_value in cash_limits_logs.items():
            pre_trading_ini_bal[currency] = {}
            for maturity, value in maturity_value.items():
                if isinstance(value, list) and len(value) > 0:
                    pre_trading_ini_bal[currency][maturity] = value[0]
    else:
        cash_limits_logs = {}
        pre_trading_ini_bal = trading_parameters['PreTradingInitialBalance']

    with open(get_data_path('RobotFX_Users.json')) as json_file:
        user_data = json.load(json_file)
        user_id = session.get("user_id", None)
        username = get_username(user_id)
        if username not in user_data:
            return render_template('404.html')

        response_data = user_data[username]
        allow_validate = response_data['allow_validate'].lower() == 'yes'

    validate_parameters = get_validate_parameters()

    return render_template(
        'trading-parameters-spot.html',
        engine_parameters=json.dumps(engine_parameters),
        currency_keys=json.dumps(currency_keys),
        pre_trading_ini_bal=json.dumps(pre_trading_ini_bal),
        counterparty_data=json.dumps(counterparty_list),
        sorted_currencies=json_sorted_currencies,
        spot_initialized=cash_limits_initialized,
        cash_limits_logs=cash_limits_logs,
        allow_validate=json.dumps(allow_validate),
        validate_parameters=json.dumps(validate_parameters),
    )