示例#1
0
 public MarketOrder(Tick t, Position.PositionSide side, double orderSize)
 {
     Symbol    = t.Symbol;
     Side      = side;
     Price     = (side.Equals(Position.PositionSide.Long)) ? t.AskClose : t.BidClose;
     Size      = orderSize;
     OrderDate = t.Time;
 }
示例#2
0
        public void PlaceMarketOrder(Symbol sym, int size, Position.PositionSide side, double stopPips = double.NaN, double LimitPips = double.NaN)
        {
            if (!currentOffers.ContainsKey(sym))
            {
                return;
            }

            double orderPrice = side.Equals(Position.PositionSide.Long)
                ? currentOffers[sym].AskClose
                : currentOffers[sym].BidClose;

            //------------------------------------
            // Take the position.
            //------------------------------------

            _portfolio.TakePosition(sym, orderPrice, side, size, currentOffers[sym].Time);

            //------------------------------------
            // Place Stop/Limits if defined
            //------------------------------------

            if (!stopPips.Equals(double.NaN))
            {
                StopOrder stopOrder = new StopOrder(sym, side, ((side.Equals(Position.PositionSide.Long)) ? orderPrice - stopPips : orderPrice + stopPips));
                PlaceStopOrder(stopOrder);
            }

            if (!LimitPips.Equals(double.NaN))
            {
                LimitOrder limitOrder = new LimitOrder(sym, side, ((side.Equals(Position.PositionSide.Long)) ? orderPrice + LimitPips : orderPrice - LimitPips));
                PlaceLimitOrder(limitOrder);
            }

            //------------------------------------
            // Flags for visualization purposes
            //------------------------------------

            _flags.Add(new HighstockFlag(
                           (side == Position.PositionSide.Long) ? "B" : "S",
                           ((side == Position.PositionSide.Long) ? "Bought " : "Sold ") + size + " on " + side + " at " + orderPrice + " on " + currentOffers[sym].Time.ToString(),
                           currentOffers[sym].Time
                           ));

            //Console.WriteLine(order.OrderDate.ToString() + "ORDER--------");
        }
示例#3
0
 public void PlaceMarketOrder(Symbol sym, int size, Position.PositionSide side, double stopPips, double LimitPips)
 {
     OrderPlacementEngine.OrderObject orderObject = _opEngine.prepareParamsFromLoginRules(sym.SymbolString);
     _opEngine.CreateTrueMarketOrder(orderObject.AccountID, orderObject.OfferID, size,
                                     (side.Equals(Position.PositionSide.Long)) ? "Buy" : "Sell");
 }