Esempio n. 1
0
        public void RecordTicket(string connectionstr, string nThreadID, FUTUREORDER orderin, string stratname)
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(connectionstr))
                {
                    SqlCommand sqlcmd = new SqlCommand();
                    sqlcmd.Parameters.Add(new SqlParameter("StratName", stratname));
                    sqlcmd.Parameters.Add(new SqlParameter("nThreadID", nThreadID));
                    sqlcmd.Parameters.Add(new SqlParameter("BstrFullAccount", orderin.bstrFullAccount));
                    sqlcmd.Parameters.Add(new SqlParameter("BstrPrice", orderin.bstrPrice));
                    sqlcmd.Parameters.Add(new SqlParameter("BstrStockNo", orderin.bstrStockNo));
                    sqlcmd.Parameters.Add(new SqlParameter("nQty", orderin.nQty));
                    sqlcmd.Parameters.Add(new SqlParameter("sBuySell", orderin.sBuySell));
                    sqlcmd.Parameters.Add(new SqlParameter("sDayTrade", orderin.sDayTrade));
                    sqlcmd.Parameters.Add(new SqlParameter("sTradeType", orderin.sTradeType));
                    sqlcmd.Parameters.Add(new SqlParameter("sNewClose", orderin.sNewClose));

                    connection.Open();
                    sqlcmd.Connection  = connection;
                    sqlcmd.CommandText = @"INSERT INTO [dbo].[tblOrder_Ticket] (nThreadID, StratName, BstrFullAccount, BstrPrice, BstrStockNo, nQty, sBuySell,
                                     sDayTrade, sTradeType, sNewClose) VALUES (@nThreadID, @StratName, @BstrFullAccount, @BstrPrice, @BstrStockNo, @nQty, @sBuySell, 
                                    @sDayTrade, @sTradeType, @sNewClose)";
                    sqlcmd.ExecuteNonQuery();
                    connection.Close();
                }
            }
            catch (Exception ex)
            {
                RecordSystemLog(connectionstr, "RecordTicket " + ex.Message, DEBUG);
            }
        }
Esempio n. 2
0
        private void MyOnFutureOrderSignal(string strLogInID, bool bAsyncOrder, FUTUREORDER pStock)
        {
            m_nCode = m_pSKOrder.SendFutureOrder(strLogInID, bAsyncOrder, pStock, out string strMessage);

            WriteMessage("期貨委託2:" + strMessage);
            SendReturnMessage("Order", m_nCode, "SendFutureOrder");
        }
Esempio n. 3
0
        private void MyOnFutureOrderSignal(string strLogInID, bool bAsyncOrder, FUTUREORDER pStock)
        {
            string strMessage = "";

            m_nCode = m_pSKOrder.SendFutureOrder(strLogInID, bAsyncOrder, pStock, out strMessage);
            RecordLog("4.1 Order is issued !");
            WriteMessage("期貨委託:" + strMessage);
        }
Esempio n. 4
0
        private void MyOnFutureOrderSignal(string strLogInID, bool bAsyncOrder, FUTUREORDER pStock, string stratname)
        {
            string strMessage;

            m_nCode = m_pSKOrder.SendFutureOrder(strLogInID, bAsyncOrder, pStock, out strMessage);
            util.RecordLog(connectionstr, "4.1 Order is issued !", util.INFO);
            util.RecordTicket(connectionstr, strMessage, pStock, stratname);
            WriteMessage("期貨委託:" + strMessage);
        }
Esempio n. 5
0
        private void Disassemble_Click(object sender, EventArgs e)
        {
            if (m_UserAccount == "")
            {
                MessageBox.Show("請選擇期貨帳號");
                return;
            }

            string strTarget;
            
            int nBidAsk;
            
            int nQty;


            if (txtTargetDisassemble.Text.Trim() == "")
            {
                MessageBox.Show("請輸入拆解商品代碼");
                return;
            }
            strTarget = txtTargetDisassemble.Text.Trim();

            if (BuySellDisassemble.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇拆解商品買賣別");
                return;
            }
            nBidAsk = BuySellDisassemble.SelectedIndex;


            if (int.TryParse(QtyDisassemble.Text.Trim(), out nQty) == false)
            {
                MessageBox.Show("拆解商品口數請輸入數字");
                return;
            }


            FUTUREORDER pFutureOrder = new FUTUREORDER();

            pFutureOrder.bstrFullAccount = m_UserAccount;

            pFutureOrder.bstrStockNo = strTarget;
            
            pFutureOrder.nQty = nQty;
            pFutureOrder.sBuySell = (short)nBidAsk;
            


            if (OnTwoOrderToDisassemblySignal != null)
            {
                OnTwoOrderToDisassemblySignal(m_UserID, false, pFutureOrder);
            }
        }
