/// <summary>
        /// Gets the equity order detail from database
        /// </summary>
        /// <param name="orderExchangeRef">order reference to get details for</param>
        /// <returns>true if record found, false otherwise</returns>
        private bool GetOrderRecordFromDatabase(string orderExchangeRef)
        {
            bool doesOrderRecordExist = false;

            DBLibrary   dbLib       = new DBLibrary();
            DBUtilities dbUtilities = new DBUtilities();

            try
            {
                ArrayList paramList = new ArrayList
                {
                    dbUtilities.CreateSqlParamater("@orderRef", SqlDbType.VarChar, 50,
                                                   ParameterDirection.Input, orderExchangeRef)
                };

                // Query the database for an orderRecord with given orderRecordId
                DataSet ds = dbLib.ExecuteProcedureDS("sp_select_st_derivatives_orderbook", paramList);

                if (ds != null &&
                    ds.Tables != null &&
                    ds.Tables.Count > 0)
                {
                    DataTable dt = ds.Tables[0];

                    if (dt.Rows.Count > 0)
                    {
                        DataRow dr = dt.Rows[0];

                        // Get StockOrderBookRecord data
                        OrderDate          = DateTime.Parse(dr["order_date"].ToString());
                        ContractName       = dr["contract_name"].ToString();
                        Direction          = (OrderDirection)Enum.Parse(typeof(OrderDirection), dr["direction"].ToString());
                        Quantity           = int.Parse(dr["qty"].ToString());
                        Price              = double.Parse(dr["price"].ToString());
                        OrderRefenceNumber = dr["order_ref"].ToString();
                        Exchange           = (Exchange)Enum.Parse(typeof(Exchange), dr["exchange"].ToString());
                        OrderStatus        = (OrderStatus)Enum.Parse(typeof(OrderStatus), dr["order_status"].ToString());
                        OpenQty            = int.Parse(dr["qty_open"].ToString());
                        ExecutedQty        = int.Parse(dr["qty_executed"].ToString());
                        ExpiredQty         = int.Parse(dr["qty_expired"].ToString());
                        CancelledQty       = int.Parse(dr["qty_cancelled"].ToString());
                        StopLossPrice      = double.Parse(dr["stoploss_price"].ToString());
                        UpdatedAt          = DateTime.Parse(dr["status_update_time"].ToString());
                        AlgoId             = int.Parse(dr["algo_id"].ToString());

                        doesOrderRecordExist = true;
                    }
                }
            }
            catch (Exception ex)
            {
                // If we failed, trace the error for log analysis
                Logger.LogException(ex);
                throw;
            }

            return(doesOrderRecordExist);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Method to read recent log
        /// </summary>
        /// <param name="reportId">Id of the report</param>
        /// <returns>log string</returns>
        public static string ReadRecentLog(string reportId)
        {
            string latestLog = string.Empty;

            ArrayList paramList = new ArrayList();

            paramList.Add(dbUtilities.CreateSqlParamater("@id", SqlDbType.VarChar, ParameterDirection.Input, reportId));

            DataSet ds = dbLib.ExecuteProcedureDS("sp_select_pdr_logs", paramList);

            if (ds != null &&
                ds.Tables != null &&
                ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                latestLog = (ds.Tables[0].Rows[0])["status_message"].ToString();
            }

            return(latestLog);
        }
Exemplo n.º 3
0
        public static bool DoesExistEOPStatsForMinMaxAlgos(string contractName,
                                                           short algoId,
                                                           double marketDirection,
                                                           string r1,
                                                           string r2)
        {
            //EOPTradeStats eopTradeStats = null;
            DBUtilities dbUtilities = new DBUtilities();
            DBLibrary   dbLib       = new DBLibrary("");

            ArrayList paramList = new ArrayList
            {
                dbUtilities.CreateSqlParamater("@contract_name", SqlDbType.VarChar, 100,
                                               ParameterDirection.Input, contractName),
                dbUtilities.CreateSqlParamater("@market_direction_percentage",
                                               SqlDbType.Decimal, ParameterDirection.Input,
                                               marketDirection),
                dbUtilities.CreateSqlParamater("@algo_id", SqlDbType.SmallInt,
                                               ParameterDirection.Input, algoId)
            };

            var param = dbUtilities.CreateSqlParamater("@r1", SqlDbType.VarChar, 100, ParameterDirection.Input, r1);

            param.IsNullable = true;
            param.Value      = param.Value ?? DBNull.Value;
            paramList.Add(param);

            param            = dbUtilities.CreateSqlParamater("@r2", SqlDbType.VarChar, 100, ParameterDirection.Input, r2);
            param.IsNullable = true;
            param.Value      = param.Value ?? DBNull.Value;
            paramList.Add(param);

            // Query the database
            DataSet ds = dbLib.ExecuteProcedureDS("sp_select_st_trading_eop_statsbook", paramList);

            if (ds != null &&
                ds.Tables != null &&
                ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                return(true);
            }

            return(false);
        }