示例#1
0
        private Trade _loadTrade(BinaryFormatter bformatter, Stream stream)
        {
            Trade trade = new Trade();

            trade.AfterHours         = (bool)bformatter.Deserialize(stream);
            trade.BrokerCode         = (string)bformatter.Deserialize(stream);
            trade.BrokerName         = (string)bformatter.Deserialize(stream);
            trade.BrokerType         = (string)bformatter.Deserialize(stream);
            trade.BuyerCode          = (string)bformatter.Deserialize(stream);
            trade.BuyerName          = (string)bformatter.Deserialize(stream);
            trade.DMASource          = (string)bformatter.Deserialize(stream);
            trade.DMATrade           = (string)bformatter.Deserialize(stream);
            trade.DMATradeID         = (string)bformatter.Deserialize(stream);
            trade.HedgeLongMaturity  = (DateTime)bformatter.Deserialize(stream);
            trade.MarketID           = (string)bformatter.Deserialize(stream);
            trade.MaturityDate       = (DateTime)bformatter.Deserialize(stream);
            trade.NegotiationChannel = (string)bformatter.Deserialize(stream);
            trade.NumberOfContracts  = (int)bformatter.Deserialize(stream);
            trade.OptionType         = (string)bformatter.Deserialize(stream);
            trade.Orientation        = (string)bformatter.Deserialize(stream);
            trade.Papel            = (string)bformatter.Deserialize(stream);
            trade.Price            = (Decimal)bformatter.Deserialize(stream);
            trade.ProductID        = (string)bformatter.Deserialize(stream);
            trade.RecordType       = (string)bformatter.Deserialize(stream);
            trade.SellerCode       = (string)bformatter.Deserialize(stream);
            trade.SellerName       = (string)bformatter.Deserialize(stream);
            trade.SequentialNumber = (string)bformatter.Deserialize(stream);
            trade.Serie            = (string)bformatter.Deserialize(stream);
            trade.TradeDate        = (DateTime)bformatter.Deserialize(stream);
            trade.TradeID          = (string)bformatter.Deserialize(stream);
            trade.TraderCode       = (string)bformatter.Deserialize(stream);
            trade.TraderName       = (string)bformatter.Deserialize(stream);
            trade.TradeTimestamp   = (DateTime)bformatter.Deserialize(stream);
            trade.ValDelta         = (Decimal)bformatter.Deserialize(stream);
            trade.ValReference1    = (Decimal)bformatter.Deserialize(stream);
            trade.ValReference2    = (Decimal)bformatter.Deserialize(stream);

            int numtradedetails = (int)bformatter.Deserialize(stream);

            if (numtradedetails > 0)
            {
                for (int i = 0; i < numtradedetails; i++)
                {
                    TradeDetail detail = new TradeDetail();

                    detail.MarketID          = (string)bformatter.Deserialize(stream);
                    detail.NumberOfContracts = (int)bformatter.Deserialize(stream);
                    detail.Price             = (Decimal)bformatter.Deserialize(stream);
                    detail.Rate = (Decimal)bformatter.Deserialize(stream);
                    detail.Type = (string)bformatter.Deserialize(stream);

                    trade.TradeDetails.Add(detail);
                }
            }

            return(trade);
        }
