示例#1
0
 public RowData(double price, long liquidity, MarketDataType dataType, bool active)
 {
     Liquidity = liquidity;
     Price     = price;
     DataType  = dataType;
     Active    = active;
 }
示例#2
0
文件: Ticks.cs 项目: dshe/InterReact
 internal MarketDataTypeTick(ResponseReader r)
 {
     r.IgnoreVersion();
     RequestId      = r.ReadInt();
     TickType       = TickType.MarketDataType;
     MarketDataType = r.ReadEnum <MarketDataType>();
 }
 /// <summary>
 /// Argument Constructor
 /// </summary>
 /// <param name="security">Contains Symbol information</param>
 /// <param name="provider">Market Data Provider details</param>
 /// <param name="marketDataType">Type of Market Data to subscribe</param>
 /// <param name="subscriptionType">Subscription category e.g. Subscribe, Un-Subscribe</param>
 public SubscriptionRequest(Security security, MarketDataProvider provider, MarketDataType marketDataType, SubscriptionType subscriptionType)
 {
     _security         = security;
     _provider         = provider;
     _marketDataType   = marketDataType;
     _subscriptionType = subscriptionType;
 }
示例#4
0
		internal MarketDataSubscription(IMarketDataProvider provider, Instrument instrument, MarketDataType mdType, int count)
		{
			this.Provider = provider;
			this.Instrument = instrument;
			this.MDType = mdType;
			this.Count = count;
		}
示例#5
0
        /// <summary>
        /// Creates Missing Directories and place returns proper
        /// path of file depending on dataType and symbol
        /// </summary>
        /// <param name="symbol"></param>
        /// <param name="dataType"> </param>
        /// <param name="dataProvider"> </param>
        /// <returns></returns>
        private string CreateDirectoryPath(string symbol, MarketDataType dataType, string dataProvider)
        {
            try
            {
                string[] directories =
                {
                    _specificFolder + "\\" + dataProvider,
                    _specificFolder + "\\" + dataProvider + "\\" + symbol,
                    _specificFolder + "\\" + dataProvider + "\\" + symbol + "\\" + dataType,
                    _specificFolder + "\\" + dataProvider + "\\" + symbol + "\\" + dataType + "\\" + DateTime.Now.Year.ToString(CultureInfo.InvariantCulture),
                    _specificFolder + "\\" + dataProvider + "\\" + symbol + "\\" + dataType + "\\" + DateTime.Now.Year.ToString(CultureInfo.InvariantCulture) + "\\" + DateTime.Now.Month.ToString(CultureInfo.InvariantCulture)
                };

                foreach (string path in directories)
                {
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                }
                if (Logger.IsInfoEnabled)
                {
                    Logger.Info(directories[directories.Length - 1] + "\\" + DateTime.Now.ToString("yyyyMMdd"),
                                _oType.FullName,
                                "CreateDirectoryPath");
                }
                return(directories[directories.Length - 1] + "\\" + DateTime.Now.ToString("yyyyMMdd"));
            }
            catch (Exception exception)
            {
                Logger.Error(exception, _oType.FullName, "CreateDirectoryPath");
                return(null);
            }
        }
示例#6
0
 internal TickMarketDataType(ResponseComposer c)
 {
     c.IgnoreVersion();
     RequestId      = c.ReadInt();
     TickType       = TickType.MarketDataType; //
     MarketDataType = c.ReadEnum <MarketDataType>();
 }
 /// <summary>
 /// Construct a MarketDataDescription item.
 /// </summary>
 /// <param name="ticker">The ticker symbol to use.</param>
 /// <param name="dataType">The data type needed.</param>
 /// <param name="type">The normalization type.</param>
 /// <param name="activationFunction"> The activation function to apply to this data, can be null.</param>
 /// <param name="input">Is this field used for input?</param>
 /// <param name="predict">Is this field used for prediction?</param>
 public MarketDataDescription(TickerSymbol ticker,
                              MarketDataType dataType, Type type,
                              IActivationFunction activationFunction, bool input,
                              bool predict)
     : base(activationFunction, type, input, predict)
 {
     _ticker   = ticker;
     _dataType = dataType;
 }
 /// <summary>
 /// Construct a MarketDataDescription item.
 /// </summary>
 /// <param name="ticker">The ticker symbol to use.</param>
 /// <param name="dataType">The data type needed.</param>
 /// <param name="type">The normalization type.</param>
 /// <param name="activationFunction"> The activation function to apply to this data, can be null.</param>
 /// <param name="input">Is this field used for input?</param>
 /// <param name="predict">Is this field used for prediction?</param>
 public MarketDataDescription(TickerSymbol ticker,
         MarketDataType dataType, Type type,
         IActivationFunction activationFunction, bool input,
         bool predict)
     : base(activationFunction, type, input, predict)
 {
     this.ticker = ticker;
     this.dataType = dataType;
 }
