コード例 #1
0
        static void Main(string[] args)
        {
            // instances des classes JsonRpcService
            MiscRequests = new MiscRequests();
            DataRequests = new DataRequests();
            //

            var rpcResultHandler = new AsyncCallback(
                state =>
            {
                var async  = ((JsonRpcStateAsync)state);
                var result = async.Result;
                var writer = ((StreamWriter)async.AsyncState);

                writer.WriteLine(result);
                writer.FlushAsync();
            });

            SocketListener.start(3333, (writer, line) =>
            {
                var async = new JsonRpcStateAsync(rpcResultHandler, writer)
                {
                    JsonRpc = line
                };
                JsonRpcProcessor.Process(async, writer);
            });
        }
コード例 #2
0
        public ActionResult DataRequestDeleted(int id)
        {
            DataRequests dataRequest = _context.DataRequests.FirstOrDefault(x => x.Id == id);

            _context.DataRequests.Remove(dataRequest);
            _context.SaveChanges();

            return(RedirectToAction("AllDataRequest"));
        }
コード例 #3
0
ファイル: WebServer.cs プロジェクト: nbogojevic/NeboGauges
        internal bool OnDataRequest(DataRequests feed, object data)
        {
            HashSet <WebSocketContext> existingSubscribers = subscribers[feed];
            String json = Json.Serialize(new { feed = feed.ToString(), data });

            foreach (var ctx in existingSubscribers)
            {
                this.Send(ctx, json);
            }
            return(existingSubscribers.Count > 0);
        }
コード例 #4
0
ファイル: WebServer.cs プロジェクト: nbogojevic/NeboGauges
        /// <summary>
        /// Called when this WebSockets Server receives a full message (EndOfMessage) form a WebSockets client.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="rxBuffer">The rx buffer.</param>
        /// <param name="rxResult">The rx result.</param>
        protected override void OnMessageReceived(WebSocketContext context, byte[] rxBuffer, WebSocketReceiveResult rxResult)
        {
            var          result = System.Text.Encoding.UTF8.GetString(rxBuffer);
            DataRequests feed   = (DataRequests)Enum.Parse(typeof(DataRequests), result);

            subscribers[feed].Add(context);
            if (!NeboContext.Instance.Polling[feed].Running)
            {
                NeboContext.Instance.Polling[feed].Start();
            }
        }
コード例 #5
0
        public ActionResult DataRequestCreated(DataRequests dataRequest)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Something went wrong!");
                return(View("CreateDataRequest"));
            }
            db.DataRequests.Add(dataRequest);
            db.SaveChanges();

            return(RedirectToAction("DataRequests", "Home"));
        }
コード例 #6
0
        public ActionResult DataRequestEdited(DataRequest newDataRequest)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Something went wrong!");
                return(View("EditDataRequest", newDataRequest));
            }

            DataRequests oldDataRequest = _context.DataRequests.FirstOrDefault(x => x.Id == newDataRequest.Id);

            oldDataRequest.Title       = newDataRequest.Title;
            oldDataRequest.Description = newDataRequest.Description;
            oldDataRequest.StatusId    = newDataRequest.StatusId;
            _context.SaveChanges();

            return(RedirectToAction("AllDataRequest"));
        }
コード例 #7
0
        public void Online(bool resetState)
        {
            if (resetState)
            {
                this.stops.Clear();
            }
            DataRequests dataRequests = (DataRequests)null;

            if (resetState)
            {
                dataRequests = this.BuildStrategyRequest();
                OpenQuant.API.Strategy.Global.Clear();
            }
            if (resetState)
            {
                UserCommandManager.Clear();
            }
            if (resetState)
            {
                this.strategyLogManager.Clear();
            }
            foreach (StrategyRunner strategyRunner in this.strategies.Values)
            {
                if (strategyRunner.Enabled)
                {
                    strategyRunner.Portfolio.TransactionAdded += new TransactionEventHandler(this.Portfolio_TransactionAdded);
                }
                if (resetState)
                {
                    strategyRunner.DataRequests       = dataRequests;
                    strategyRunner.StartDate          = this.startDate;
                    strategyRunner.StopDate           = this.stopDate;
                    strategyRunner.Cash               = this.cash;
                    strategyRunner.MetaPortfolio      = this.portfolio;
                    strategyRunner.StrategyLogManager = this.strategyLogManager;
                }
                strategyRunner.Online(resetState);
            }
            this.Connect();
        }