Esempio n. 6
0
        private void button3_Click(object sender, EventArgs e)
        {
            FUTUREORDER pFutureOrder = new FUTUREORDER();

            pFutureOrder.bstrFullAccount = GetMorningOrNightVars(0);//return account
            pFutureOrder.bstrPrice       = "12000";
            pFutureOrder.bstrStockNo     = "MTX00";
            pFutureOrder.nQty            = 1;
            pFutureOrder.sBuySell        = 0;
            pFutureOrder.sDayTrade       = 0;
            //(short)Convert.ToInt32(reader["DayTrade"].ToString()); //當沖0:否 1:是
            pFutureOrder.sTradeType = 0;
            //(short)Convert.ToInt32(reader["TradeType"].ToString()); ;//0:ROD  1:IOC  2:FOK

            //0新倉 1平倉 2自動
            pFutureOrder.sNewClose = 2;
            OnFutureOrderSignal?.Invoke("", true, pFutureOrder, "stratname1");
        }
Esempio n. 7
0
        private void CoverAllProduct_Click(object sender, EventArgs e)
        {
            if (m_UserAccount == "")
            {
                MessageBox.Show("請選擇期貨帳號");
                return;
            }

            string strTarget;

            int nQty;

            if (TxtTargetAllCover.Text.Trim() == "")
            {
                MessageBox.Show("請輸入雙邊部位了結商品代碼");
                return;
            }
            strTarget = TxtTargetAllCover.Text.Trim();

            if (int.TryParse(QtyAllCover.Text.Trim(), out nQty) == false)
            {
                MessageBox.Show("雙邊部位了結商品口數,請輸入數字");
                return;
            }


            FUTUREORDER pFutureOrder = new FUTUREORDER();

            pFutureOrder.bstrFullAccount = m_UserAccount;

            pFutureOrder.bstrStockNo = strTarget;

            pFutureOrder.nQty = nQty;

            if (OnCoverAllProductSignal != null)
            {
                OnCoverAllProductSignal(m_UserID, false, pFutureOrder);
            }
        }
Esempio n. 8
0
        private void TFTOMIT_OnOptionMITOrderSignal(string strLogInID, bool bAsyncOrder, FUTUREORDER pOrder)
        {
            string strMessage = "";

            m_nCode = m_pSKOrder.SendOptionMITOrder(strLogInID, bAsyncOrder, pOrder, out strMessage);

            WriteMessage("選擇權MIT委託:" + strMessage);
            SendReturnMessage("Order", m_nCode, "SendOptionMITOrder");
        }
Esempio n. 9
0
        private void futureStopLossControl1_OnOptionStopLossOrderSignal(string strLogInID, bool bAsyncOrder, FUTUREORDER pOrder)
        {
            string strMessage = "";

            m_nCode = m_pSKOrder.SendOptionStopLossOrder(strLogInID, bAsyncOrder, pOrder, out strMessage);

            WriteMessage("選擇權停損委託:" + strMessage);
            SendReturnMessage("Order", m_nCode, "SendOptionStopLossOrder");
        }
Esempio n. 10
0
        private void optionOrderControl1_OnCoverAllProductSignal(string strLogInID, bool bAsyncOrder, FUTUREORDER pFutureOrder)
        {
            string strMessage = "";

            m_nCode = m_pSKOrder.CoverAllProduct(strLogInID, bAsyncOrder, pFutureOrder, out strMessage);

            WriteMessage("雙邊部位了結:" + strMessage);
            SendReturnMessage("Order", m_nCode, "CoverAllProduct");
        }
