Ejemplo n.º 1
0
        private void AddOrder(SmartQuant.AccountData data)
        {
            Dictionary <string, ListViewItem> dictionary = this.orders[data.Account];
            string       key          = new OrderKey(data).ToString();
            ListViewItem listViewItem = (ListViewItem)null;

            if (!dictionary.TryGetValue(key, out listViewItem))
            {
                listViewItem                  = new ListViewItem(new string[8]);
                listViewItem.Name             = key;
                listViewItem.SubItems[0].Text = key;
                dictionary.Add(key, listViewItem);
            }
            this.UpdateSubItem(listViewItem, 1, data, "Symbol");
            this.UpdateSubItem(listViewItem, 2, data, "OrderSide");
            this.UpdateSubItem(listViewItem, 3, data, "OrderType");
            this.UpdateSubItem(listViewItem, 4, data, "Qty");
            this.UpdateSubItem(listViewItem, 5, data, "Price");
            this.UpdateSubItem(listViewItem, 6, data, "StopPx");
            this.UpdateSubItem(listViewItem, 7, data, "OrderStatus");
            if (!(data.Account == this.cbxAccount.SelectedItem as string))
            {
                return;
            }
            this.UpdateListView(data.Account, AccountDataViewer.ListType.Orders);
        }
Ejemplo n.º 2
0
        public void OnData(SmartQuant.AccountData data)
        {
            if (!this.cbxAccount.Items.Contains((object)data.Account))
            {
                this.cbxAccount.Items.Add((object)data.Account);
                this.accounts.Add(data.Account, new Dictionary <string, ListViewItem>());
                this.positions.Add(data.Account, new Dictionary <string, ListViewItem>());
                this.orders.Add(data.Account, new Dictionary <string, ListViewItem>());
                if (this.cbxAccount.SelectedIndex < 0)
                {
                    this.cbxAccount.SelectedIndex = 0;
                }
            }
            switch (data.Type)
            {
            case AccountDataType.AccountValue:
                this.AddValue(data);
                break;

            case AccountDataType.Position:
                this.AddPosition(data);
                break;

            case AccountDataType.Order:
                this.AddOrder(data);
                break;
            }
        }
Ejemplo n.º 3
0
		internal AccountDataEntry(string account, AccountData values, AccountData[] positions, AccountData[] orders)
		{
			this.Account = account;
			this.Values = values;
			this.Positions = positions;
			this.Orders = orders;
		}
Ejemplo n.º 4
0
		private string GetValue(AccountData data, string fieldName)
		{
			object obj = data.Fields[fieldName];
			if (obj != null)
			{
				return obj.ToString();
			}
			return string.Empty;
		}
Ejemplo n.º 5
0
        private void UpdateSubItem(ListViewItem item, int index, SmartQuant.AccountData data, string name)
        {
            object obj = data.Fields[name];

            if (obj == null)
            {
                return;
            }
            item.SubItems[index].Text = obj.ToString();
        }
Ejemplo n.º 6
0
		public AccountDataKey(AccountData data, params string[] fieldNames)
		{
			List<string> list = new List<string>();
			for (int i = 0; i < fieldNames.Length; i++)
			{
				string fieldName = fieldNames[i];
				list.Add(this.GetValue(data, fieldName));
			}
			this.key = string.Join("\u0001", list);
		}
Ejemplo n.º 7
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.º 8
0
        private void AddPosition(SmartQuant.AccountData data)
        {
            Dictionary <string, ListViewItem> dictionary = this.positions[data.Account];
            string       key          = new PositionKey(data).ToString();
            ListViewItem listViewItem = (ListViewItem)null;

            if (!dictionary.TryGetValue(key, out listViewItem))
            {
                listViewItem                  = new ListViewItem(new string[4]);
                listViewItem.Name             = key;
                listViewItem.SubItems[0].Text = key;
                dictionary.Add(key, listViewItem);
            }
            this.UpdateSubItem(listViewItem, 1, data, "Qty");
            this.UpdateSubItem(listViewItem, 2, data, "LongQty");
            this.UpdateSubItem(listViewItem, 3, data, "ShortQty");
            if (!(data.Account == this.cbxAccount.SelectedItem as string))
            {
                return;
            }
            this.UpdateListView(data.Account, AccountDataViewer.ListType.Positions);
        }
Ejemplo n.º 9
0
        private void AddValue(SmartQuant.AccountData data)
        {
            Dictionary <string, ListViewItem> dictionary = this.accounts[data.Account];

            foreach (AccountDataField accountDataField in data.Fields)
            {
                string       key          = string.Format("{0}:{1}", (object)accountDataField.Name, (object)accountDataField.Currency);
                ListViewItem listViewItem = (ListViewItem)null;
                if (!dictionary.TryGetValue(key, out listViewItem))
                {
                    listViewItem                  = new ListViewItem(new string[3]);
                    listViewItem.Name             = key;
                    listViewItem.SubItems[0].Text = accountDataField.Name;
                    listViewItem.SubItems[1].Text = accountDataField.Currency;
                    dictionary.Add(key, listViewItem);
                }
                listViewItem.SubItems[2].Text = this.ValueToString(accountDataField.Value);
            }
            if (!(data.Account == this.cbxAccount.SelectedItem as string))
            {
                return;
            }
            this.UpdateListView(data.Account, AccountDataViewer.ListType.Accounts);
        }
Ejemplo n.º 10
0
 public OrderKey(SmartQuant.AccountData data) : base(data)
 {
     this.key = GetFieldAsString("OrderID");
 }
Ejemplo n.º 11
0
 public PositionKey(SmartQuant.AccountData data) : base(data)
 {
     this.key = $"{GetFieldAsString("Symbol")} {GetFieldAsString("Maturity")} {GetFieldAsString("PutOrCall")} {GetFieldAsString("Strike")}";
 }
Ejemplo n.º 12
0
		public AccountDataEventArgs(AccountData data)
		{
			this.Data = data;
		}
Ejemplo n.º 13
0
 public AccountDataEventArgs(AccountData data)
 {
     this.Data = data;
 }
Ejemplo n.º 14
0
 protected internal void EmitAccountData(AccountData data)
 {
     this.executionQueue.Enqueue(data);
 }
Ejemplo n.º 15
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;
		}