Exemple #1
0
        public ChartManager GetChartManager(int accountID, int insID, Timeframes tf)
        {
            lock (_cmCache)
            {
                ChartManager cm = _cmCache.GetChartManager(accountID, insID, tf);
                if (cm != null)
                {
                    return(cm);
                }

                var account = _accountDA.GetAccountByID(accountID);
                if (account == null)
                {
                    return(null);
                }

                if (account.AccountType == AccountTypes.Real)
                {
                    cm = new ChartManager(_instrumBL, _insStoreBL, _accountDA, _tickDisp);
                }
                else
                {
                    DateTime end   = DateTime.Today;
                    DateTime start = end.AddDays(-1);
                    var      json  = _reposBL.GetStringParam(TestRun.ACCOUNT_META + accountID.ToString());
                    try
                    {
                        var meta = JsonConvert.DeserializeObject <AccountMeta>(json);
                        if (meta != null)
                        {
                            start = meta.TickSource_StartDate;
                            end   = meta.TickSource_EndDate;
                        }
                    }
                    catch { }
                    cm = new ChartManager(_instrumBL, _insStoreBL, _accountDA, start, end);
                }

                var chart = _chartDA.GetChart(accountID, insID, tf);
                if (chart != null)
                {
                    cm.Initialize(chart.XmlData);
                }
                else
                {
                    cm.Initialize();
                    cm.CreatePrices(insID, tf);
                }

                cm.LoadHistoryAsync().Wait(); // нехорошо ждать внутри лока

                _cmCache.AddChartManager(accountID, insID, tf, cm);

                return(cm);
            }
        }
Exemple #2
0
        public string GetAccountMeta(int accountID)
        {
            var json = _reposBL.GetStringParam(TestRun.ACCOUNT_META + accountID.ToString());

            if (json == null)
            {
                json = "";
            }
            return(json);
        }