Esempio n. 11
0
        private void BtnAssembleOption_Click(object sender, EventArgs e)
        {
            if (m_UserAccount == "")
            {
                MessageBox.Show("請選擇期貨帳號");
                return;
            }

            string strOptionNo1;
            string strOptionNo2;
            int nBidAsk1;
            int nBidAsk2;
            int nQty;


            if (txtST1.Text.Trim() == "")
            {
                MessageBox.Show("請輸入組合商品代碼");
                return;
            }
            strOptionNo1 = txtST1.Text.Trim();
            if (txtST2.Text.Trim() == "")
            {
                MessageBox.Show("請輸入目標商品代碼");
                return;
            }
            strOptionNo2 = txtST2.Text.Trim();

            if (comBS1.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇組合商品買賣別");
                return;
            }
            nBidAsk1 = comBS1.SelectedIndex;
            if (comBS2.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇目標商品買賣別");
                return;
            }
            nBidAsk2 = comBS2.SelectedIndex;

            if (int.TryParse(txtQyt1.Text.Trim(), out nQty) == false)
            {
                MessageBox.Show("組合商品口數請輸入數字");
                return;
            }


            FUTUREORDER pFutureOrder = new FUTUREORDER();

            pFutureOrder.bstrFullAccount = m_UserAccount;

            pFutureOrder.bstrStockNo = strOptionNo1;
            pFutureOrder.bstrStockNo2 = strOptionNo2;
            pFutureOrder.nQty = nQty;
            pFutureOrder.sBuySell = (short)nBidAsk1;
            pFutureOrder.sBuySell2 = (short)nBidAsk2;


            if (OnAssembleOptionSignal != null)
            {
                OnAssembleOptionSignal(m_UserID, false, pFutureOrder);
            }
        }
        private void btnSendOptionOrderAsync_Click(object sender, EventArgs e)
        {
            if (m_UserAccount == "")
            {
                MessageBox.Show("請選擇期貨帳號");
                return;
            }

            string strFutureNo;
            int    nBidAsk;
            int    nPeriod;
            int    nFlag;
            string strPrice;
            string strTigger;
            int    nQty;


            if (txtStockNo3.Text.Trim() == "")
            {
                MessageBox.Show("請輸入商品代碼");
                return;
            }
            strFutureNo = txtStockNo3.Text.Trim();

            if (boxBidAsk3.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇買賣別");
                return;
            }
            nBidAsk = boxBidAsk3.SelectedIndex;

            if (boxPeriod3.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇委託條件");
                return;
            }
            nPeriod = boxPeriod3.SelectedIndex;

            if (boxFlag3.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇當沖與否");
                return;
            }
            nFlag = boxFlag3.SelectedIndex;

            strPrice = txtPrice3.Text.Trim();

            if (int.TryParse(txtQty3.Text.Trim(), out nQty) == false)
            {
                MessageBox.Show("委託量請輸入數字");
                return;
            }
            strTigger = txtTrigger3.Text.Trim();

            FUTUREORDER pFutureOrder = new FUTUREORDER();

            pFutureOrder.bstrFullAccount = m_UserAccount;
            pFutureOrder.bstrPrice       = strPrice;
            pFutureOrder.bstrStockNo     = strFutureNo;
            pFutureOrder.nQty            = nQty;
            pFutureOrder.sBuySell        = (short)nBidAsk;
            pFutureOrder.sNewClose       = (short)nFlag;
            pFutureOrder.sTradeType      = (short)nPeriod;
            pFutureOrder.bstrTrigger     = strTigger;

            if (OnOptionStopLossOrderSignal != null)
            {
                OnOptionStopLossOrderSignal(m_UserID, true, pFutureOrder);
            }
        }
        private void btnSendOptionOrderAsync_Click(object sender, EventArgs e)
        {
            if (m_UserAccount == "")
            {
                MessageBox.Show("請選擇期貨帳號");
                return;
            }

            string strFutureNo;
            int    nBidAsk;
            int    nPeriod;
            int    nFlag;
            string strPrice;
            string strTrigger;
            int    nQty;
            int    nReserved;

            if (txtStockNo3.Text.Trim() == "")
            {
                MessageBox.Show("請輸入商品代碼");
                return;
            }
            strFutureNo = txtStockNo3.Text.Trim();

            if (boxBidAsk3.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇買賣別");
                return;
            }
            nBidAsk = boxBidAsk3.SelectedIndex;

            if (boxPeriod3.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇委託條件");
                return;
            }
            nPeriod = boxPeriod3.SelectedIndex;

            if (boxNewCloseOST.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇倉位");
                return;
            }
            nFlag = boxNewCloseOST.SelectedIndex;

            double dPrice = 0.0;

            if (double.TryParse(txtPrice3.Text.Trim(), out dPrice) == false && txtPrice.Text.Trim() != "P")
            {
                MessageBox.Show("委託價請輸入數字");
                return;
            }
            strPrice = txtPrice3.Text.Trim();

            if (int.TryParse(txtQty3.Text.Trim(), out nQty) == false)
            {
                MessageBox.Show("委託量請輸入數字");
                return;
            }

            if (double.TryParse(txtTrigger3.Text.Trim(), out dPrice) == false)
            {
                MessageBox.Show("觸發價請輸入數字");
                return;
            }
            strTrigger = txtTrigger3.Text.Trim();

            if (ReservedBox3.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇盤別");
                return;
            }
            nReserved = ReservedBox3.SelectedIndex;

            FUTUREORDER pFutureOrder = new FUTUREORDER();

            pFutureOrder.bstrFullAccount = m_UserAccount;
            pFutureOrder.bstrPrice       = strPrice;
            pFutureOrder.bstrStockNo     = strFutureNo;
            pFutureOrder.nQty            = nQty;
            pFutureOrder.sBuySell        = (short)nBidAsk;
            pFutureOrder.sNewClose       = (short)nFlag;
            pFutureOrder.sTradeType      = (short)nPeriod;
            pFutureOrder.bstrTrigger     = strTrigger;
            pFutureOrder.sReserved       = (short)nReserved;

            //pFutureOrder.bstrTrigger = "";
            pFutureOrder.bstrDealPrice   = "";
            pFutureOrder.bstrMovingPoint = "";
            //pFutureOrder.bstrPrice = "";

            if (OnOptionStopLossOrderSignal != null)
            {
                OnOptionStopLossOrderSignal(m_UserID, true, pFutureOrder);
            }
        }
