示例#1
0
        private void Button_PlaceOrder_Click(object sender, EventArgs e)
        {
            //trd未初始化直接返回
            if (trd == null)
            {
                return;
            }

            //创建发单对象
            //BUY-SELL-SELLSHORT买卖开平
            InsertOrder orderInsert = this.CreateInsertOrder();

            //调用trd下单
            TrdPlaceOrder.Request.Builder req      = TrdPlaceOrder.Request.CreateBuilder();
            TrdPlaceOrder.C2S.Builder     cs       = TrdPlaceOrder.C2S.CreateBuilder();
            Common.PacketID.Builder       packetID = Common.PacketID.CreateBuilder().SetConnID(trd.GetConnectID()).SetSerialNo(0);

            //设置参与的账户--真实模拟市场--参与的市场(美港A股等)
            TrdCommon.TrdHeader.Builder trdHeader = TrdCommon.TrdHeader.CreateBuilder().SetAccID(m_st.accID).SetTrdEnv((int)TrdCommon.TrdEnv.TrdEnv_Real).SetTrdMarket((int)TrdCommon.TrdMarket.TrdMarket_US);
            //设置下单的参数
            cs.SetPacketID(packetID).SetHeader(trdHeader).SetTrdSide((int)orderInsert.OrderSide).SetOrderType((int)orderInsert.OrderType).SetCode(orderInsert.StockCode).SetQty(orderInsert.Shares).SetPrice(orderInsert.Price).SetAdjustPrice(true);
            req.SetC2S(cs);

            uint serialNo = trd.PlaceOrder(req.Build());
        }
示例#2
0
        private void OrderAction(string lastInfo)
        {
            //拆解最后一条,生成orderInsert,发单
            string[] arrayInfos = lastInfo.Split('|');

            InsertOrder orderInsert = new InsertOrder();

            orderInsert.StockCode = arrayInfos[0].Trim();
            orderInsert.OrderSide = (TrdCommon.TrdSide)Convert.ToDouble(arrayInfos[1].Trim());
            orderInsert.OrderType = (TrdCommon.OrderType)Convert.ToDouble(arrayInfos[2].Trim());
            orderInsert.Shares    = Convert.ToDouble(arrayInfos[3].Trim());
            orderInsert.Price     = Convert.ToDouble(arrayInfos[4].Trim());

            //调用trd下单
            TrdPlaceOrder.Request.Builder req      = TrdPlaceOrder.Request.CreateBuilder();
            TrdPlaceOrder.C2S.Builder     cs       = TrdPlaceOrder.C2S.CreateBuilder();
            Common.PacketID.Builder       packetID = Common.PacketID.CreateBuilder().SetConnID(trd.GetConnectID()).SetSerialNo(0);

            //设置参与的账户--真实模拟市场--参与的市场(美港A股等)
            TrdCommon.TrdHeader.Builder trdHeader = TrdCommon.TrdHeader.CreateBuilder().SetAccID(m_st.accID).SetTrdEnv((int)TrdCommon.TrdEnv.TrdEnv_Real).SetTrdMarket((int)TrdCommon.TrdMarket.TrdMarket_US);
            //设置下单的参数
            cs.SetPacketID(packetID).SetHeader(trdHeader).SetTrdSide((int)orderInsert.OrderSide).SetOrderType((int)orderInsert.OrderType).SetCode(orderInsert.StockCode).SetQty(orderInsert.Shares).SetPrice(orderInsert.Price).SetAdjustPrice(true);
            req.SetC2S(cs);

            uint serialNo = trd.PlaceOrder(req.Build());
        }
示例#3
0
            public void OnReply_UnlockTrade(FTAPI_Conn client, int nSerialNo, TrdUnlockTrade.Response rsp)
            {
                Console.WriteLine("Recv UnlockTrade: {0} {1}", nSerialNo, rsp);
                if (rsp.RetType != (int)Common.RetType.RetType_Succeed)
                {
                    Console.WriteLine("error code is {0}", rsp.RetMsg);
                }
                else
                {
                    FTAPI_Trd trd = client as FTAPI_Trd;

                    TrdPlaceOrder.Request.Builder req       = TrdPlaceOrder.Request.CreateBuilder();
                    TrdPlaceOrder.C2S.Builder     cs        = TrdPlaceOrder.C2S.CreateBuilder();
                    Common.PacketID.Builder       packetID  = Common.PacketID.CreateBuilder().SetConnID(trd.GetConnectID()).SetSerialNo(0);
                    TrdCommon.TrdHeader.Builder   trdHeader = TrdCommon.TrdHeader.CreateBuilder().SetAccID(this.accID).SetTrdEnv((int)TrdCommon.TrdEnv.TrdEnv_Real).SetTrdMarket((int)TrdCommon.TrdMarket.TrdMarket_US);
                    cs.SetPacketID(packetID).SetHeader(trdHeader).SetTrdSide((int)TrdCommon.TrdSide.TrdSide_Sell).SetOrderType((int)TrdCommon.OrderType.OrderType_Market).SetCode("AAPL").SetQty(100.00).SetPrice(10.2).SetAdjustPrice(true);
                    req.SetC2S(cs);

                    uint serialNo = trd.PlaceOrder(req.Build());
                    Console.WriteLine("Send PlaceOrder: {0}, {1}", serialNo, req);
                }
            }