コード例 #8
0
ファイル: Solution.cs プロジェクト: zhuzhenping/OpenQuant.API
 private Solution()
 {
     this.Requests = new DataRequests();
 }
コード例 #9
0
ファイル: WebServer.cs プロジェクト: nbogojevic/NeboGauges
 internal bool HasListeners(DataRequests request)
 {
     return(subscribers[request].Count > 0);
 }
コード例 #10
0
 /// <summary>
 /// Updates the data from the EDDB database.
 /// </summary>
 /// <param name="data">Datatype to be updated.</param>
 public void UpdateData(DataRequests data)
 {
     UpdateData(new DataRequests[] { data });
 }
コード例 #11
0
ファイル: Solution.cs プロジェクト: houzhongxu/OpenQuant.API
		private Solution()
		{
			this.Requests = new DataRequests();
		}
コード例 #12
0
        private DataRequests BuildStrategyRequest()
        {
            bool flag1 = false;
            bool flag2 = false;
            bool flag3 = false;
            bool flag4 = false;
            bool flag5 = false;
            List <OpenQuant.API.BarRequest> list = new List <OpenQuant.API.BarRequest>();

            foreach (MarketDataRequest marketDataRequest in this.requests)
            {
                if (marketDataRequest.Enabled)
                {
                    switch (marketDataRequest.RequestType)
                    {
                    case RequestType.Trade:
                        flag3 = true;
                        continue;

                    case RequestType.Quote:
                        flag2 = true;
                        continue;

                    case RequestType.MarketDepth:
                        flag5 = true;
                        continue;

                    case RequestType.Bar:
                        flag1 = true;
                        BarRequest barRequest = marketDataRequest as BarRequest;
                        if (barRequest.IsBarFactoryRequest)
                        {
                            flag3 = true;
                        }
                        list.Add(new OpenQuant.API.BarRequest(this.ConvertBarType(barRequest.BarType), barRequest.BarSize, barRequest.IsBarFactoryRequest));
                        continue;

                    case RequestType.Daily:
                        flag4 = true;
                        continue;

                    default:
                        continue;
                    }
                }
            }
            DataRequests dataRequests = new DataRequests();

            dataRequests.GetType().GetProperty("HasBarRequests", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.GetProperty | BindingFlags.SetProperty).SetValue((object)dataRequests, flag1, (object[])null);
            dataRequests.GetType().GetProperty("HasTradeRequest", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.GetProperty | BindingFlags.SetProperty).SetValue((object)dataRequests, flag3, (object[])null);
            dataRequests.GetType().GetProperty("HasQuoteRequest", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.GetProperty | BindingFlags.SetProperty).SetValue((object)dataRequests, flag2, (object[])null);
            dataRequests.GetType().GetProperty("HasDailyRequest", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.GetProperty | BindingFlags.SetProperty).SetValue((object)dataRequests, flag4, (object[])null);
            dataRequests.GetType().GetProperty("HasMarketDepthRequest", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.GetProperty | BindingFlags.SetProperty).SetValue((object)dataRequests, flag5, (object[])null);
            MethodInfo methodInfo1 = (MethodInfo)null;

            foreach (MethodInfo methodInfo2 in dataRequests.BarRequests.GetType().GetMethods())
            {
                if (methodInfo2.Name == "Add" && methodInfo2.GetParameters().Length == 1)
                {
                    methodInfo1 = methodInfo2;
                }
            }
            foreach (OpenQuant.API.BarRequest barRequest in list)
            {
                methodInfo1.Invoke((object)dataRequests.BarRequests, new object[1]
                {
                    (object)barRequest
                });
            }
            return(dataRequests);
        }