Esempio n. 14
0
        private void GetCurrentOrder()
        {
            SqlConnection connection = null;

            try
            {
                using (connection = new SqlConnection(connectionstr))
                {
                    connection.Open();
                    int        intervalMins = Convert.ToInt32(textBox1.Text.ToString()) / 1000 / 60;//convert to minute
                    SqlCommand sqlcmd       = new SqlCommand();
                    sqlcmd.Connection = connection;

                    RecordLog("4.2 GetCurrentOrder Start");
                    sqlcmd.CommandText = "SELECT * FROM [dbo].[Orders] WHERE SignalTime BETWEEN " +
                                         " FORMAT(DATEADD(minute,-" + (intervalMins + 1) + ",GETDATE()),'yyyy-MM-dd HH:mm')+':00' AND " +
                                         " FORMAT(DATEADD(minute,-" + (intervalMins - 1) + ",GETDATE()),'yyyy-MM-dd HH:mm')+':00'";

                    //sqlcmd.CommandText = "SELECT * FROM [Stock].[dbo].[Orders] WHERE SignalTime=GETDATE() ";
                    //sqlcmd.CommandText = "SELECT TOP 2* FROM [Stock].[dbo].[Orders] ";
                    using (SqlDataReader reader = sqlcmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            FUTUREORDER pFutureOrder = new FUTUREORDER();
                            pFutureOrder.bstrFullAccount = GetFutureAccount();
                            pFutureOrder.bstrPrice       = reader["DealPrice"].ToString();
                            pFutureOrder.bstrStockNo     = reader["stockNo"].ToString();
                            pFutureOrder.nQty            = Convert.ToInt16(reader["Size"].ToString());
                            pFutureOrder.sBuySell        = Convert.ToInt16(reader["BuyOrSell"].ToString());
                            pFutureOrder.sDayTrade       = Convert.ToInt16(reader["DayTrade"].ToString());
                            //(short)Convert.ToInt32(reader["DayTrade"].ToString()); //當沖0:否 1:是
                            pFutureOrder.sTradeType = Convert.ToInt16(reader["TradeType"].ToString());
                            //(short)Convert.ToInt32(reader["TradeType"].ToString()); ;//0:ROD  1:IOC  2:FOK

                            //0新倉 1平倉 2自動
                            pFutureOrder.sNewClose = 2;

                            if (GetSkipOrdersCount() == 0)
                            {
                                OnFutureOrderSignal?.Invoke("", false, pFutureOrder);
                                OrderPushToLine();
                            }
                            else
                            {
                                DecreaseSkipOrdersCount();
                                OrderPushToLine();
                            }
                            RecordLog("4.0 Order loop is finished !");
                        }
                    }
                    RecordLog("4.3 GetCurrentOrder Done");
                    connection.Close();
                }
            }
            catch (Exception ex)
            {
                RecordLog("5 " + ex.Message);
            }
            finally
            {
                connection.Close();
            }
        }
