private string  GetAuthMsg(ref bool bIsValid)
        {
            try
            {
                long   authNonce   = BitfinexAuthentication.CreateAuthNonce();
                string authPayload = BitfinexAuthentication.CreateAuthPayload(authNonce);
                string authSig     = BitfinexAuthentication.CreateSignature(authPayload, _apiSecret);

                RequestAuth reqAuth = new RequestAuth
                {
                    ApiKey      = _apiKey,
                    AuthNonce   = authNonce,
                    AuthSig     = authSig,
                    AuthPayload = authPayload
                };

                bIsValid = true;

                return(CBitfinexJsonSerializer.SerializeObject(reqAuth));
            }
            catch (Exception e)
            {
                Error("Unable gen AuthMsg");
                return("");
            }
        }
        public string GetSubscribeTrade(string instrument)
        {
            RequestSubsribeTrades reqTr = new RequestSubsribeTrades {
                Symbol = instrument
            };
            string msgTrade = CBitfinexJsonSerializer.SerializeObject(reqTr);

            return(msgTrade);
        }
        public void SendPing(int cid = 0)
        {
            RequestPing rp = new RequestPing {
                Cid = cid
            };
            string msg = CBitfinexJsonSerializer.SerializeObject(rp);

            SendMessage(msg);
        }
        /*
         * public void UpdateStock(long chanId, CBookParam newBookParam)
         * {
         *
         *  bool bNeedRemove = false;
         *  long keyRemove = 0;
         *
         *  //if channel changed (for example after disconnect)
         *  //need to remove old channel first
         *  foreach (var kvp in _dictBookChanidInstr)
         *  {
         *      if (kvp.Value.Instrument == newBookParam.Instrument)
         *      {
         *          bNeedRemove = true;
         *          keyRemove = kvp.Key;
         *      }
         *  }
         *  if (bNeedRemove)
         *      _dictBookChanidInstr.Remove(keyRemove);
         *
         *
         *  _dictBookChanidInstr[chanId] = newBookParam;
         *
         *
         * }
         */



        public string GetSubscribeBook(string instrument, int precisionLevel)
        {
            // int precisionLevel = 1;
            RequestSubscribeBook reqBook = new RequestSubscribeBook {
                Prec   = String.Format("P{0}", precisionLevel),
                Symbol = instrument,
                Len    = precisionLevel == 0 ? "25": "100"
                         // Len = "100"
            };
            string msgBook = CBitfinexJsonSerializer.SerializeObject(reqBook);

            return(msgBook);
        }