Exemple #1
0
        private void CloseLimitOrder(Tick t, LimitOrder l)
        {
            _tradeProfits.Add(_portfolio.ClosePosition(t, l.TriggerPrice));

            _outStandingLimitOrders.Remove(l.Symbol);

            //remove stop order because limit was closed
            if (_outStandingStopOrders.ContainsKey(t.Symbol))
                _outStandingStopOrders.Remove(t.Symbol);


            //Flags for visualization purposes
            _flags.Add(new HighstockFlag(
                                "CL",
                                "Closed Limit Order",
                                t.Time
                            ));
        }
Exemple #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--------");
        }
Exemple #3
0
 public void PlaceLimitOrder(LimitOrder limit)
 {
     _outStandingLimitOrders.Add(limit.Symbol, limit);
 }