Пример #1
0
        private void OnMargin(MarginLevel ml)
        {
            var h = Margin;

            if (h != null)
            {
                EventHandler.RiseSafely(() => h(ml));
            }
        }
Пример #2
0
 void IMT4ServerConnectorHost.OnMargin(eMT4ServerType serverIndex, MarginLevel ptrLevel)
 {
     try
     {
         OnMarginAsync(serverIndex, ptrLevel, CancellationToken.None).Wait();
     }
     catch (Exception exception)
     {
         m_ptrLogger.LogException(exception);
     }
 }
Пример #3
0
        public void Proper_Margin_Have_Been_Received_And_Rised()
        {
            MarginLevel sentML     = new MarginLevel();
            MarginLevel receivedML = null;

            var client = new APIClient(moq_connection.Object);

            client.Margin += (ml => receivedML = ml);

            moq_connection.Raise(con => con.PacketReceived += null, new MarginLevelPacket()
            {
                MarginLevel = sentML
            });

            Assert.Equal(sentML, receivedML);
        }
Пример #4
0
        /// <summary>
        /// WitFXMT4ServerBL.onMarginLevelResponse
        /// </summary>
        private async Task OnMarginAsync(eMT4ServerType serverIndex, MarginLevel ptrMargin, CancellationToken cancellationToken)
        {
            int masterLogin = await _mt4AccountService.GetCachedMasterLoginAsync(serverIndex, ptrMargin.login, cancellationToken);

            if (masterLogin > 0)
            {
                var ptr = new MT4MarginResponse(); // MT_MT4MarginResponse_ID
                ptr._marginInfo                 = new MT4AccountStatus();
                ptr._marginInfo._balance        = ptrMargin.balance;
                ptr._marginInfo._equity         = ptrMargin.equity;
                ptr._marginInfo._freeMargin     = ptrMargin.margin_free;
                ptr._marginInfo._margin         = ptrMargin.margin;
                ptr._marginInfo._marginLevel    = ptrMargin.margin_level;
                ptr._marginInfo._mt4ServerIndex = serverIndex;
                ptr._marginInfo._mt4Login       = ptrMargin.login;
                _connectionMgr.SentDataUsingLoginID(ptr, MessageTypeID.MT_MT4MarginResponse_ID, masterLogin);
            }
        }