Beispiel #1
0
        public void SendOrder(int jump, int Qty, EnumDirectionType direction, EnumOffsetFlagType oc, double PriceTick)
        {
            double ordPrice = C.LASTDATA;

            if (direction == EnumDirectionType.Buy)
            {
                ordPrice = BIDPRICE(1).LASTDATA + jump * PriceTick;
                if (oc == EnumOffsetFlagType.Open)
                {
                    OpenBuy(ordPrice, Qty);
                }
                else
                {
                    CloseBuy(ordPrice, Qty);
                }
            }
            else
            {
                ordPrice = ASKPRICE(1).LASTDATA - jump * PriceTick;
                if (oc == EnumOffsetFlagType.Open)
                {
                    OpenSell(ordPrice, Qty);
                }
                else
                {
                    CloseSell(ordPrice, Qty);
                }
            }

            PrintLine(TickNow.ToString("HH:mm:ss.fff") + "->" + "下单" + Qty + "手" + oc.ToString() + direction.ToString() + SYMBOL
                      + "@" + ordPrice.ToString() + ",t=" + SERVERTIME.ToString());
        }
Beispiel #2
0
 public void AddTrader(string investorID, string instrumentID, string tradeTime, string orderRef, string tradeID, double price, int volume, EnumOffsetFlagType offsetFlag, EnumDirectionType direction, CThostFtdcTradeField pTrade)
 {
     try
     {
         sqlConnection.Open();
         string sql = "insert into trader(investorID, instrumentID, tradeTime, orderRef, tradeID, price, volume" +
                      ",offsetFlag,direction) values ('" +
                      investorID + "','" + instrumentID + "','" + tradeTime + "', '" + orderRef + "','" + tradeID + "'," + price + "," +
                      volume + "," + (offsetFlag == EnumOffsetFlagType.Open ? 0 : 1) + "," + (direction == EnumDirectionType.Buy ? 0 : 1) + ")";
         //Console.WriteLine(sql);
         MySqlCommand command = new MySqlCommand(sql, sqlConnection);
         command.ExecuteNonQuery();
     }
     finally {
         sqlConnection.Close();
     }
 }
Beispiel #3
0
        /// <summary>
        /// 下单
        /// </summary>
        /// <param name="sender">单子来源 Quote/Arbitrage</param>
        /// <param name="instrumentID">合约ID</param>
        /// <param name="directionType">买卖方向 Buy/Sell</param>
        /// <param name="offsetFlagType">开平标记 Open/CloseToday</param>
        /// <param name="lots">数量</param>
        /// <param name="price">价格</param>
        /// <returns>报单引用OrderRef</returns>
        public string PlaceOrder(object sender, string instrumentID, EnumDirectionType directionType, EnumOffsetFlagType offsetFlagType, int lots, double price)
        {
            ThostFtdcInputOrderField req = new ThostFtdcInputOrderField();
            ///经纪公司代码
            req.BrokerID = trader.BrokerID;
            ///投资者代码
            req.InvestorID = trader.InvestorID;
            ///合约代码
            req.InstrumentID = instrumentID;
            ///报单价格条件: 限价
            req.OrderPriceType = CTP.EnumOrderPriceTypeType.LimitPrice;
            ///买卖方向:
            req.Direction = directionType;
            ///组合开平标志: 开仓
            req.CombOffsetFlag_0 = offsetFlagType;
            ///组合投机套保标志
            req.CombHedgeFlag_0 = CTP.EnumHedgeFlagType.Speculation;
            ///价格
            req.LimitPrice = price;
            ///数量: 1
            req.VolumeTotalOriginal = lots;
            ///有效期类型: 当日有效
            req.TimeCondition = CTP.EnumTimeConditionType.GFD;
            ///成交量类型: 任何数量
            req.VolumeCondition = CTP.EnumVolumeConditionType.AV;
            ///最小成交量: 1
            req.MinVolume = 1;
            ///触发条件: 立即
            req.ContingentCondition = CTP.EnumContingentConditionType.Immediately;
            ///强平原因: 非强平
            req.ForceCloseReason = CTP.EnumForceCloseReasonType.NotForceClose;
            ///自动挂起标志: 否
            req.IsAutoSuspend = 0;
            ///用户强评标志: 否
            req.UserForceClose = 0;
            OrderRef++;
            req.OrderRef = OrderRef.ToString();
            int iResult = trader.ReqOrderInsert(req, ++RequestID);

            //OrderRef2ArbitrageStategyMap.Add(req.OrderRef, (Arbitrage)sender);

            return req.OrderRef;
        }
Beispiel #4
0
        /// <summary>
        /// 报价录入请求
        /// </summary>
        public string PlaceQuote(object sender, string instrumentID, EnumOffsetFlagType AskOffset, int Asklots, double Askprice,
            EnumOffsetFlagType BidOffset, int Bidlots, double Bidprice)
        {
            ThostFtdcInputQuoteField req = new ThostFtdcInputQuoteField();
            req.BrokerID = trader.BrokerID;
            req.InvestorID = trader.InvestorID;
            req.InstrumentID = instrumentID;
            req.AskHedgeFlag = EnumHedgeFlagType.Speculation;
            req.AskOffsetFlag = AskOffset;
            req.AskPrice = Askprice;
            req.AskVolume = Asklots;
            req.BidHedgeFlag = EnumHedgeFlagType.Speculation;
            req.BidOffsetFlag = BidOffset;
            req.BidPrice = Bidprice;
            req.BidVolume = Bidlots;
            QuoteRef++;
            req.QuoteRef = QuoteRef.ToString();
            int iRet = trader.ReqQuoteInsert(req, ++RequestID);

            //QuoteRef2QuoteStategyMap.Add(req.QuoteRef, (Quote)sender);

            return req.QuoteRef;
        }
 public int ReqOrderInsert(string instrumentId, EnumDirectionType direction, double price, int nVolume,
                           EnumOffsetFlagType openOrClose, EnumTimeConditionType timeCondition,
                           EnumVolumeConditionType volumeCondition, string reason)
 {
     return(0);
 }