示例#9
0
 private void CancelMarketData(Instrument[] array, MarketDataType mdType)
 {
     ThreadPool.QueueUserWorkItem((WaitCallback)(objects =>
     {
         foreach (Instrument item_0 in (Instrument[])objects)
         {
             Global.ProviderHelper.CancelMarketData(this.provider, item_0, mdType);
         }
     }), array);
 }
        public void OnSecuritiesChangeDoesNotThrow(
            Language language,
            double[] historicalPrices,
            MarketDataType marketDataType)
        {
            var time = new DateTime(2018, 8, 2, 16, 0, 0);

            Func <double, int, BaseData> func = (x, i) =>
            {
                var price = Convert.ToDecimal(x);
                switch (marketDataType)
                {
                case MarketDataType.TradeBar:
                    return(new TradeBar(time.AddMinutes(i), Symbols.AAPL, price, price, price, price, 100m));

                case MarketDataType.QuoteBar:
                    var bar = new Bar(price, price, price, price);
                    return(new QuoteBar(time.AddMinutes(i), Symbols.AAPL, bar, 10m, bar, 10m));

                default:
                    throw new ArgumentException($"Invalid MarketDataType: {marketDataType}");
                }
            };

            var historyProvider = new Mock <IHistoryProvider>();

            historyProvider.Setup(m => m.GetHistory(It.IsAny <IEnumerable <HistoryRequest> >(), It.IsAny <DateTimeZone>()))
            .Returns(historicalPrices.Select((x, i) => new Slice(time.AddMinutes(i), new List <BaseData> {
                func(x, i)
            })));

            var algorithm = new QCAlgorithm();

            algorithm.SetPandasConverter();
            algorithm.SetHistoryProvider(historyProvider.Object);
            algorithm.SubscriptionManager.SetDataManager(new DataManagerStub(algorithm));
            algorithm.SetDateTime(time.AddMinutes(5));

            var security = algorithm.AddEquity(Symbols.AAPL.Value);

            security.SetMarketPrice(new TradeBar {
                Value = 250
            });
            algorithm.SetFinishedWarmingUp();

            var model = GetExecutionModel(language);

            algorithm.SetExecution(model);

            var changes = new SecurityChanges(new[] { security }, Enumerable.Empty <Security>());

            Assert.DoesNotThrow(() => model.OnSecuritiesChanged(algorithm, changes));
        }
示例#11
0
        public Mantle.Fix44.MarketDataRequest MarketDataRequest(string symbol, MarketDataType type)
        {
            var res = new Mantle.Fix44.MarketDataRequest();

            res = new Mantle.Fix44.MarketDataRequest()
            {
                StandardHeader = StandardHeader()
            };
            var instrument = new Mantle.Fix44.Instrument();

            instrument.Symbol.Value = symbol;
            res.RelatedSym.Add(instrument);
            // It's important for huobi that MDReqID has symbol as its prefix. Otherwise they'll
            // silently ignore our request. This is undocumented.
            res.MDReqID.Value = symbol + Guid.NewGuid().ToString();
            // '0' - snapshot only
            // '1' - snapshot followed by incremental refresh
            res.SubscriptionRequestType.Value = '1';
            if (_cfg.Extensions == Extensions.OkCoin && type == MarketDataType.Order)
            {
                // OkCoin sends incremental refresh for the first 20 rows only, which isn't enough for us.
                // We have to periodically request the full snapshot instead.
                res.SubscriptionRequestType.Value = '0';
            }
            res.MarketDepth.Value  = 0;
            res.MDUpdateType.Value = 1;
            switch (type)
            {
            case MarketDataType.Order:
                // Bids.
                res.MDEntryTypes.Add(new Mantle.Fix44.MDEntryType()
                {
                    Value = '0'
                });
                // Asks.
                res.MDEntryTypes.Add(new Mantle.Fix44.MDEntryType()
                {
                    Value = '1'
                });
                break;

            case MarketDataType.Trade:
                // Live trades.
                res.MDEntryTypes.Add(new Mantle.Fix44.MDEntryType()
                {
                    Value = '2'
                });
                break;
            }
            return(res);
        }
示例#12
0
        public void AlwaysReturnTheLastData(MarketDataType marketDataType, int quantity, bool sameTime)
        {
            // Arrange
            var securityCache = new SecurityCache();
            var quotes        = GenerateData(marketDataType, quantity, sameTime);

            // Act
            foreach (var quoteBar in quotes)
            {
                securityCache.AddData(quoteBar);
            }
            // Assert
            Assert.True(securityCache.GetData().Equals(quotes.Last()));
        }