Esempio n. 15
0
        /*通常下單時間會落在5x秒到下一分x秒, 因calibiration關係會落在x+-5 second
         *使用RoundToNearest回復到正常分0秒
         */
        private void GetCurrentOrder()
        {
            SqlConnection connection = null;

            try
            {
                string sqltext = "";
                foreach (int interval in targetinterval)
                {
                    sqltext += " SignalTime=DATEADD(minute, -" + interval + ", @execution_dt) OR";
                }
                sqltext = sqltext.Substring(0, sqltext.Length - 3);//remove last OR
                using (connection = new SqlConnection(connectionstr))
                {
                    connection.Open();
                    //int intervalMins = Convert.ToInt32(textBox1.Text.ToString()) / 1000 / 60;//convert to minute
                    //intervalMins = 5;
                    SqlCommand sqlcmd = new SqlCommand();
                    sqlcmd.Connection = connection;
                    DateTime     nearestMinute     = util.RoundToNearest(DateTime.Now, TimeSpan.FromMinutes(1));
                    SqlParameter prar_execution_dt = sqlcmd.Parameters.Add("@execution_dt", System.Data.SqlDbType.DateTime);
                    //SqlParameter interval_para = sqlcmd.Parameters.Add("@intervalMins", System.Data.SqlDbType.Int);
                    prar_execution_dt.Value = nearestMinute;
                    //interval_para.Value = intervalMins;

                    util.RecordLog(connectionstr, "4.2 GetCurrentOrder Start", util.INFO);
                    sqlcmd.CommandText = "SELECT * FROM [dbo].[Orders] WHERE " + sqltext;

                    //sqlcmd.CommandText = "SELECT TOP 2 * FROM [Stock].[dbo].[Orders] WHERE orderid=53787";
                    using (SqlDataReader reader = sqlcmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            FUTUREORDER pFutureOrder = new FUTUREORDER();
                            //將三個order欄位資訊放入stratName, 方便委託成交回報串資料
                            string stratName = reader["StrategyName"].ToString() + ";" + reader["SignalTime"].ToString() + ";" + reader["Price"].ToString();
                            pFutureOrder.bstrFullAccount = GetMorningOrNightVars(0);//return account
                            pFutureOrder.bstrPrice       = reader["DealPrice"].ToString();
                            pFutureOrder.bstrStockNo     = reader["stockNo"].ToString();
                            pFutureOrder.nQty            = Convert.ToInt16(reader["Size"].ToString());
                            pFutureOrder.sBuySell        = Convert.ToInt16(reader["BuyOrSell"].ToString());
                            pFutureOrder.sDayTrade       = Convert.ToInt16(reader["DayTrade"].ToString());
                            //(short)Convert.ToInt32(reader["DayTrade"].ToString()); //當沖0:否 1:是
                            pFutureOrder.sTradeType = Convert.ToInt16(reader["TradeType"].ToString());
                            //(short)Convert.ToInt32(reader["TradeType"].ToString()); ;//0:ROD  1:IOC  2:FOK
                            pFutureOrder.sNewClose = 2;                                     //0新倉 1平倉 2自動
                            OnFutureOrderSignal?.Invoke("", true, pFutureOrder, stratName); //true 為非同步委託
                            util.RecordLog(connectionstr, "4.0 Order loop is finished !", util.INFO);
                        }
                    }
                    util.RecordLog(connectionstr, "4.3 GetCurrentOrder Done", util.INFO);
                    connection.Close();
                }
            }
            catch (Exception ex)
            {
                util.RecordLog(connectionstr, "GetCurrentOrder " + ex.ToString(), util.ALARM);
            }
            finally
            {
                connection.Close();
            }
        }
Esempio n. 16
0
        private void btnSendFutureOrderCLR_Click(object sender, EventArgs e)
        {
            m_UserAccount = "F0200009834349";
            if (m_UserAccount == "")
            {
                MessageBox.Show("請選擇期貨帳號");
                return;
            }

            string strFutureNo;
            int    nBidAsk;
            int    nPeriod;
            int    nFlag;
            string strPrice;
            int    nQty;
            int    nNewClose;
            int    nReserved;


            if (txtStockNo.Text.Trim() == "")
            {
                MessageBox.Show("請輸入商品代碼");
                return;
            }
            strFutureNo = txtStockNo.Text.Trim();

            if (boxBidAsk.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇買賣別");
                return;
            }
            nBidAsk = boxBidAsk.SelectedIndex;

            if (boxPeriod.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇委託條件");
                return;
            }
            nPeriod = boxPeriod.SelectedIndex;

            if (boxNewClose.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇倉別");
                return;
            }
            nNewClose = boxNewClose.SelectedIndex;

            if (boxFlag.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇當沖與否");
                return;
            }
            nFlag = boxFlag.SelectedIndex;

            double dPrice = 0.0;

            if (double.TryParse(txtPrice.Text.Trim(), out dPrice) == false && txtPrice.Text.Trim() != "M" && txtPrice.Text.Trim() != "P")
            {
                MessageBox.Show("委託價請輸入數字");
                return;
            }
            strPrice = txtPrice.Text.Trim();

            if (int.TryParse(txtQty.Text.Trim(), out nQty) == false)
            {
                MessageBox.Show("委託量請輸入數字");
                return;
            }

            if (boxReserved.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇盤別");
                return;
            }
            nReserved = boxReserved.SelectedIndex;

            FUTUREORDER pFutureOrder = new FUTUREORDER();

            pFutureOrder.bstrFullAccount = m_UserAccount;
            pFutureOrder.bstrPrice       = strPrice;
            pFutureOrder.bstrStockNo     = strFutureNo;
            pFutureOrder.nQty            = nQty;
            pFutureOrder.sBuySell        = (short)nBidAsk;
            pFutureOrder.sDayTrade       = (short)nFlag;
            pFutureOrder.sTradeType      = (short)nPeriod;
            pFutureOrder.sNewClose       = (short)nNewClose;
            pFutureOrder.sReserved       = (short)nReserved;

            OnFutureOrderCLRSignal?.Invoke(m_UserID, false, pFutureOrder);
        }
