コード例 #1
0
        public async Task <IActionResult> SetWalletLimit(string AccWalletID, [FromBody] WalletLimitConfigurationReq Request)
        {
            LimitResponse response = new LimitResponse();

            try
            {
                var user = await _userManager.GetUserAsync(HttpContext.User);

                if (user == null)
                {
                    response.ReturnCode = enResponseCode.Fail;
                    response.ReturnMsg  = EnResponseMessage.StandardLoginfailed;
                    response.ErrorCode  = enErrorCode.StandardLoginfailed;
                }
                else
                {
                    var accessToken = await HttpContext.GetTokenAsync("access_token");

                    response = _walletService.SetWalletLimitConfig(AccWalletID, Request, user.Id, accessToken);
                }
                var     respObj     = JsonConvert.SerializeObject(response);
                dynamic respObjJson = JObject.Parse(respObj);
                return(Ok(respObjJson));
            }
            catch (Exception ex)
            {
                //_logger.LogError(ex, "Date: " + _basePage.UTC_To_IST() + ",\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nControllername=" + this.GetType().Name, LogLevel.Error);
                //return BadRequest();
                return(BadRequest(new BizResponseClass {
                    ReturnCode = enResponseCode.InternalError, ReturnMsg = ex.ToString(), ErrorCode = enErrorCode.Status500InternalServerError
                }));
            }
            //return Ok();
        }
コード例 #2
0
 public async Task <IActionResult> GetWalletLimit(string AccWalletID)
 {
     try
     {
         LimitResponse Response    = _walletService.GetWalletLimitConfig(AccWalletID);
         var           respObj     = JsonConvert.SerializeObject(Response);
         dynamic       respObjJson = JObject.Parse(respObj);
         return(Ok(respObjJson));
     }
     catch (Exception ex)
     {
         //_logger.LogError(ex, "Date: " + _basePage.UTC_To_IST() + ",\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nControllername=" + this.GetType().Name, LogLevel.Error);
         //return BadRequest();
         return(BadRequest(new BizResponseClass {
             ReturnCode = enResponseCode.InternalError, ReturnMsg = ex.ToString(), ErrorCode = enErrorCode.Status500InternalServerError
         }));
     }
 }
