Пример #1
0
            public StudioSecurityList(StudioEntityRegistry registry)
                : base(registry.Storage)
            {
                _registry = registry;

                var database = (Database)registry.Storage;

                var readAllByUnderlyingSecurityId = Query
                                                    .Select(Schema)
                                                    .From(Schema)
                                                    .Where()
                                                    .Equals(Schema.Fields["UnderlyingSecurityId"])
                                                    .And()
                                                    .OpenBracket()
                                                    .IsParamNull(Schema.Fields["ExpiryDate"])
                                                    .Or()
                                                    .Equals(Schema.Fields["ExpiryDate"])
                                                    .CloseBracket();

                _readAllByUnderlyingSecurityId = database.GetCommand(readAllByUnderlyingSecurityId, Schema, new FieldList(new[] { Schema.Fields["UnderlyingSecurityId"], Schema.Fields["ExpiryDate"] }), new FieldList());

                var readSecurityIds = Query
                                      .Execute("SELECT group_concat(Id, ',') FROM Security");

                _readSecurityIds = database.GetCommand(readSecurityIds, null, new FieldList(), new FieldList());
            }
Пример #2
0
            public ContinuousSecurityList(StudioEntityRegistry registry)
            {
                _registry = registry;

                _jumps = new JumpList(_registry.Storage)
                {
                    BulkLoad = true
                };

                foreach (var group in _jumps.GroupBy(j => j.Id.ContinuousSecurity))
                {
                    group.ForEach(s => s.Id.JumpSecurity.CheckExchange());

                    var underlyingSecurity = group.First().Id.JumpSecurity;

                    var cs = new ContinuousSecurity
                    {
                        Id            = group.Key,
                        Board         = underlyingSecurity.Board,
                        Type          = underlyingSecurity.Type,
                        PriceStep     = underlyingSecurity.PriceStep,
                        ExtensionInfo = new Dictionary <object, object>(),
                    };

                    cs.ExpirationJumps.AddRange(group.Select(j => new KeyValuePair <Security, DateTimeOffset>(j.Id.JumpSecurity, j.JumpDate)));

                    Add(cs);
                }
            }
Пример #3
0
            public StrategyInfoList(StudioEntityRegistry parent, Session session)
                : base(parent.Storage)
            {
                if (session == null)
                {
                    throw new ArgumentNullException(nameof(session));
                }

                Recycle = false;

                //_parent = parent;
                _session = session;

                DelayAction = parent.DelayAction;

                _session.Strategies.DelayAction = parent.DelayAction;
                _session.News.DelayAction       = parent.DelayAction;

                _session.Strategies.Added += SessionStrategiesAdded;

                var id = _session.RowId.ToString(CultureInfo.InvariantCulture);

                CountQuery = Query
                             .Select("count(*)")
                             .From(Schema)
                             .Where()
                             .Equals("Session", id);

                ReadAllQuery = Query
                               .Select(Schema)
                               .From(Schema)
                               .Where()
                               .Equals("Session", id);

                var readByType = Query
                                 .Select(Schema)
                                 .From(Schema)
                                 .Where()
                                 .Equals(Schema.Fields["Type"]);

                _readByType = ((Database)Storage).GetCommand(readByType, null, new FieldList(new[] { Schema.Fields["Type"] }), new FieldList());
            }