예제 #1
0
        public void StoreTradeVolume(ezQuantity quantity)
        {
            var vdp = new VolumeDataPoint(DateTime.Now, quantity.ToInt());

            // Insert the newest data points at the "top" of the list.
            VolumeDataPoints.Insert(0, vdp);
        }
예제 #2
0
        public EZFill(DateTime fillTime, EZInstrument instrument, zBuySell buySell, ezQuantity quantity, ezPrice price, zFillType fillType)
        {
            TimeZoneInfo cst       = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
            DateTime     localTime = TimeZoneInfo.ConvertTimeFromUtc(fillTime, cst);

            DateTime time         = localTime;
            string   timeStr      = time.ToString("H:mm:ss.fff");
            string   shortTimeStr = time.ToString("hh:mm:ss tt");

            Time           = timeStr;
            ShortTime      = shortTimeStr;
            Identifiers    = ""; // GetFillIdenifiers(fill);
            Instrument     = instrument;
            BuySell        = buySell;
            InstrumentName = ""; // ParseInstrumentKey(fill.InstrumentKey.ToString());
            Quantity       = quantity;
            Price          = price;
            FFT2           = ""; // fill.FFT2;
            FFT3           = ""; // fill.FFT3;
            FillType       = fillType;
            //_fill = fill;
            Originator         = FillOriginator.TRADER;
            Action             = FillAction.ADD;
            ReplacementForFill = null;
        }
예제 #3
0
 public EZOrder(ezInstrumentKey instrumentKey, zBuySell buySell, ezQuantity quantity, ezPrice price)
 {
     InstrumentKey = instrumentKey;
     BuySell       = buySell;
     _quantity     = quantity;
     _price        = price;
     Status        = EZOrderStatus.None;
 }
예제 #4
0
        void api_OnInsideMarketUpdate(EZInstrument instrument)
        {
            if (instrument == null || currentInstrument == null || instrument.Key != currentInstrument.Key)
            {
                return;
            }

            /*if (selectedMarketData.Equals("Bid Price"))
             *  UpdateDataValue(instrument.Bid.ToString());
             * else if (selectedMarketData.Equals("Bid Quantity"))
             *  UpdateDataValue(instrument.BidQty.ToString());
             * else if (selectedMarketData.Equals("Offer Price"))
             *  UpdateDataValue(instrument.Ask.ToString());
             * else if (selectedMarketData.Equals("Offer Quantity"))
             *  UpdateDataValue(instrument.AskQty.ToString());*/

            ezPrice    price = instrument.Last;
            ezQuantity qty   = instrument.LastQty;

            // Check if the price has moved.
            if (price != lastPrint)
            {
                Spy.Print("{0} : {1}", price, lastPrint);
                //StoreLastPrice(price);
                lastPrint = price;
                timeFrames.StoreTradeVolume(qty);
                UpdateDataValue(timeFrames.VolumeInTimePeriod(TimeSpan.FromMinutes(5)));
                lastPrintTotalVolume = instrument.LastTotalVolume;
            }
            else // last price is the same - check to see if another trade occurred at the same price
            {
                if (instrument.LastTotalVolume > lastPrintTotalVolume)
                {
                    timeFrames.StoreTradeVolume(qty);
                    UpdateDataValue(timeFrames.VolumeInTimePeriod(TimeSpan.FromMinutes(5)));
                    lastPrintTotalVolume = instrument.LastTotalVolume;
                }
            }


            //UpdateDataValue(instrument.LastQty.ToString());

            /*this.Invoke((MethodInvoker)delegate
             * {
             *  lblBid1.Text = instrument.Bid.ToString();
             *  lblBidVol1.Text = instrument.BidQty.ToString();
             *  lblOffer1.Text = instrument.Ask.ToString();
             *  lblOfferVol1.Text = instrument.AskQty.ToString();
             *  lblLast1.Text = instrument.Last.ToString();
             *  lblLastVol1.Text = instrument.LastQty.ToString();
             *  lblTotalVol1.Text = instrument.Volume.ToString();
             *  lblNet1.Text = instrument.NetPos.ToString();
             *  lblBuys1.Text = instrument.NetBuys.ToString();
             *  lblSells1.Text = instrument.NetSells.ToString();
             * });*/
        }
예제 #5
0
        /// <summary>
        /// Construct a TTOrder object from a TTAPI Order object
        /// </summary>
        /// <param name="order">TTAPI Order object</param>
        public EZOrder(ezOrder order)
        {
            _order = order;

            InstrumentKey = order.InstrumentKey;
            BuySell       = order.BuySell;
            _quantity     = order.OrderQuantity;
            _price        = order.LimitPrice;
            Status        = EZOrderStatus.None;
        }
예제 #6
0
 /// <summary>
 /// Set the market depth at a specified level by specifying bid/ask price/quantity
 /// </summary>
 /// <param name="level">market depth level to change</param>
 /// <param name="bid">bid price</param>
 /// <param name="bidQty">bid quantity</param>
 /// <param name="ask">ask price</param>
 /// <param name="askQty">ask quantity</param>
 public void SetDepth(int level, ezPrice bid, ezQuantity bidQty, ezPrice ask, ezQuantity askQty)
 {
     if (_marketDepth[level] == null)
     {
         _marketDepth[level] = new EZMarketDepthLevel();
     }
     _marketDepth[level].Bid    = bid;
     _marketDepth[level].BidQty = bidQty;
     _marketDepth[level].Ask    = ask;
     _marketDepth[level].AskQty = askQty;
 }
예제 #7
0
        public DataProviderMomentum() : base()
        {
            // For the momentum indicator, we will start off assuming we are in the
            // "collecting data" state (which will change to "READY" when the DataProvider
            // has enough data that it can begin returning calculations.
            //dataProviderState = DataProviderState.COLLECTING_DATA;

            // Start off with ZERO momentum. As the indicator changes, POSITIVE values means market moving UP with
            // momentum. NEGATIVE values means market moving DOWN with momentum.
            momentum = 0.0;

            uiControl       = null;
            uiModifyControl = null;
            DataUpdate     += DataProviderMarketData_DataUpdate;

            lastPrint            = null;
            lastPrintQty         = null;
            lastPrintTotalVolume = 0;

            timeFrames = new VolumeTimeFrames();

            api = APIMain.Instance;
        }