Esempio n. 17
0
        private void btnSendFutureOrderAsync_Click(object sender, EventArgs e)
        {
            if (m_UserAccount == "")
            {
                MessageBox.Show("請選擇期貨帳號");
                return;
            }

            string strFutureNo;
            int    nBidAsk;
            int    nPeriod;
            int    nFlag;
            string strPrice;
            int    nQty;

            if (txtStockNo.Text.Trim() == "")
            {
                MessageBox.Show("請輸入商品代碼");
                return;
            }
            strFutureNo = txtStockNo.Text.Trim();

            if (boxBidAsk.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇買賣別");
                return;
            }
            nBidAsk = boxBidAsk.SelectedIndex;

            if (boxPeriod.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇委託條件");
                return;
            }
            nPeriod = boxPeriod.SelectedIndex;

            if (boxFlag.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇當沖與否");
                return;
            }
            nFlag = boxFlag.SelectedIndex;

            double dPrice = 0.0;

            //if (double.TryParse(txtPrice.Text.Trim(), out dPrice) == false)
            if (double.TryParse(txtPrice.Text.Trim(), out dPrice) == false && txtPrice.Text.Trim() != "M" && txtPrice.Text.Trim() != "P")
            {
                MessageBox.Show("委託價請輸入數字");
                return;
            }
            strPrice = txtPrice.Text.Trim();

            if (int.TryParse(txtQty.Text.Trim(), out nQty) == false)
            {
                MessageBox.Show("委託量請輸入數字");
                return;
            }

            FUTUREORDER pFutureOrder = new FUTUREORDER();

            pFutureOrder.bstrFullAccount = m_UserAccount;
            pFutureOrder.bstrPrice       = strPrice;
            pFutureOrder.bstrStockNo     = strFutureNo;
            pFutureOrder.nQty            = nQty;
            pFutureOrder.sBuySell        = (short)nBidAsk;
            pFutureOrder.sDayTrade       = (short)nFlag;
            pFutureOrder.sTradeType      = (short)nPeriod;

            if (OnFutureOrderSignal != null)
            {
                OnFutureOrderSignal(m_UserID, true, pFutureOrder);
            }
        }
Esempio n. 18
0
        private void futureOrderControl1_OnFutureOrderSignal(string strLogInID, bool bAsyncOrder, FUTUREORDER pStock)
        {
            string strMessage = "";

            m_nCode = m_pSKOrder.SendFutureOrder(strLogInID, bAsyncOrder, pStock, out strMessage);
            util.RecordTicket(connectionstr, strMessage, pStock, "");
            WriteMessage("期貨委託:" + strMessage);
            SendReturnMessage("Order", m_nCode, "SendFutureOrder");
        }
Esempio n. 19
0
        private void futureOrderControl1_OnFutureOrderCLRSignal(string strLogInID, bool bAsyncOrder, FUTUREORDER pStock)
        {
            string strMessage = "";

            m_nCode = m_pSKOrder.SendFutureOrderCLR(strLogInID, bAsyncOrder, pStock, out strMessage);

            WriteMessage("期貨委託含倉位盤別:" + strMessage);
            SendReturnMessage("Order", m_nCode, "SendFutureOrderCLR");
        }
Esempio n. 20
0
        private void optionOrderControl1_OnDuplexOrderSignal(string strLogInID, bool bAsyncOrder, FUTUREORDER pStock)
        {
            string strMessage = "";

            m_nCode = m_pSKOrder.SendDuplexOrder(strLogInID, bAsyncOrder, pStock, out strMessage);

            WriteMessage("選擇權複式單委託:" + strMessage);
            SendReturnMessage("Order", m_nCode, "SendDuplexOrder");
        }
Esempio n. 21
0
        private void btnSendOptionMITOrderAsync_Click(object sender, EventArgs e)
        {
            if (m_UserAccount == "")
            {
                MessageBox.Show("請選擇期貨帳號");
                return;
            }

            string strFutureNo;
            int    nBidAsk;
            int    nPeriod;

            string strDealPrice;
            string strTigger;
            int    nQty;
            int    nNewClose;

            if (txtOPStockNo.Text.Trim() == "")
            {
                MessageBox.Show("請輸入商品代碼");
                return;
            }
            strFutureNo = txtOPStockNo.Text.Trim();

            if (boxBidAsk3.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇買賣別");
                return;
            }

            if (boxNewCloseOP.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇倉別");
                return;
            }
            nNewClose = boxNewCloseOP.SelectedIndex;

            nBidAsk = boxBidAsk3.SelectedIndex;

            if (boxPeriod3.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇委託條件");
                return;
            }
            nPeriod = boxPeriod3.SelectedIndex;


            double dPrice = 0.0;

            if (double.TryParse(txtDealPrice2.Text.Trim(), out dPrice) == false)
            {
                MessageBox.Show("成交價請輸入數字");
                return;
            }
            strDealPrice = txtDealPrice2.Text.Trim();

            if (int.TryParse(txtQty3.Text.Trim(), out nQty) == false)
            {
                MessageBox.Show("委託量請輸入數字");
                return;
            }

            if (double.TryParse(txtTrigger3.Text.Trim(), out dPrice) == false)
            {
                MessageBox.Show("觸發價請輸入數字");
                return;
            }
            strTigger = txtTrigger3.Text.Trim();



            FUTUREORDER pFutureOrder = new FUTUREORDER();

            pFutureOrder.bstrFullAccount = m_UserAccount;

            pFutureOrder.bstrStockNo = strFutureNo;
            pFutureOrder.nQty        = nQty;
            pFutureOrder.sBuySell    = (short)nBidAsk;

            pFutureOrder.sNewClose       = (short)nNewClose;
            pFutureOrder.sTradeType      = (short)nPeriod;
            pFutureOrder.bstrTrigger     = strTigger;
            pFutureOrder.bstrDealPrice   = strDealPrice;
            pFutureOrder.bstrMovingPoint = "";
            pFutureOrder.bstrPrice       = "";

            if (OnOptionMITOrderSignal != null)
            {
                OnOptionMITOrderSignal(m_UserID, true, pFutureOrder);
            }
        }
