Inheritance: DataObject
 internal AccountDataEntry(string account, AccountData values, AccountData[] positions, AccountData[] orders)
 {
     Account = account;
     Values = values;
     Positions = positions;
     Orders = orders;
 }
Exemple #2
0
        public AccountDataSnapshot GetSnapshot(byte providerId, byte route)
        {
            var table = GetTable(providerId, route, false);
            if (table == null)
                return new AccountDataSnapshot(new AccountDataEntry[0]);

            AccountDataSnapshot result;
            lock (table)
            {
                var list = new List<AccountDataEntry>();
                foreach (string current in table.Items.Keys)
                {
                    var class2 = table.Items[current];
                    var accountData = new AccountData(this.framework.Clock.DateTime, AccountDataType.AccountValue, current, providerId, route);
                    CopyFields(class2.Values, accountData.Fields);
                    var list2 = new List<AccountData>();
                    foreach (var current2 in class2.Positions.Values)
                    {
                        var accountData2 = new AccountData(this.framework.Clock.DateTime, AccountDataType.Position, current, providerId, route);
                        CopyFields(current2, accountData2.Fields);
                        list2.Add(accountData2);
                    }
                    var list3 = new List<AccountData>();
                    foreach (var current3 in class2.Orders.Values)
                    {
                        var accountData3 = new AccountData(this.framework.Clock.DateTime, AccountDataType.Order, current, providerId, route);
                        CopyFields(current3, accountData3.Fields);
                        list3.Add(accountData3);
                    }
                    list.Add(new AccountDataEntry(current, accountData, list2.ToArray(), list3.ToArray()));
                }
                result = new AccountDataSnapshot(list.ToArray());
            }
            return result;
        }
 public AccountDataEventArgs(AccountData data)
 {
     Data = data;
 }
Exemple #4
0
 public override object Read(BinaryReader reader, byte version)
 {
     var datetime = new DateTime(reader.ReadInt64());
     var type = (AccountDataType)reader.ReadInt32();
     var account = reader.ReadString();
     var providerId = reader.ReadByte();
     var route = reader.ReadByte();
     var accountData = new AccountData(datetime, type, account, providerId, route);
     int count = reader.ReadInt32();
     for (int i = 0; i < count; i++)
     {
         var name = reader.ReadString();
         var currency = reader.ReadString();
         object value = StreamerManager.Deserialize(reader);
         accountData.Fields.Add(name, currency, value);
     }
     return accountData;
 }
Exemple #5
0
 internal void OnAccountData(AccountData data)
 {
     if (Strategy != null && Strategy.Status == StrategyStatus.Running && Mode != StrategyMode.Backtest)
         Strategy.EmitAccountData(data);
 }
Exemple #6
0
 internal void OnAccountData(AccountData data)
 {
     var @class = GetTable(data.ProviderId, data.Route, true);
     lock (@class)
     {
         AccountDataTableItem class2;
         if ([email protected](data.Account, out class2))
         {
             class2 = new AccountDataTableItem();
             @class.Items.Add(data.Account, class2);
         }
         switch (data.Type)
         {
             case AccountDataType.AccountValue:
                 MergeFields(data.Fields, class2.Values);
                 break;
             case AccountDataType.Position:
                 {
                     AccountDataKey key = new AccountDataKey(data, new[] { "Symbol", "Maturity", "PutOrCall", "Strike" });
                     AccountDataFieldList list;
                     if (!class2.Positions.TryGetValue(key, out list))
                     {
                         list = new AccountDataFieldList();
                         class2.Positions.Add(key, list);
                     }
                     list.Clear();
                     CopyFields(data.Fields, list);
                     break;
                 }
             case AccountDataType.Order:
                 {
                     AccountDataKey key2 = new AccountDataKey(data, new[] { "OrderID" });
                     AccountDataFieldList list;
                     if (!class2.Orders.TryGetValue(key2, out list))
                     {
                         list = new AccountDataFieldList();
                         class2.Orders.Add(key2, list);
                     }
                     list.Clear();
                     CopyFields(data.Fields, list);
                     break;
                 }
         }
     }
 }
Exemple #7
0
 private static string GetValue(AccountData data, string fieldName) => data.Fields[fieldName]?.ToString() ?? string.Empty;
Exemple #8
0
 public AccountDataKey(AccountData data, params string[] fieldNames)
 {
     _key = string.Join("\u0001", fieldNames.Select(f => GetValue(data, f)));
 }
Exemple #9
0
 protected internal void EmitAccountData(AccountData data)
 {
     if (this.executionQueue != null)
         this.executionQueue.Enqueue(data);
     else
         this.framework.EventServer.OnEvent(data);
 }
Exemple #10
0
 public AccountDataEventArgs(AccountData data)
 {
     Data = data;
 }
 private static string GetValue(AccountData data, string fieldName) => data.Fields[fieldName]?.ToString() ?? string.Empty;
 public AccountDataKey(AccountData data, params string[] fieldNames)
 {
     _key = string.Join("\u0001", fieldNames.Select(f => GetValue(data, f)));
 }