Exemplo n.º 1
0
 public EZOrder(ezInstrumentKey instrumentKey, zBuySell buySell, ezQuantity quantity, ezPrice price)
 {
     InstrumentKey = instrumentKey;
     BuySell       = buySell;
     _quantity     = quantity;
     _price        = price;
     Status        = EZOrderStatus.None;
 }
        public override void UpdateProviderFromPropertyValues()
        {
            selectedMarketQuoteItem = prop["QuoteItem"];
            ezInstrumentKey instrumentKey = APIFactory.InstrumentKeyFromString(prop["InstrumentKey"]);

            currentInstrument = APIMain.InstrumentFromKey(instrumentKey);
            //api.SubscribeToInstrument(instrument.Key);
            api.OnInsideMarketUpdate += api_OnInsideMarketUpdate;
            api_OnInsideMarketUpdate(currentInstrument);
        }
Exemplo n.º 3
0
        static public EZInstrument MakeInstrument(Market market)
        {
            ezInstrumentKey iKey = MakeInstrumentKey(market);
            var             ezi  = new EZInstrument(iKey);

            ezi.Key         = iKey;
            ezi.Name        = market.Description;
            ezi.Description = market.Description;
            return(ezi);
        }
Exemplo n.º 4
0
        static public ezInstrumentKey MakeInstrumentKey(Market market)
        {
            ezInstrumentKey iKey;
            string          keyString = CreateKeyString(market);

            if (keyLookupFromString.ContainsKey(keyString))
            {
                iKey = keyLookupFromString[keyString];
            }
            else
            {
                iKey = new ezInstrumentKey(market.ExchangeID, market.ContractID, market.MarketID, null);
                keyLookupFromString[keyString] = iKey;
                stringLookupFromKey[iKey]      = keyString;
            }
            return(iKey);
        }
Exemplo n.º 5
0
        public override void UpdateProviderFromPropertyValues()
        {
            //selectedMarketData = prop["QuoteItem"];
            ezInstrumentKey instrumentKey = APIFactory.InstrumentKeyFromString(prop["InstrumentKey"]);

            // Get historical data for 1-hour "bars".
            EZInstrument   instrument = APIMain.InstrumentFromKey(instrumentKey);
            zChartInterval interval   = zChartInterval.Hour;
            int            period     = 1;

            // TODO analyze different time periods (ex: different hours of the trading session) to
            // get a better "AverageVolumePerTimePeriod" calculation.
            EZChartDataSeries historicalData = api.RequestHistoricalData(instrument, interval, period);

            if (historicalData == null)
            {
                averageVolumePerTimePeriod = prop["AverageVolumePerTimePeriod"] ?? 0;
                timePeriodLength           = prop["TimePeriodLengthMinutes"] ?? 0.0;
            }
            else
            {
                int totalVolume = 0;
                int volumeCount = 0;
                foreach (ezBarDataPoint dp in historicalData.TradeBars)
                {
                    totalVolume += dp.Volume;
                    ++volumeCount;
                }
                double averageVolumePerHour = (double)totalVolume / (double)volumeCount;

                timePeriodLength           = 5.0; // five minutes
                averageVolumePerTimePeriod = (int)Math.Round(averageVolumePerHour / 20.0);
            }

            currentInstrument = APIMain.InstrumentFromKey(instrumentKey);
            //api.SubscribeToInstrument(instrument.Key);
            api.OnInsideMarketUpdate += api_OnInsideMarketUpdate;
            api_OnInsideMarketUpdate(currentInstrument);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Construct a TTInstrument object by passing an instrument key
 /// </summary>
 /// <param name="key">Same InstrumentKey used by the underlying TTAPI</param>
 public EZInstrument(ezInstrumentKey key)
 {
     Key = key;
     InstrumentDescriptor = null;
 }
Exemplo n.º 7
0
 static public string StringFromInstrumentKey(ezInstrumentKey ikey)
 {
     return(stringLookupFromKey[ikey]);
 }