예제 #1
0
        /// <summary>
        /// connect to Oanda server
        /// установить соединение сервером Oanda
        /// </summary>
        public void Connect(string id, string token, bool isJuniorConnect)
        {
            if (isJuniorConnect)
            {
                _environment = EEnvironment.Practice;
            }
            else
            {
                _environment = EEnvironment.Trade;
            }

            if (string.IsNullOrEmpty(token))
            {
                SendLogMessage(OsLocalization.Market.Message77 + " https://www.oanda.com/account/tpa/personal_token", LogMessageType.Error);
                return;
            }

            Credentials.SetCredentials(_environment, token, id);

            if (Credentials.GetDefaultCredentials().HasServer(EServer.Account))
            {
                _isConnected = true;

                if (ConnectionSucsess != null)
                {
                    ConnectionSucsess();
                }

                _transactionsSession = new TransactionsSession(Credentials.GetDefaultCredentials().DefaultAccountId);
                _transactionsSession.DataReceived += _transactionsSession_DataReceived;
                _transactionsSession.StartSession();
            }
        }
예제 #2
0
        public void StartStreamThreads()
        {
            if (_pricingStream != null)
            {
                _pricingStream.StopSession();
                _pricingStream = null;

                _transactionsSession.StopSession();
                _transactionsSession = null;
            }

            _pricingStream = new PricingSession(Credentials.GetDefaultCredentials().DefaultAccountId, _allInstruments);
            _pricingStream.DataReceived += _marketDepthStream_DataReceived;
            _pricingStream.StartSession();

            _transactionsSession = new TransactionsSession(Credentials.GetDefaultCredentials().DefaultAccountId);
            _transactionsSession.DataReceived += _transactionsSession_DataReceived;
            _transactionsSession.StartSession();
        }
예제 #3
0
        static void StartTransactionsStream()
        {
            WriteNewLine("Starting transactions stream ...");

            _transactionsSession = new TransactionsSession(AccountID);
            _transactionReceived = new Semaphore(0, 100);
            _transactionsSession.DataReceived += OnTransactionReceived;

            _transactionsSession.StartSession();

            bool success = _transactionReceived.WaitOne(10000);

            if (success)
            {
                WriteNewLine("Good news!. Transactions stream is functioning.");
            }
            else
            {
                WriteNewLine("Bad news!. Transactions stream is not functioning.");
            }
        }