/// <summary> /// 持仓查询请求 /// </summary> /// <param name="strContractId">合同编码(可以为空,表示查全部合同)</param> /// <param name="strBuyOrSell">买卖方向(可以为空,表示查全部方向)</param> /// <param name="strTradeNo">交易流水号,会原样反回到应答包包头的TradeNo字段</param> /// <returns></returns> public bool ForJHTradeSubsfListRequest(string strContractId, EnumBuySell _buysell, string strTradeNo) { try { string strBuyOrSell = ""; //买卖方向 if (_buysell == EnumBuySell.买入) { strBuyOrSell = "1"; } else if (_buysell == EnumBuySell.卖出) { strBuyOrSell = "2"; } else { strBuyOrSell = ""; } if (manageTrade != null && trade_login_ok) { return(manageTrade.ForJHTradeSubsfListRequest(strContractId, strBuyOrSell, strTradeNo)); } return(false); }catch { return(false); } }
// 对冲方向平仓 public void ClosePosition(double lastPrice, double priceDiff) { if (_orderLock || _status != HedgeStatus.WaitClosePosition) { return; } double priceLimite = getClosePrice(lastPrice, priceDiff); EnumBuySell dir = getClosePositionDir(); _order = _st.SendOrder(_st.DefaultAccount, _future.ID, EnumMarket.期货, _future.ExchangeID, priceLimite, _volume, dir, EnumOpenClose.平今仓, EnumOrderPriceType.市价, EnumOrderTimeForce.当日有效, EnumHedgeFlag.投机); _orderLock = true; _status = HedgeStatus.WaitCloseOrderComplete; _closeHitTimes++; _st.Print("===========》平今仓:"); OrderHelper.PrintOrderStatus(_st, _order); }
public TestTradeCase( string _insId, EnumMarket _market, string _exchange, EnumBuySell _direction, double _limitPrice, int _volume, int _year, int _month, int _day) { insId = _insId; Market = _market; ExchangeID = _exchange; Direction = _direction; LimitPrice = _limitPrice; Volume = _volume; Year = _year; Month = _month; Day = _day; }
/// <summary> /// 报单函数 /// </summary> /// <param name="_buysell">(*下单必填)买卖方向(1 - 买入,2 - 卖出)</param> /// <param name="_openclose">(*下单必填)开平仓标记:1、开仓(新订);2、平今;3、平昨;4、平仓(先订先转); /// 5、平仓(转今优先);6、指定仓平仓;</param> /// <param name="_price">委托价格</param> /// <param name="_volume">委托数量</param> /// <param name="_tradeno">交易流水</param> /// <returns></returns> public bool ForLimitOrder(EnumBuySell _buysell, EnumOpenClose _openclose, int _price, int _volume, string _contractId, string _tradeno) { Orderf orf = new Orderf(); orf.contract_no = contractID; orf.contract_id = _contractId; orf.is_deposit = "1"; orf.trade_type = "1"; //买卖方向 if (_buysell == EnumBuySell.买入) { orf.buyorsell = "1"; } else { orf.buyorsell = "2"; } //开平标志 if (_openclose == EnumOpenClose.开仓_新订) { orf.offset_flag = "1"; } else if (_openclose == EnumOpenClose.平今) { orf.offset_flag = "2"; } else if (_openclose == EnumOpenClose.平昨) { orf.offset_flag = "3"; } else if (_openclose == EnumOpenClose.平仓_先订先转) { orf.offset_flag = "4"; } else if (_openclose == EnumOpenClose.平仓_转今优先) { orf.offset_flag = "5"; } else { orf.offset_flag = "6"; } orf.order_price = _price + ""; orf.order_qtt = _volume + ""; try { if (manageTrade != null) { return(manageTrade.ForJHTradeOrderfRequest(orf, _tradeno)); } else { return(false); } } catch { return(false); } }
private Order SendOrderEx(Future future, double priceLimite, int volume, EnumBuySell buySell, EnumOpenClose openClose) { return(SendOrder(DefaultAccount, future.ID, future.Market, future.ExchangeID, priceLimite, volume, buySell, openClose, EnumOrderPriceType.市价, EnumOrderTimeForce.当日有效, EnumHedgeFlag.投机)); }