Esempio n. 22
0
        private void optionOrderControl1_OnAssembleOptionSignal(string strLogInID, bool bAsyncOrder, FUTUREORDER pFutureOrder)
        {
            string strMessage = "";

            m_nCode = m_pSKOrder.AssembleOptions(strLogInID, bAsyncOrder, pFutureOrder, out strMessage);

            WriteMessage("選擇權組合單委託:" + strMessage);
            SendReturnMessage("Order", m_nCode, "SendAssemleOption");
        }
        private void btnMovingStopLossOrderAsync_Click(object sender, EventArgs e)
        {
            if (m_UserAccount == "")
            {
                MessageBox.Show("請選擇期貨帳號");
                return;
            }

            string strFutureNo;
            int    nBidAsk;
            int    nPeriod;
            int    nFlag;
            string strMovingPint;
            string strTigger;
            int    nQty;


            if (txtStockNo2.Text.Trim() == "")
            {
                MessageBox.Show("請輸入商品代碼");
                return;
            }
            strFutureNo = txtStockNo2.Text.Trim();

            if (boxBidAsk2.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇買賣別");
                return;
            }
            nBidAsk = boxBidAsk2.SelectedIndex;

            if (boxPeriod2.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇委託條件");
                return;
            }
            nPeriod = boxPeriod2.SelectedIndex;

            if (boxFlag2.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇當沖與否");
                return;
            }
            nFlag = boxFlag2.SelectedIndex;

            double dPrice = 0.0;

            if (double.TryParse(txtMovingPoint.Text.Trim(), out dPrice) == false)
            {
                MessageBox.Show("移動點數請輸入數字");
                return;
            }
            strMovingPint = txtMovingPoint.Text.Trim();

            if (int.TryParse(txtQty2.Text.Trim(), out nQty) == false)
            {
                MessageBox.Show("委託量請輸入數字");
                return;
            }

            strTigger = txtTrigger2.Text.Trim();

            FUTUREORDER pFutureOrder = new FUTUREORDER();

            pFutureOrder.bstrFullAccount = m_UserAccount;
            //pFutureOrder.bstrPrice = strPrice;
            pFutureOrder.bstrStockNo     = strFutureNo;
            pFutureOrder.nQty            = nQty;
            pFutureOrder.sBuySell        = (short)nBidAsk;
            pFutureOrder.sDayTrade       = (short)nFlag;
            pFutureOrder.sTradeType      = (short)nPeriod;
            pFutureOrder.bstrTrigger     = strTigger;
            pFutureOrder.bstrMovingPoint = strMovingPint;

            if (OnMovingStopLossOrderSignal != null)
            {
                OnMovingStopLossOrderSignal(m_UserID, true, pFutureOrder);
            }
        }
Esempio n. 24
0
        private void optionOrderControl1_OnTwoOrderToDisassemblySignal(string strLogInID, bool bAsyncOrder, FUTUREORDER pFutureOrder)
        {
            string strMessage = "";

            m_nCode = m_pSKOrder.DisassembleOptions(strLogInID, bAsyncOrder, pFutureOrder, out strMessage);

            WriteMessage("複式單拆解:" + strMessage);
            SendReturnMessage("Order", m_nCode, "TwoOrderToDisassembly");
        }
