Ejemplo n.º 1
0
        internal void OnAccountData(AccountData data)
        {
            AccountDataTable table = this.GetTable(data.ProviderId, data.Route, true);

            lock (table)
            {
                AccountDataTableItem accountDataTableItem;
                if (!table.Items.TryGetValue(data.Account, out accountDataTableItem))
                {
                    accountDataTableItem = new AccountDataTableItem();
                    table.Items.Add(data.Account, accountDataTableItem);
                }
                switch (data.Type)
                {
                case AccountDataType.AccountValue:
                    this.MergeFields(data.Fields, accountDataTableItem.Values);
                    break;

                case AccountDataType.Position:
                {
                    AccountDataKey key = new AccountDataKey(data, new string[]
                        {
                            "Symbol",
                            "Maturity",
                            "PutOrCall",
                            "Strike"
                        });
                    AccountDataFieldList accountDataFieldList;
                    if (!accountDataTableItem.Positions.TryGetValue(key, out accountDataFieldList))
                    {
                        accountDataFieldList = new AccountDataFieldList();
                        accountDataTableItem.Positions.Add(key, accountDataFieldList);
                    }
                    accountDataFieldList.Clear();
                    this.CopyFields(data.Fields, accountDataFieldList);
                    break;
                }

                case AccountDataType.Order:
                {
                    AccountDataKey key2 = new AccountDataKey(data, new string[]
                        {
                            "OrderID"
                        });
                    AccountDataFieldList accountDataFieldList2;
                    if (!accountDataTableItem.Orders.TryGetValue(key2, out accountDataFieldList2))
                    {
                        accountDataFieldList2 = new AccountDataFieldList();
                        accountDataTableItem.Orders.Add(key2, accountDataFieldList2);
                    }
                    accountDataFieldList2.Clear();
                    this.CopyFields(data.Fields, accountDataFieldList2);
                    break;
                }
                }
            }
        }
Ejemplo n.º 2
0
        private AccountDataTable GetTable(byte providerId, byte route, bool addNew)
        {
            int key = (int)providerId * 256 + (int)route;
            AccountDataTable accountDataTable;

            lock (this.tables)
            {
                if (!this.tables.TryGetValue(key, out accountDataTable))
                {
                    if (addNew)
                    {
                        accountDataTable = new AccountDataTable();
                        this.tables.Add(key, accountDataTable);
                    }
                    else
                    {
                        accountDataTable = null;
                    }
                }
            }
            return(accountDataTable);
        }
Ejemplo n.º 3
0
        public AccountDataSnapshot GetSnapshot(byte providerId, byte route)
        {
            AccountDataTable table = this.GetTable(providerId, route, false);

            if (table == null)
            {
                return(new AccountDataSnapshot(new AccountDataEntry[0]));
            }
            AccountDataSnapshot result;

            lock (table)
            {
                List <AccountDataEntry> list = new List <AccountDataEntry>();
                foreach (string current in table.Items.Keys)
                {
                    AccountDataTableItem accountDataTableItem = table.Items[current];
                    AccountData          accountData          = new AccountData(this.framework.Clock.DateTime, AccountDataType.AccountValue, current, providerId, route);
                    this.CopyFields(accountDataTableItem.Values, accountData.Fields);
                    List <AccountData> list2 = new List <AccountData>();
                    foreach (AccountDataFieldList current2 in accountDataTableItem.Positions.Values)
                    {
                        AccountData accountData2 = new AccountData(this.framework.Clock.DateTime, AccountDataType.Position, current, providerId, route);
                        this.CopyFields(current2, accountData2.Fields);
                        list2.Add(accountData2);
                    }
                    List <AccountData> list3 = new List <AccountData>();
                    foreach (AccountDataFieldList current3 in accountDataTableItem.Orders.Values)
                    {
                        AccountData accountData3 = new AccountData(this.framework.Clock.DateTime, AccountDataType.Order, current, providerId, route);
                        this.CopyFields(current3, accountData3.Fields);
                        list3.Add(accountData3);
                    }
                    list.Add(new AccountDataEntry(current, accountData, list2.ToArray(), list3.ToArray()));
                }
                result = new AccountDataSnapshot(list.ToArray());
            }
            return(result);
        }
Ejemplo n.º 4
0
		private AccountDataTable GetTable(byte providerId, byte route, bool addNew)
		{
			int key = (int)providerId * 256 + (int)route;
			AccountDataTable accountDataTable;
			lock (this.tables)
			{
				if (!this.tables.TryGetValue(key, out accountDataTable))
				{
					if (addNew)
					{
						accountDataTable = new AccountDataTable();
						this.tables.Add(key, accountDataTable);
					}
					else
					{
						accountDataTable = null;
					}
				}
			}
			return accountDataTable;
		}