示例#13
0
        public data_response Data(string exchange_code, string exchange_market, MarketDataType type)
        {
            var url      = "data";
            var typename = Enum.GetName(typeof(MarketDataType), type);
            var pd       = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("exchange_code", exchange_code),
                new KeyValuePair <string, string>("exchange_market", exchange_market),
                new KeyValuePair <string, string>("type", typename)
            };
            var gr = HttpPostRequest(url, User_Agent, pd);

            return(JsonConvert.DeserializeObject <data_response>(gr));
        }
示例#14
0
        private MarketDataType GetMarketDataType()
        {
            MarketDataType marketDataType = (MarketDataType)0;

            if (this.cbxTrades.Checked)
            {
                marketDataType = (MarketDataType)(int)(byte)(marketDataType | MarketDataType.Trade);
            }
            if (this.cbxQuotes.Checked)
            {
                marketDataType = (MarketDataType)(int)(byte)(marketDataType | MarketDataType.Quote);
            }
            if (this.cbxMarketDepth.Checked)
            {
                marketDataType = (MarketDataType)(int)(byte)(marketDataType | MarketDataType.MarketDepth);
            }
            return(marketDataType);
        }
示例#15
0
        public void OnSecuritiesChangeDoesNotThrow(
            Language language,
            MarketDataType marketDataType)
        {
            var time = new DateTime(2018, 8, 2, 16, 0, 0);

            Func <double, int, BaseData> func = (x, i) =>
            {
                var price = Convert.ToDecimal(x);
                switch (marketDataType)
                {
                case MarketDataType.TradeBar:
                    return(new TradeBar(time.AddMinutes(i), Symbols.AAPL, price, price, price, price, 100m));

                case MarketDataType.QuoteBar:
                    var bar = new Bar(price, price, price, price);
                    return(new QuoteBar(time.AddMinutes(i), Symbols.AAPL, bar, 10m, bar, 10m));

                default:
                    throw new ArgumentException($"Invalid MarketDataType: {marketDataType}");
                }
            };

            var algorithm = new QCAlgorithm();

            algorithm.SetPandasConverter();
            algorithm.SubscriptionManager.SetDataManager(new DataManagerStub(algorithm));
            algorithm.SetDateTime(time.AddMinutes(5));

            var security = algorithm.AddEquity(Symbols.AAPL.Value);

            security.SetMarketPrice(new TradeBar {
                Value = 250
            });
            algorithm.SetFinishedWarmingUp();

            var model = GetExecutionModel(language);

            algorithm.SetExecution(model);

            var changes = new SecurityChanges(new[] { security }, Enumerable.Empty <Security>());

            Assert.DoesNotThrow(() => model.OnSecuritiesChanged(algorithm, changes));
        }
        public void AlwaysReturnTheLastData(MarketDataType marketDataType, int quantity, bool sameTime)
        {
            // Arrange
            var securityCache = new SecurityCache();
            var quotes        = GenerateData(marketDataType, quantity, sameTime);

            // Act
            foreach (var quoteBar in quotes)
            {
                quoteBar.Symbol = Symbols.SPY;
                securityCache.AddData(quoteBar);
            }

            var lastData = securityCache.GetData();

            if (marketDataType == MarketDataType.QuoteBar)
            {
                Assert.IsNull(lastData);
            }
            else
            {
                Assert.True(lastData.Equals(quotes.Last()));
            }
        }