Esempio n. 25
0
        private void btnSendFutureStopOrder_Click(object sender, EventArgs e)
        {
            if (m_UserAccount == "")
            {
                MessageBox.Show("請選擇期貨帳號");
                return;
            }

            string strFutureNo;
            int    nBidAsk;
            int    nPeriod;
            int    nFlag;
            string strPrice;
            string strTigger;
            int    nQty;
            int    nNewClose;
            int    nReserved;


            if (txtStockNo.Text.Trim() == "")
            {
                MessageBox.Show("請輸入商品代碼");
                return;
            }
            strFutureNo = txtStockNo.Text.Trim();

            if (boxBidAsk.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇買賣別");
                return;
            }
            nBidAsk = boxBidAsk.SelectedIndex;

            if (boxPeriod.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇委託條件");
                return;
            }
            nPeriod = boxPeriod.SelectedIndex;

            if (boxNewCloseSTP.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇倉別");
                return;
            }
            nNewClose = boxNewCloseSTP.SelectedIndex;

            if (boxFlag.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇當沖與否");
                return;
            }
            nFlag = boxFlag.SelectedIndex;

            double dPrice = 0.0;

            if (double.TryParse(txtPrice.Text.Trim(), out dPrice) == false)
            {
                MessageBox.Show("委託價請輸入數字");
                return;
            }
            strPrice = txtPrice.Text.Trim();

            if (int.TryParse(txtQty.Text.Trim(), out nQty) == false)
            {
                MessageBox.Show("委託量請輸入數字");
                return;
            }

            if (double.TryParse(txtTrigger.Text.Trim(), out dPrice) == false)
            {
                MessageBox.Show("觸發價請輸入數字");
                return;
            }
            strTigger = txtTrigger.Text.Trim();

            if (ReservedBox1.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇盤別");
                return;
            }
            nReserved = ReservedBox1.SelectedIndex;


            FUTUREORDER pFutureOrder = new FUTUREORDER();

            pFutureOrder.bstrFullAccount = m_UserAccount;
            pFutureOrder.bstrPrice       = strPrice;
            pFutureOrder.bstrStockNo     = strFutureNo;
            pFutureOrder.nQty            = nQty;
            pFutureOrder.sBuySell        = (short)nBidAsk;
            pFutureOrder.sDayTrade       = (short)nFlag;
            pFutureOrder.sNewClose       = (short)nNewClose;
            pFutureOrder.sTradeType      = (short)nPeriod;
            pFutureOrder.bstrTrigger     = strTigger;
            pFutureOrder.sReserved       = (short)nReserved;

            if (OnFutureStopLossOrderSignal != null)
            {
                OnFutureStopLossOrderSignal(m_UserID, false, pFutureOrder);
            }
        }
Esempio n. 26
0
        private void btnSendDuplexOrderAsync_Click(object sender, EventArgs e)
        {
            if (m_UserAccount == "")
            {
                MessageBox.Show("請選擇期貨帳號");
                return;
            }

            string strOptionNo1;
            string strOptionNo2;
            int nBidAsk1;
            int nBidAsk2;
            int nPeriod;
            int nFlag;
            string strPrice;
            int nQty;


            if (txtDStockNo1.Text.Trim() == "")
            {
                MessageBox.Show("請輸入商品代碼1");
                return;
            }
            strOptionNo1 = txtDStockNo1.Text.Trim();
            if (txtDStockNo2.Text.Trim() == "")
            {
                MessageBox.Show("請輸入商品代碼2");
                return;
            }
            strOptionNo2 = txtDStockNo2.Text.Trim();

            if (boxDBidAsk1.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇買賣別1");
                return;
            }
            nBidAsk1 = boxDBidAsk1.SelectedIndex;
            if (boxDBidAsk2.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇買賣別2");
                return;
            }
            nBidAsk2 = boxDBidAsk2.SelectedIndex;

            if (boxDPeriod.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇委託條件");
                return;
            }
            nPeriod = boxDPeriod.SelectedIndex;

            if (boxDFlag.SelectedIndex < 0)
            {
                MessageBox.Show("請選擇當沖與否");
                return;
            }
            nFlag = boxDFlag.SelectedIndex;

            double dPrice = 0.0;
            if (double.TryParse(txtDPrice.Text.Trim(), out dPrice) == false && txtDPrice.Text.Trim() != "M" && txtDPrice.Text.Trim() != "P")
            {
                MessageBox.Show("委託價請輸入數字");
                return;
            }
            strPrice = txtDPrice.Text.Trim();

            if (int.TryParse(txtDQty.Text.Trim(), out nQty) == false)
            {
                MessageBox.Show("委託量請輸入數字");
                return;
            }

            FUTUREORDER pFutureOrder = new FUTUREORDER();

            pFutureOrder.bstrFullAccount = m_UserAccount;
            pFutureOrder.bstrPrice = strPrice;
            pFutureOrder.bstrStockNo = strOptionNo1;
            pFutureOrder.bstrStockNo2 = strOptionNo2;
            pFutureOrder.nQty = nQty;
            pFutureOrder.sBuySell = (short)nBidAsk1;
            pFutureOrder.sBuySell2 = (short)nBidAsk2;
            pFutureOrder.sNewClose = (short)nFlag;
            pFutureOrder.sTradeType = (short)nPeriod;

            if (OnDuplexOrderSignal != null)
            {
                OnDuplexOrderSignal(m_UserID, true, pFutureOrder);
            }
        }