Exemplo n.º 1
0
        public int SendOrder(
            string szInstrument,
            string szExchange,
            TZQThostFtdcDirectionType Direction,
            string szCombOffsetFlag,
            string szCombHedgeFlag,
            int VolumeTotalOriginal,
            string LimitPrice,
            TZQThostFtdcOrderPriceTypeType OrderPriceType,
            TZQThostFtdcTimeConditionType TimeCondition,
            TZQThostFtdcContingentConditionType ContingentCondition,
            double StopPrice)
        {
            if (null == m_pTdApi || IntPtr.Zero == m_pTdApi)
            {
                return(0);
            }

            return(TraderApi.TD_SendOrder(
                       m_pTdApi,
                       szInstrument,
                       szExchange,
                       Direction,
                       szCombOffsetFlag,
                       szCombHedgeFlag,
                       VolumeTotalOriginal,
                       LimitPrice,
                       OrderPriceType,
                       TimeCondition,
                       ContingentCondition,
                       StopPrice));
        }
Exemplo n.º 2
0
        //只收到成交信息时调用
        public bool InsertOrReplaceForTrade(
            string InstrumentID,
            TZQThostFtdcPosiDirectionType PosiDirection,
            TZQThostFtdcDirectionType Direction,
            TZQThostFtdcHedgeFlagType HedgeFlag,
            TZQThostFtdcPositionDateType PositionDate,
            int volume)
        {
            lock (this)
            {
                // 今天的买入要先冻结
                //冲突的可能性大一些,所以要先Update后Insert
                DataRow[] rows = Select(InstrumentID, PosiDirection, HedgeFlag, PositionDate);

                if (rows.Count() == 1)
                {
                    int vol = (int)rows[0][Position];
                    rows[0][Position] = vol - volume;
                }
                else
                {
                    //假设是新添数据
                    try
                    {
                        if (Direction == TZQThostFtdcDirectionType.Buy)
                        {
                            dtInvestorPosition.Rows.Add(
                                InstrumentID,
                                PosiDirection,
                                HedgeFlag,
                                PositionDate,
                                0,
                                volume,
                                0);
                        }
                        else
                        {
                            dtInvestorPosition.Rows.Add(
                                InstrumentID,
                                PosiDirection,
                                HedgeFlag,
                                PositionDate,
                                0,
                                0,
                                volume);
                        }
                    }
                    catch
                    {
                        return(false);
                    }
                }
                return(true);
            }
        }
Exemplo n.º 3
0
 public static extern int TD_SendOrder(IntPtr pTraderApi,
                                       string szInstrument,
                                       string szExchange,
                                       TZQThostFtdcDirectionType Direction,
                                       string szCombOffsetFlag,
                                       string szCombHedgeFlag,
                                       int VolumeTotalOriginal,
                                       string LimitPrice,
                                       TZQThostFtdcOrderPriceTypeType OrderPriceType,
                                       TZQThostFtdcTimeConditionType TimeCondition,
                                       TZQThostFtdcContingentConditionType ContingentCondition,
                                       double StopPrice);
Exemplo n.º 4
0
 public static extern int TD_SendOrder(IntPtr pTraderApi,
     string szInstrument,
     string szExchange,
     TZQThostFtdcDirectionType Direction,
     string szCombOffsetFlag,
     string szCombHedgeFlag,
     int VolumeTotalOriginal,
     string LimitPrice,
     TZQThostFtdcOrderPriceTypeType OrderPriceType,
     TZQThostFtdcTimeConditionType TimeCondition,
     TZQThostFtdcContingentConditionType ContingentCondition,
     double StopPrice);
Exemplo n.º 5
0
        public int SendOrder(
            string szInstrument,
            string szExchange,
            TZQThostFtdcDirectionType Direction,
            string szCombOffsetFlag,
            string szCombHedgeFlag,
            int VolumeTotalOriginal,
            string LimitPrice,
            TZQThostFtdcOrderPriceTypeType OrderPriceType,
            TZQThostFtdcTimeConditionType TimeCondition,
            TZQThostFtdcContingentConditionType ContingentCondition,
            double StopPrice)
        {
            if (null == m_pTdApi || IntPtr.Zero == m_pTdApi)
            {
                return 0;
            }

            return TraderApi.TD_SendOrder(
               m_pTdApi,
               szInstrument,
               szExchange,
               Direction,
               szCombOffsetFlag,
               szCombHedgeFlag,
               VolumeTotalOriginal,
               LimitPrice,
               OrderPriceType,
               TimeCondition,
               ContingentCondition,
               StopPrice);
        }
        //只收到成交信息时调用
        public bool InsertOrReplaceForTrade(
            string InstrumentID,
            TZQThostFtdcPosiDirectionType PosiDirection,
            TZQThostFtdcDirectionType Direction,
            TZQThostFtdcHedgeFlagType HedgeFlag,
            TZQThostFtdcPositionDateType PositionDate,
            int volume)
        {
            lock(this)
            {
                // 今天的买入要先冻结
                //冲突的可能性大一些,所以要先Update后Insert
                DataRow[] rows = Select(InstrumentID, PosiDirection, HedgeFlag, PositionDate);

                if (rows.Count() == 1)
                {
                    int vol = (int)rows[0][Position];
                    rows[0][Position] = vol - volume;
                }
                else
                {
                    //假设是新添数据
                    try
                    {
                        if (Direction == TZQThostFtdcDirectionType.Buy)
                        {
                            dtInvestorPosition.Rows.Add(
                                        InstrumentID,
                                        PosiDirection,
                                        HedgeFlag,
                                        PositionDate,
                                        0,
                                        volume,
                                        0);
                        }
                        else
                        {
                            dtInvestorPosition.Rows.Add(
                                        InstrumentID,
                                        PosiDirection,
                                        HedgeFlag,
                                        PositionDate,
                                        0,
                                        0,
                                        volume);
                        }
                    }
                    catch
                    {
                        return false;
                    }
                }
                return true;
            }
        }