示例#2
0
        /// <summary>
        /// Popula um objeto Trade a partir dos dados lidos do Oracle
        /// </summary>
        /// <param name="odr"></param>
        /// <returns></returns>
        private Trade _Sinacor2Trade(OracleDataReader odr)
        {
            Trade trade = new Trade();

            try
            {
                trade.TradeID = OracleConvert.GetString("NR_SEQCOMI", odr);

                string dtStamp = OracleConvert.GetString("DT_STAMP_N", odr);

                trade.TradeTimestamp = DateTime.ParseExact(dtStamp, "yyyy/MM/dd HH:mm:ss", ciEn);

                trade.TradeDate          = OracleConvert.GetDateTime("DT_NEGOCIO", odr);
                trade.Orientation        = OracleConvert.GetString("CD_NATOPE", odr).Equals("C") ? "B" : "S";
                trade.ProductID          = OracleConvert.GetString("CD_COMMOD", odr);
                trade.MarketID           = OracleConvert.GetString("CD_MERCAD", odr);
                trade.Serie              = OracleConvert.GetString("CD_SERIE", odr);
                trade.NegotiationChannel = OracleConvert.GetString("CD_CANAL", odr);
                trade.AfterHours         = OracleConvert.GetString("IN_AFTER", odr).Equals("S") ? true : false;
                trade.NumberOfContracts  = OracleConvert.GetInt("QT_QTDESP", odr);
                trade.Price              = Convert.ToDecimal(OracleConvert.GetDouble("PR_NEGOCIO", odr));
                trade.SequentialNumber   = OracleConvert.GetInt("NR_SEQORD", odr).ToString();
                trade.Papel              = OracleConvert.GetString("CD_PAPEL", odr);
                trade.MaturityDate       = OracleConvert.GetDateTime("DT_VENC", odr);
                trade.HedgeLongMaturity  = trade.MaturityDate;

                if (trade.Orientation.Equals("B"))
                {
                    trade.BuyerCode  = OracleConvert.GetInt("CD_CLIENTE", odr).ToString();
                    trade.BuyerName  = OracleConvert.GetString("NM_CLIENTE", odr);
                    trade.SellerCode = OracleConvert.GetInt("CD_CORRET", odr).ToString();
                    trade.SellerName = OracleConvert.GetString("NM_CONTRAPARTE", odr);
                }
                else
                {
                    trade.SellerCode = OracleConvert.GetInt("CD_CLIENTE", odr).ToString();
                    trade.SellerName = OracleConvert.GetString("NM_CLIENTE", odr);
                    trade.BuyerCode  = OracleConvert.GetInt("CD_CORRET", odr).ToString();
                    trade.BuyerName  = OracleConvert.GetString("NM_CONTRAPARTE", odr);
                }

                trade.BrokerCode    = "227";
                trade.BrokerName    = "GRADUAL INVESTIMENTOS";
                trade.BrokerType    = "";
                trade.TraderCode    = OracleConvert.GetString("CD_CPFCGC_EMIT", odr);
                trade.TraderName    = OracleConvert.GetString("NM_EMIT_ORDEM", odr);
                trade.ValReference1 = Convert.ToDecimal(OracleConvert.GetDouble("VL_FUT_CURTO", odr));
                trade.ValReference2 = Convert.ToDecimal(OracleConvert.GetDouble("VL_FUT_LONGO", odr));

                if (trade.ProductID.Equals("VID") ||
                    trade.ProductID.Equals("VTF") ||
                    trade.ProductID.Equals("VTC"))
                {
                    TradeDetail detail = new TradeDetail();

                    detail.NumberOfContracts = trade.NumberOfContracts;
                    detail.Price             = trade.Price;
                    detail.MarketID          = trade.MarketID;

                    if (trade.ValReference1 > 0)
                    {
                        detail.Type = "Short";
                    }

                    if (trade.ValReference2 > 0)
                    {
                        detail.Type = "Long";
                    }

                    if (trade.Orientation.Equals("B"))
                    {
                        trade.OptionType = "CALL";
                    }
                    else
                    {
                        trade.OptionType = "PUT";
                    }

                    trade.TradeDetails.Add(detail);
                }

                int tpregistro = OracleConvert.GetInt("TP_REGISTRO", odr);

                switch (tpregistro)
                {
                case 1: trade.RecordType = "NW"; break;

                case 2: trade.RecordType = "DL"; break;

                case 3: trade.RecordType = "AM"; break;

                default: trade.RecordType = "IV"; break;
                }

                return(trade);
            }
            catch (Exception ex)
            {
                logger.Error("_Sinacor2Trade(): (" + ex.StackTrace + ") [" + ex.Message + "]");
            }

            return(null);
        }