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); } }
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);
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; } }