Exemple #1
0
        private void ProcessUserUpdatePosLog(byte[] arrMsgBody)
        {
            CUserPosLogUpdate userPosLogUpdate = CUtilProto.DeserializeProto <CUserPosLogUpdate>(arrMsgBody);

            Log("[UserUpdatePosLog]");


            _childWinDataUpdater.Update(userPosLogUpdate, _connId);
        }
        public void EnqueueUpdateUserPosLog(int botID)
        {
            if (!IsNeedSenUserPosLog(botID))
            {
                return;
            }



            var res = _dictBotIdConnId.FirstOrDefault(a => a.Key == botID);

            if (res.Key == 0)
            {
                return;               //not found
            }
            int connId = res.Value;



            // CUserPosMonitorUpdate upos = new CUserPosMonitorUpdate();

            CUserPosLogUpdate poslog = new CUserPosLogUpdate();

            poslog.DictLog = new Dictionary <string, List <CUserPosLog> >();

            //for trader terminals send all deals
            lock (_client.UserDealsPosBox.DicBotPosLog)
            {
                var dictBotPosLog = _client.UserDealsPosBox.DicBotPosLog[botID];

                foreach (var kvp in dictBotPosLog)
                {
                    poslog.DictLog[kvp.Key] = new List <CUserPosLog>();
                    string instrument = kvp.Key;
                    //userDeal.Decimals = _client.Instruments.GetDecimals(instrument);
                    int decimals      = _client.Instruments.GetDecimals(instrument);
                    int decimalVolume = _client.Instruments.GetDecimalVolume(instrument);

                    foreach (var v in kvp.Value)
                    {
                        poslog.DictLog[kvp.Key].Add
                            (new CUserPosLog
                        {
                            PriceOpen       = v.PriceOpen,
                            PriceClose      = v.PriceClose,
                            BuySell         = v.BuySell,
                            DtOpen          = v.DtOpen,
                            DtClose         = v.DtClose,
                            CloseAmount     = v.CloseAmount,
                            VMClosed_Points = v.VMClosed_Points,
                            VMClosed_RUB    = v.VMClosed_RUB,
                            Fee             = v.Fee,
                            PriceOpenSt     = v.PriceOpen.ToString("N0" + decimals),//TODO put to client side
                            PriceCloseSt    = v.PriceClose.ToString("N0" + decimals),
                            CloseAmountSt   = v.CloseAmount.ToString("N0" + decimalVolume)
                        });
                    }
                }
            }



            _bqTraderData.Add(new CTradingData
            {
                ConnId = connId,
                Data   = (object)poslog,
                Event  = enmTradingEvent.UserUpdatePosLog
            }
                              );
        }
 private void SendUpdateUserPosLog(int connId, CUserPosLogUpdate userPosLogUpdate)
 {
     SendDataToClients(userPosLogUpdate, enmTradingEvent.UserUpdatePosLog, "", connId);
 }