public AlfaWrapper(AlfaDirectMessageAdapter adapter) { if (adapter == null) { throw new ArgumentNullException("adapter"); } _adapter = adapter; _sysCulture = ThreadingHelper.GetSystemCulture(); _adapter.AddInfoLog(LocalizedStrings.Str2270Params, _sysCulture); _ad = new AlfaDirectClass(); _ad.OnConnectionChanged += OnConnectionChanged; _ad.OnTableChanged += OnTableChanged; _ad.OrderConfirmed += OrderConfirmed; _tableSecurities = new AlfaTable(_ad, _adapter, AlfaTable.TableName.papers, "paper_no, p_code, ansi_name, place_code, at_code, lot_size, i_last_update, expired, mat_date, price_step, base_paper_no, go_buy, go_sell, price_step_cost, curr_code, strike"); _tableDepth = new AlfaTable(_ad, _adapter, AlfaTable.TableName.queue, "paper_no, sell_qty, price, buy_qty"); _tableLevel1 = new AlfaTable(_ad, _adapter, AlfaTable.TableName.fin_info, "paper_no, status, go_buy, go_sell, open_pos_qty, open_price, close_price, sell, sell_qty, buy, buy_qty, min_deal, max_deal, lot_size, volatility, theor_price, last_price, last_qty, last_update_date, last_update_time, price_step, buy_sqty, sell_sqty, buy_count, sell_count", "trading_status"); _tableTrades = new AlfaTable(_ad, _adapter, AlfaTable.TableName.all_trades, "paper_no, trd_no, qty, price, ts_time, b_s", "b_s_num"); _tableOrders = new AlfaTable(_ad, _adapter, AlfaTable.TableName.orders, "ord_no, acc_code, paper_no, status, b_s, price, qty, rest, ts_time, comments, place_code, stop_price, avg_trd_price, blank, updt_grow_price, updt_down_price, updt_new_price, trailing_level, trailing_slippage", "order_status, b_s_str"); _tablePositions = new AlfaTable(_ad, _adapter, AlfaTable.TableName.balance, "acc_code, p_code, place_code, paper_no, income_rest, real_rest, forword_rest, pl, profit_vol, income_vol, real_vol, open_vol, var_margin, balance_price"); _tableMyTrades = new AlfaTable(_ad, _adapter, AlfaTable.TableName.trades, "trd_no, ord_no, treaty, paper_no, price, qty, b_s, ts_time", "b_s_str"); _tableNews = new AlfaTable(_ad, _adapter, AlfaTable.TableName.news, "new_no, provider, db_data, subject, body"); _tableAccounts = new AlfaTable(_ad, _adapter, AlfaTable.TableName.accounts, "treaty"); _connState = IsConnected ? ConnectionStates.Connected : ConnectionStates.Disconnected; _adapter.AddInfoLog("AlfaDirect {0}", _ad.Version.ToString()); }
public FieldList(AlfaTable table, ILogReceiver logReceiver, string fields, string uniqueIds = null) { Table = table; _logReceiver = logReceiver; Names = fields.Split(",").Select(f => f.Trim()).Where(f => !f.IsEmpty()).ToArray(); var ids = uniqueIds == null?Enumerable.Empty <string>() : uniqueIds.Split(",").Select(f => f.Trim()).Where(f => !f.IsEmpty()); var checkIds = new HashSet <string>(); var allFields = new Dictionary <string, List <Field> >(); foreach (var info in _definedFields) { var field = (Field)info.GetValue(this); if (checkIds.Contains(field.Id)) { throw new InvalidOperationException("non unique id: {0}".Put(field.Id)); } checkIds.Add(field.Id); var list = allFields.TryGetValue(field.Name); if (list == null) { allFields.Add(field.Name, list = new List <Field>()); } list.Add(field); } for (var i = 0; i < Names.Length; ++i) { var list = allFields[Names[i]]; var field = list.Count == 1 ? list.First() : list.First(f => ids.Contains(f.Id)); field.Init(this, i); } allFields.Values.SelectMany(l => l).Where(f => f.List == null).ForEach(f => f.Init(this)); }