示例#17
0
 private static void DoFixRequest(IMarketDataProvider provider, Instrument instrument, MarketDataType type, char subCh, string suffix)
 {
     FIXMarketDataRequest request = new FIXMarketDataRequest();
     request.MDReqID = DataManager.GetRequestId();
     request.SubscriptionRequestType = subCh;
     switch (type)
     {
         case MarketDataType.Trade:
             request.AddGroup(new FIXMDEntryTypesGroup('2'));
             break;
         case MarketDataType.Quote:
             request.AddGroup(new FIXMDEntryTypesGroup('0'));
             request.AddGroup(new FIXMDEntryTypesGroup('1'));
             request.MarketDepth = 1;  // Top of Book
             break;
         case MarketDataType.MarketDepth:
             request.AddGroup(new FIXMDEntryTypesGroup('0'));
             request.AddGroup(new FIXMDEntryTypesGroup('1'));
             request.MarketDepth = 0;  // Full Book
             break;
     }
     if (!instrument.ContainsField(15))
         instrument.Currency = Framework.Configuration.DefaultCurrency;
     FIXRelatedSymGroup symGrp = new FIXRelatedSymGroup();
     request.AddGroup(symGrp);
     symGrp.Symbol = instrument.Symbol;
     symGrp.SecurityType = instrument.SecurityType;
     symGrp.SecurityExchange = instrument.SecurityExchange;
     symGrp.Currency = instrument.Currency;
     symGrp.SecurityID = instrument.SecurityID;
     symGrp.SecurityIDSource = instrument.SecurityIDSource;
     symGrp.MaturityDate = instrument.MaturityDate;
     symGrp.MaturityMonthYear = instrument.MaturityMonthYear;
     symGrp.StrikePrice = instrument.StrikePrice;
     symGrp.PutOrCall = ((FIXInstrument)instrument).PutOrCall;
     foreach (FIXSecurityAltIDGroup group2 in instrument.SecurityAltIDGroup)
         symGrp.AddGroup(group2);
     symGrp.SetStringValue(10001, suffix);
     if (provider == ProviderManager.MarketDataSimulator)
     {
         provider.SendMarketDataRequest(request);
     }
     else
     {
         switch (subCh)
         {
             case MARKET_DATA_SUBSCRIBE:
                 bool flag1 = false;
                 lock (DataManager.providers)
                 {
                     Hashtable local_4 = DataManager.providers[provider] as Hashtable;
                     if (local_4 == null)
                     {
                         local_4 = new Hashtable();
                         DataManager.providers.Add(provider, local_4);
                     }
                     Hashtable local_5 = local_4[instrument] as Hashtable;
                     if (local_5 == null)
                     {
                         local_5 = new Hashtable();
                         local_4.Add(instrument, local_5);
                     }
                     RequestItem local_6 = local_5[type] as RequestItem;
                     if (local_6 == null)
                     {
                         local_6 = new RequestItem(request);
                         local_5.Add(type, local_6);
                         flag1 = true;
                     }
                     RequestItem temp_91 = local_6;
                     int temp_94 = temp_91.GetRequestId() + 1;
                     temp_91.SetRequestId(temp_94);
                 }
                 if (!flag1)
                     break;
                 provider.SendMarketDataRequest(request);
                 break;
             case MARKET_DATA_UNSUBSCRIBE:
                 bool canSend = false;
                 string msg = null;
                 lock (DataManager.providers)
                 {
                     Hashtable local_10 = DataManager.providers[provider] as Hashtable;
                     if (local_10 != null)
                     {
                         Hashtable local_11 = local_10[instrument] as Hashtable;
                         if (local_11 != null)
                         {
                             RequestItem local_12 = local_11[type] as RequestItem;
                             if (local_12 != null)
                             {
                                 RequestItem temp_152 = local_12;
                                 int temp_155 = temp_152.GetRequestId() - 1;
                                 temp_152.SetRequestId(temp_155);
                                 if (local_12.GetRequestId() == 0)
                                 {
                                     local_11.Remove(type);
                                     if (local_11.Count == 0)
                                     {
                                         local_10.Remove(instrument);
                                         if (local_10.Count == 0)
                                             DataManager.providers.Remove(provider);
                                     }
                                     canSend = true;
                                 }
                             }
                             else
                                 msg = "No this RequestItem";
                         }
                         else
                             msg = "No Request for this instrument";
                     }
                     else
                         msg = "No Request for this provider";
                 }
                 if (msg != null)
                     DataManager.LogRequestMessage(provider, instrument, type, msg);
                 if (!canSend)
                     break;
                 provider.SendMarketDataRequest(request);
                 break;
         }
     }
 }
示例#18
0
 public static bool IsSubscribed(IMarketDataProvider provider, Instrument instrument, MarketDataType mdType)
 {
     lock (DataManager.providers)
     {
         Hashtable local_0 = DataManager.providers[provider] as Hashtable;
         if (local_0 == null)
             return false;
         Hashtable local_1 = local_0[instrument] as Hashtable;
         if (local_1 == null)
             return false;
         else
             return local_1.ContainsKey(mdType);
     }
 }
示例#19
0
 public static void CancelMarketData(IMarketDataProvider provider, Instrument instrument, MarketDataType mdType, string suffix)
 {
     DataManager.DoRequest(provider, instrument, mdType, MARKET_DATA_UNSUBSCRIBE, suffix);
 }
 /// <summary>
 /// Construct a MarketDataDescription item.
 /// </summary>
 /// <param name="ticker">The ticker symbol to use.</param>
 /// <param name="dataType">The data type needed.</param>
 /// <param name="input">Is this field used for input?</param>
 /// <param name="predict">Is this field used for prediction?</param>
 public MarketDataDescription(TickerSymbol ticker,
                              MarketDataType dataType, bool input,
                              bool predict)
     : this(ticker, dataType, Type.PercentChange, null, input, predict)
 {
 }
 /// <summary>
 /// Get the specified data type.
 /// </summary>
 /// <param name="t">The type of data to get.</param>
 /// <returns>The value.</returns>
 public double GetData(MarketDataType t)
 {
     return(this.data[t]);
 }
示例#22
0
		public void RequestMarketData(IMarketDataProvider provider, Instrument instrument, MarketDataType mdType, string suffix)
		{
			if (this.useMessageLoop)
				this.form.Invoke((Action)(() => instrument.RequestMarketData(provider, mdType, suffix)));
			else
				instrument.RequestMarketData(provider, mdType, suffix);
		}
 public virtual void marketDataType(int reqId, int marketDataType)
 {
     MarketDataType?.Invoke(this, new MarketDataTypeArgs(reqId, marketDataType));
 }
