コード例 #1
0
        public IOrder ExitPosition(IPosition position, OrdersProcessor orderProcessor)
        {
            var volume = GetPositionVolume(position);

            return(orderProcessor.SendOrder(
                       volume > 0 ? OrderSide.Buy : OrderSide.Sell,
                       Math.Abs(volume),
                       position.Contract,
                       OrderType.Market));
        }
コード例 #2
0
        //ExitPosition with no Position required... Does require contract and EventArgs...
        public IOrder ExitPosition_Alt(GF.Api.Contracts.IContract contract, OrdersProcessor orderProcessor, EventArgs e)
        {
            //var vol = GetPositionVolume(position) //Requires position here too!
            var vol      = e.ContractPosition.Net.Volume;
            var exit_qty = Math.Abs(qty);

            //var contract = e.ContractPosition.Contract.ElectronicContract; //Might be able to drop IContract arg?
            return(orderProcessor.SendOrder(
                       vol < 0 ? OrderSide.BuyToCover : OrderSide.Sell,
                       exit_qty,
                       contract,
                       OrderType.Market));
        }