コード例 #3
0
ファイル: SessionAcceptor.cs プロジェクト: radtek/Gradual
        private void _processMessage(TOMessage to)
        {
            try
            {
                if (null != to)
                {
                    QuickFix.Message msgQF   = to.MensagemQF;
                    string           msgType = msgQF.Header.GetField(Tags.MsgType);
                    int    account           = 0;
                    string strAcc            = string.Empty;
                    #region Limit Validation
                    // Atualizacao dos valores de limite, de acordo com o execution report
                    if (this.CalcularLimite)
                    {
                        if (this.Config.Bolsa.Equals(ExchangePrefixes.BOVESPA, StringComparison.InvariantCultureIgnoreCase))
                        {
                            strAcc = msgQF.IsSetField(Tags.Account) ? msgQF.GetField(Tags.Account) : string.Empty;
                            if (!string.IsNullOrEmpty(strAcc))
                            {
                                account = Convert.ToInt32(strAcc.Remove(strAcc.Length - 1));
                            }
                            else
                            {
                                account = 0;
                            }
                        }
                        else
                        {
                            strAcc = msgQF.IsSetField(Tags.Account) ? msgQF.GetField(Tags.Account) : string.Empty;
                            if (!string.IsNullOrEmpty(strAcc))
                            {
                                account = Convert.ToInt32(strAcc);
                            }
                            else
                            {
                                account = 0;
                            }
                        }
                        bool          bProfileInst = false;
                        LimitResponse retProfile   = LimiteManager.LimitControl.GetInstance().VerifyInstitutionalProfile(account);

                        if (0 != retProfile.ErrorCode)
                        {
                            bProfileInst = true;
                        }
                        if (msgType == MsgType.EXECUTION_REPORT && !bProfileInst)
                        {
                            // Validar o perfil instituicional

                            QuickFix.FIX44.ExecutionReport er = (QuickFix.FIX44.ExecutionReport)msgQF;
                            // Bovespa
                            if (this.Config.Bolsa.Equals(ExchangePrefixes.BOVESPA, StringComparison.InvariantCultureIgnoreCase))
                            {
                                // BOVESPA
                                decimal ultimoPreco = StreamerManager.GetInstance().GetLastPrice(er.Symbol.ToString());
                                if (Decimal.Zero != ultimoPreco)
                                {
                                    LimitResponse ret          = new LimitResponse();
                                    decimal       valorAlocado = er.OrderQty.getValue() * ultimoPreco;
                                    // Retirar o digito verificador

                                    string chaveAtual = er.ClOrdID.ToString() + "-" + strAcc + "-" + er.Symbol.ToString();

                                    switch (er.OrdStatus.getValue())
                                    {
                                    // Alocar limite da parte e contra parte
                                    case OrdStatus.NEW:
                                    case OrdStatus.REPLACED:
                                    case OrdStatus.CANCELED:
                                    {
                                        // Buscar o "new order" referencial para busca do TipoLimite
                                        // toOrder = this.Initiator.GetTOOrderSession(chaveAtual);
                                        if (null == to.Order)
                                        {
                                            logger.Info("RefOrder não encontrada (New): " + chaveAtual);
                                        }
                                        else
                                        {
                                            ret = LimiteManager.LimitControl.GetInstance().UpdateOperationalLimitBovespa(account, to.TipoLimite, valorAlocado, ultimoPreco, Convert.ToInt32(er.Side.ToString()), er.OrdStatus.getValue());
                                            if (0 != ret.ErrorCode)
                                            {
                                                logger.Info("Erro na atualizacao do limite operacional Bovespa (New): " + ret.ErrorMessage);
                                            }
                                        }
                                    }
                                    break;

                                    // Atualizar a quantidade executada
                                    case OrdStatus.FILLED:
                                    case OrdStatus.PARTIALLY_FILLED:
                                        if (null != to.Order)
                                        {
                                            to.Order.CumQty = Convert.ToInt32(er.CumQty.getValue());
                                            valorAlocado    = er.CumQty.getValue() * ultimoPreco;
                                            ret             = LimiteManager.LimitControl.GetInstance().UpdateOperationalLimitBovespa(account, to.TipoLimite, valorAlocado, ultimoPreco, Convert.ToInt32(er.Side.ToString()), er.OrdStatus.getValue());
                                            if (0 != ret.ErrorCode)
                                            {
                                                logger.Info("Erro na atualizacao do limite operacional Bovespa (Filled / Partially Filled): " + ret.ErrorMessage);
                                            }
                                        }
                                        else
                                        {
                                            logger.Info("RefOrder não encontrada (New): " + chaveAtual);
                                        }
                                        break;
                                    }
                                }
                                else
                                {
                                    string symbol = er.IsSetSymbol() ? er.Symbol.getValue() : string.Empty;
                                    logger.Info("Preco base (ultimo preco) zerado, ignorando o calculo do limite: " + symbol);
                                }
                            }
                            //bmf
                            else
                            {
                                // BMF
                                // account = er.IsSetField(Tags.Account)?  Convert.ToInt32(er.Account.getValue()): 0;
                                LimitResponse ret  = null;
                                string        side = er.Side.getValue() == '1' ? "C" : "V";
                                switch (er.OrdStatus.getValue())
                                {
                                case OrdStatus.NEW:
                                    ret = LimiteManager.LimitControl.GetInstance()
                                          .UpdateOperationalLimitBMF(Convert.ToInt32(er.Account.getValue()), to.TipoLimite,
                                                                     er.Symbol.getValue(), Convert.ToInt32(er.OrderQty.getValue()), 0, side);
                                    break;

                                case OrdStatus.REPLACED:
                                {
                                    int qtdResult = (-1) * (to.Order.OrderQty - to.Order.CumQty);
                                    ret = LimiteManager.LimitControl.GetInstance()
                                          .UpdateOperationalLimitBMF(Convert.ToInt32(er.Account.getValue()), to.TipoLimite,
                                                                     er.Symbol.getValue(), qtdResult, Convert.ToInt32(er.OrderQty.getValue()), side);
                                }
                                break;

                                case OrdStatus.CANCELED:
                                {
                                    int qtdResult = (-1) * (to.Order.OrderQty - to.Order.CumQty);
                                    ret = LimiteManager.LimitControl.GetInstance()
                                          .UpdateOperationalLimitBMF(Convert.ToInt32(er.Account.getValue()), to.TipoLimite,
                                                                     er.Symbol.getValue(), qtdResult, 0, side);
                                }
                                break;

                                // Atualizando a quantidade de
                                case OrdStatus.FILLED:
                                case OrdStatus.PARTIALLY_FILLED:
                                    if (null != to.Order)
                                    {
                                        to.Order.CumQty = Convert.ToInt32(er.CumQty.getValue());
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    #endregion

                    // Efetuar verificacao da integracao utilizada, para efetuar a conversao do
                    switch (this.Config.IntegrationID)
                    {
                    case IntegrationId.BBG:
                        this._sendMessageBBGIntegration(msgType, msgQF, to, account);
                        break;

                    case IntegrationId.GRD:
                    case IntegrationId.IVF:
                    default:
                        this._sendDefaultMessageIntegration(msgQF, to, account);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("_processMessage(): " + ex.Message, ex);
            }
        }