示例#24
0
 public bool IsSubscribed(IMarketDataProvider provider, MarketDataType mdType)
 {
     return DataManager.IsSubscribed(provider, this, mdType);
 }
示例#25
0
 // FIXME: seriesSuffix = ?
 public void CancelMarketData(IMarketDataProvider provider, MarketDataType mdType)
 {
     this.CancelMarketData(provider, mdType, "ALL");
 }
示例#26
0
 public void CancelMarketData(IMarketDataProvider provider, MarketDataType mdType, string seriesSuffix)
 {
     DataManager.CancelMarketData(provider, this, mdType, seriesSuffix);
 }
示例#27
0
 // FIXME: seriesSuffix = ?
 public void RequestMarketData(IMarketDataProvider provider, MarketDataType mdType)
 {
     this.RequestMarketData(provider, mdType, "ALL");
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="requestId">The requestId.</param>
 /// <param name="marketDataType">Real-time only or frozen.</param>
 public MarketDataTypeEventArgs(int requestId, MarketDataType marketDataType)
 {
     _requestId = requestId;
     _marketDataType = marketDataType;
 }
 public Task <DataResponse> DataAsync(string exchange_code, string exchange_market, MarketDataType type) => RequestAsync <DataResponse>(_data,
                                                                                                                                        new KeyValuePair <string, string>[] {
     KVP("exchange_code", exchange_code),
     KVP("exchange_market", exchange_market),
     KVP("type", Enum.GetName(typeof(MarketDataType), type))
 });
示例#30
0
        private static void DoFixRequest(IMarketDataProvider provider, Instrument instrument, MarketDataType type, char subCh, string suffix)
        {
            FIXMarketDataRequest request = new FIXMarketDataRequest();

            request.MDReqID = DataManager.GetRequestId();
            request.SubscriptionRequestType = subCh;
            switch (type)
            {
            case MarketDataType.Trade:
                request.AddGroup(new FIXMDEntryTypesGroup('2'));
                break;

            case MarketDataType.Quote:
                request.AddGroup(new FIXMDEntryTypesGroup('0'));
                request.AddGroup(new FIXMDEntryTypesGroup('1'));
                request.MarketDepth = 1;      // Top of Book
                break;

            case MarketDataType.MarketDepth:
                request.AddGroup(new FIXMDEntryTypesGroup('0'));
                request.AddGroup(new FIXMDEntryTypesGroup('1'));
                request.MarketDepth = 0;      // Full Book
                break;
            }
            if (!instrument.ContainsField(15))
            {
                instrument.Currency = Framework.Configuration.DefaultCurrency;
            }
            FIXRelatedSymGroup symGrp = new FIXRelatedSymGroup();

            request.AddGroup(symGrp);
            symGrp.Symbol            = instrument.Symbol;
            symGrp.SecurityType      = instrument.SecurityType;
            symGrp.SecurityExchange  = instrument.SecurityExchange;
            symGrp.Currency          = instrument.Currency;
            symGrp.SecurityID        = instrument.SecurityID;
            symGrp.SecurityIDSource  = instrument.SecurityIDSource;
            symGrp.MaturityDate      = instrument.MaturityDate;
            symGrp.MaturityMonthYear = instrument.MaturityMonthYear;
            symGrp.StrikePrice       = instrument.StrikePrice;
            symGrp.PutOrCall         = ((FIXInstrument)instrument).PutOrCall;
            foreach (FIXSecurityAltIDGroup group2 in instrument.SecurityAltIDGroup)
            {
                symGrp.AddGroup(group2);
            }
            symGrp.SetStringValue(10001, suffix);
            if (provider == ProviderManager.MarketDataSimulator)
            {
                provider.SendMarketDataRequest(request);
            }
            else
            {
                switch (subCh)
                {
                case MARKET_DATA_SUBSCRIBE:
                    bool flag1 = false;
                    lock (DataManager.providers)
                    {
                        Hashtable local_4 = DataManager.providers[provider] as Hashtable;
                        if (local_4 == null)
                        {
                            local_4 = new Hashtable();
                            DataManager.providers.Add(provider, local_4);
                        }
                        Hashtable local_5 = local_4[instrument] as Hashtable;
                        if (local_5 == null)
                        {
                            local_5 = new Hashtable();
                            local_4.Add(instrument, local_5);
                        }
                        RequestItem local_6 = local_5[type] as RequestItem;
                        if (local_6 == null)
                        {
                            local_6 = new RequestItem(request);
                            local_5.Add(type, local_6);
                            flag1 = true;
                        }
                        RequestItem temp_91 = local_6;
                        int         temp_94 = temp_91.GetRequestId() + 1;
                        temp_91.SetRequestId(temp_94);
                    }
                    if (!flag1)
                    {
                        break;
                    }
                    provider.SendMarketDataRequest(request);
                    break;

                case MARKET_DATA_UNSUBSCRIBE:
                    bool   canSend = false;
                    string msg     = null;
                    lock (DataManager.providers)
                    {
                        Hashtable local_10 = DataManager.providers[provider] as Hashtable;
                        if (local_10 != null)
                        {
                            Hashtable local_11 = local_10[instrument] as Hashtable;
                            if (local_11 != null)
                            {
                                RequestItem local_12 = local_11[type] as RequestItem;
                                if (local_12 != null)
                                {
                                    RequestItem temp_152 = local_12;
                                    int         temp_155 = temp_152.GetRequestId() - 1;
                                    temp_152.SetRequestId(temp_155);
                                    if (local_12.GetRequestId() == 0)
                                    {
                                        local_11.Remove(type);
                                        if (local_11.Count == 0)
                                        {
                                            local_10.Remove(instrument);
                                            if (local_10.Count == 0)
                                            {
                                                DataManager.providers.Remove(provider);
                                            }
                                        }
                                        canSend = true;
                                    }
                                }
                                else
                                {
                                    msg = "No this RequestItem";
                                }
                            }
                            else
                            {
                                msg = "No Request for this instrument";
                            }
                        }
                        else
                        {
                            msg = "No Request for this provider";
                        }
                    }
                    if (msg != null)
                    {
                        DataManager.LogRequestMessage(provider, instrument, type, msg);
                    }
                    if (!canSend)
                    {
                        break;
                    }
                    provider.SendMarketDataRequest(request);
                    break;
                }
            }
        }
示例#31
0
 private static void DoRequest(IMarketDataProvider provider, Instrument instrument, MarketDataType type, char subCh, string suffix)
 {
     if ((type & MarketDataType.Trade) == MarketDataType.Trade)
     {
         DataManager.DoFixRequest(provider, instrument, MarketDataType.Trade, subCh, suffix);
     }
     if ((type & MarketDataType.Quote) == MarketDataType.Quote)
     {
         DataManager.DoFixRequest(provider, instrument, MarketDataType.Quote, subCh, suffix);
     }
     if ((type & MarketDataType.MarketDepth) != MarketDataType.MarketDepth)
     {
         return;
     }
     DataManager.DoFixRequest(provider, instrument, MarketDataType.MarketDepth, subCh, suffix);
 }
示例#32
0
 /// <summary>
 /// Construct a MarketDataDescription item.
 /// </summary>
 /// <param name="ticker">The ticker symbol to use.</param>
 /// <param name="dataType">The data type needed.</param>
 /// <param name="input">Is this field used for input?</param>
 /// <param name="predict">Is this field used for prediction?</param>
 public MarketDataDescription(TickerSymbol ticker,
                              MarketDataType dataType, bool input,
                              bool predict)
     : this(ticker, dataType, Type.PERCENT_CHANGE, null, input, predict)
 {
 }
示例#33
0
 /// <summary>
 /// Get the specified data type.
 /// </summary>
 /// <param name="t">The type of data to get.</param>
 /// <returns>The value.</returns>
 public double GetData(MarketDataType t)
 {
     return _data[t];
 }
示例#34
0
		public void CancelMarketData(IMarketDataProvider provider, Instrument instrument, MarketDataType mdType)
		{
			if (this.useMessageLoop)
				this.form.Invoke((Action)(() => instrument.CancelMarketData(provider, mdType)));
			else
				instrument.CancelMarketData(provider, mdType);
		}
示例#35
0
 public void marketDataType(int reqId, int marketDataType)
 {
     MarketDataType?.Invoke(new MarketDataTypeMessage(reqId, marketDataType));
 }
示例#36
0
 public Mantle.Fix44.MarketDataRequest MarketDataRequest(string symbol, MarketDataType type)
 {
     var res = new Mantle.Fix44.MarketDataRequest();
     res = new Mantle.Fix44.MarketDataRequest() { StandardHeader = StandardHeader() };
     var instrument = new Mantle.Fix44.Instrument();
     instrument.Symbol.Value = symbol;
     res.RelatedSym.Add(instrument);
     // It's important for huobi that MDReqID has symbol as its prefix. Otherwise they'll
     // silently ignore our request. This is undocumented.
     res.MDReqID.Value = symbol + Guid.NewGuid().ToString();
     // '0' - snapshot only
     // '1' - snapshot followed by incremental refresh
     res.SubscriptionRequestType.Value = '1';
     if (_cfg.Extensions == Extensions.OkCoin && type == MarketDataType.Order)
     {
         // OkCoin sends incremental refresh for the first 20 rows only, which isn't enough for us.
         // We have to periodically request the full snapshot instead.
         res.SubscriptionRequestType.Value = '0';
     }
     res.MarketDepth.Value = 0;
     res.MDUpdateType.Value = 1;
     switch (type)
     {
         case MarketDataType.Order:
             // Bids.
             res.MDEntryTypes.Add(new Mantle.Fix44.MDEntryType() { Value = '0' });
             // Asks.
             res.MDEntryTypes.Add(new Mantle.Fix44.MDEntryType() { Value = '1' });
             break;
         case MarketDataType.Trade:
             // Live trades.
             res.MDEntryTypes.Add(new Mantle.Fix44.MDEntryType() { Value = '2' });
             break;
     }
     return res;
 }
 /// <summary>
 /// Construct a MarketDataDescription item.
 /// </summary>
 /// <param name="ticker">The ticker symbol to use.</param>
 /// <param name="dataType">The data type needed.</param>
 /// <param name="input">Is this field used for input?</param>
 /// <param name="predict">Is this field used for prediction?</param>
 public MarketDataDescription(TickerSymbol ticker,
                              MarketDataType dataType, bool input,
                              bool predict)
     : this(ticker, dataType, Type.PercentChange, null, input, predict)
 {
 }
示例#38
0
 /// <summary>
 /// Set the specified type of data.
 /// </summary>
 /// <param name="t">The type of data to set.</param>
 /// <param name="d">The value to set.</param>
 public void SetData(MarketDataType t, double d)
 {
     _data[t] = d;
 }
        /// <summary>
        /// Construct a MarketDataDescription item.
        /// </summary>
        /// <param name="ticker">The ticker symbol to use.</param>
        /// <param name="dataType">The data type needed.</param>
        /// <param name="input">Is this field used for input?</param>
        /// <param name="predict">Is this field used for prediction?</param>
        public MarketDataDescription(TickerSymbol ticker,
                MarketDataType dataType, bool input,
                bool predict)
            : this(ticker, dataType, Type.PERCENT_CHANGE, null, input, predict)
        {

        }
        private IReadOnlyCollection <BaseData> GenerateData(MarketDataType type, int quantity, bool sameTime, DateTime?firstTimeStamp = null)
        {
            var time            = firstTimeStamp ?? DateTime.Now;
            var outputTradeBars = new List <BaseData>();

            for (var i = 0; i < quantity; i++)
            {
                var rnd = _rng.Next(minValue: 50, maxValue: 150);
                var ask = new Bar {
                    Close = 1m * rnd, High = 1.2m * rnd, Low = 0.9m * rnd, Open = 1.1m * rnd
                };
                var bid = new Bar {
                    Close = 0.9m * rnd, High = 1.1m * rnd, Low = 0.8m * rnd, Open = 1m * rnd
                };
                BaseData data = new TradeBar();
                switch (type)
                {
                case MarketDataType.TradeBar:
                    data = new TradeBar
                    {
                        Close    = (ask.Close + bid.Close) / 2,
                        Open     = (ask.Open + bid.Open) / 2,
                        High     = (ask.High + bid.High) / 2,
                        Low      = (ask.Low + bid.Low) / 2,
                        Volume   = 1,
                        DataType = type
                    };
                    break;

                case MarketDataType.Tick:
                    data = new Tick
                    {
                        AskPrice = ask.Close,
                        BidPrice = bid.Close,
                        AskSize  = 1,
                        BidSize  = 1
                    };
                    break;

                case MarketDataType.QuoteBar:
                    data = new QuoteBar
                    {
                        Ask         = ask,
                        Bid         = bid,
                        LastAskSize = 1,
                        LastBidSize = 1,
                        DataType    = type,
                        Value       = (ask.Close + bid.Close) / 2
                    };
                    break;

                case MarketDataType.Auxiliary:
                case MarketDataType.OptionChain:
                case MarketDataType.FuturesChain:
                case MarketDataType.Base:
                    throw new NotImplementedException("Cases not tested yet");
                }
                data.Time    = time;
                data.EndTime = time.AddSeconds(value: 1);
                time         = sameTime ? time : time.AddSeconds(value: 1);
                outputTradeBars.Add(data);
            }
            return(outputTradeBars);
        }
示例#41
0
 private void CancelMarketData(Instrument[] array, MarketDataType mdType)
 {
   ThreadPool.QueueUserWorkItem((WaitCallback) (objects =>
   {
     foreach (Instrument item_0 in (Instrument[]) objects)
       Global.ProviderHelper.CancelMarketData(this.provider, item_0, mdType);
   }), array);
 }
示例#42
0
 void IEWrapper.MarketDataType(int reqId, int marketDataType)
 {
     MarketDataType?.Invoke(new MarketDataTypeMessage(reqId, marketDataType));
 }
 public void SetMarketDataUsingKrxData(InPacket iPacket, MarketDataType type)
 {
     switch (type)
     {
         case MarketDataType.KOSPI_FUTURE:
             {
                 SetKospiFutureDataUsingKrxData(iPacket);
                 break;
             }
         case MarketDataType.CALL:
             {
                 SetOptionDataUsingKrxData(iPacket);
                 break;
             }
         case MarketDataType.PUT:
             {
                 SetOptionDataUsingKrxData(iPacket);
                 break;
             }
         case MarketDataType.ELW:
             {
                 SetElwDataUsingKrxData(iPacket);
                 break;
             }
         case MarketDataType.BOND:
             {
                 SetBondDataUsingKrxData(iPacket);
                 break;
             }
         case MarketDataType.STOCK:
             {
                 SetStockDataUsingKrxData(iPacket);
                 break;
             }
         case MarketDataType.USD_FUTURE:
             {
                 SetUsdFutureDataUsingInfomaxData(iPacket);
                 break;
             }
         default:
             {
                 logger.Warn("Invalid type.");
                 break;
             }
     }
 }
示例#44
0
 public static void CancelMarketData(IMarketDataProvider provider, Instrument instrument, MarketDataType mdType)
 {
     DataManager.CancelMarketData(provider, instrument, mdType, SERIES_SEPARATOR + "UNSUBSCRIBE");
 }
 public void SetMarketDataUsingYulchonData(InPacket iPacket, MarketDataType type)
 {
     ++this.PacketCount;
     switch (type)
     {
         case MarketDataType.KOSPI_FUTURE:
             {
                 SetIndexFutureDataUsingYulchonData(iPacket);
                 break;
             }
         case MarketDataType.CALL:
             {
                 SetIndexOptionDataUsingYulchonData(iPacket);
                 break;
             }
         case MarketDataType.PUT:
             {
                 SetIndexOptionDataUsingYulchonData(iPacket);
                 break;
             }
         case MarketDataType.ELW:
             {
                 SetIndexElwDataUsingYulchonData(iPacket);
                 break;
             }
         default:
             {
                 HandleDefaultData(iPacket);
                 break;
             }
     }
 }
示例#46
0
 private static void DoRequest(IMarketDataProvider provider, Instrument instrument, MarketDataType type, char subCh, string suffix)
 {
     if ((type & MarketDataType.Trade) == MarketDataType.Trade)
         DataManager.DoFixRequest(provider, instrument, MarketDataType.Trade, subCh, suffix);
     if ((type & MarketDataType.Quote) == MarketDataType.Quote)
         DataManager.DoFixRequest(provider, instrument, MarketDataType.Quote, subCh, suffix);
     if ((type & MarketDataType.MarketDepth) != MarketDataType.MarketDepth)
         return;
     DataManager.DoFixRequest(provider, instrument, MarketDataType.MarketDepth, subCh, suffix);
 }
示例#47
0
 public MarketDataDescription(TickerSymbol ticker, MarketDataType dataType, TemporalDataDescription.Type type, bool input, bool predict)
     : this(ticker, dataType, type, null, input, predict)
 {
 }
示例#48
0
 private static void LogRequestMessage(IMarketDataProvider provider, Instrument instrument, MarketDataType mdType, string obj3)
 {
     if (Trace.IsLevelEnabled(TraceLevel.Warning))
     {
         Trace.WriteLine("" + Environment.NewLine + "" + provider.Name + Environment.NewLine + "Symbol" + instrument.Symbol + Environment.NewLine + "Type:" + mdType.ToString() + Environment.NewLine + "" + obj3);
     }
 }
示例#49
0
 public MarketDataDescription(TickerSymbol ticker, MarketDataType dataType, TemporalDataDescription.Type type, IActivationFunction activationFunction, bool input, bool predict)
     : base(activationFunction, type, input, predict)
 {
     this._x96e4701dec47675e = ticker;
     this._xd2f3d36b96df4542 = dataType;
 }
示例#50
0
 public void SetMarketDataType(MarketDataType _marketDataType)
 {
     clientSocket.reqMarketDataType((int)_marketDataType);
 }
示例#51
0
 private static void LogRequestMessage(IMarketDataProvider provider, Instrument instrument, MarketDataType mdType, string obj3)
 {
     if (Trace.IsLevelEnabled(TraceLevel.Warning))
     {
         Trace.WriteLine("" + Environment.NewLine + "" + provider.Name + Environment.NewLine + "Symbol" + instrument.Symbol + Environment.NewLine + "Type:" + mdType.ToString() + Environment.NewLine + "" + obj3);
     }
 }
示例#52
0
 void EWrapper.marketDataType(int reqId, int marketDataType)
 {
     MarketDataType?.Invoke(reqId, marketDataType);
 }
        public void HandleMarketDataTypeMessage(MarketDataTypeMessage dataMessage)
        {
            DataGridView grid = (DataGridView)uiControl;

            grid[MARKET_DATA_TYPE_INDEX, GetIndex(dataMessage.RequestId)].Value = MarketDataType.get(dataMessage.MarketDataType).Name;
        }