Beispiel #1
0
        private async Task RequestSubscribeForSymbol(string symbol, params ProtoOATrendbarPeriod[] periods)
        {
            await ValidateConnected();

            if (periods.Length == 0)
            {
                periods = new ProtoOATrendbarPeriod[] {
                    ProtoOATrendbarPeriod.M1 // TEMP TEST - For Spotware troubleshooting missing trendbars
                };
            }

            var subscribed = GetSubscribed(symbol);

            List <ProtoOATrendbarPeriod> list = new List <ProtoOATrendbarPeriod>(periods.Where(p => !subscribed.Contains(p)));

            // TODO: Verify previously subscribed trendbars stay subscribed.  Otherwise, eliminate the where clause above.

            var _msg = outgoingMsgFactory.CreateSubscribeForSpotsRequest(AccountId, AccessToken, symbol, clientMsgId, list);

            if (isDebugIsOn)
            {
                //#if LOG_SENTITIVE_INFO
#if TRACE_SUBSCRIPTIONS
                Debug.WriteLine("[tradeapi] SendSubscribeForSpotsRequest(): {0}", OpenApiMessagesPresentation.ToString(_msg));
#endif
                //#else
                //                Console.WriteLine("SendSubscribeForSpotsRequest(): {0}", OpenApiMessagesPresentation.ToString(_msg));
                //#endif
            }
            writeQueueSync.Enqueue(_msg.ToByteArray());
        }
Beispiel #2
0
        private void btnSubscribeForSpots_Click(object sender, EventArgs e)
        {
            var msgFactory = new OpenApiMessagesFactory();
            var msg        = msgFactory.CreateSubscribeForSpotsRequest(_accountID, 1);

            Transmit(msg);
        }
Beispiel #3
0
        void SendSubscribeForSpotsRequest(OpenApiMessagesFactory msgFactory, Queue writeQueue)
        {
            var _msg = msgFactory.CreateSubscribeForSpotsRequest(AccountId, AccessToken, "EURUSD", clientMsgId);

            if (isDebugIsOn)
            {
                Console.WriteLine("SendSubscribeForSpotsRequest() Message to be sent:\n{0}", OpenApiMessagesPresentation.ToString(_msg));
            }
            writeQueue.Enqueue(_msg.ToByteArray());
        }
        public void SendSubscribeForSpotsRequest(long testAccountId, String symbolName)
        {
            var _msg = outgoingMsgFactory.CreateSubscribeForSpotsRequest(testAccountId, authToken, symbolName, clientMsgId);

            if (isDebugIsOn)
            {
                Console.WriteLine("SendSubscribeForSpotsRequest() Message to be send:\n{0}", OpenApiMessagesPresentation.ToString(_msg));
            }
            writeQueue.Enqueue(Utils.Serialize(_msg));
        }
Beispiel #5
0
        protected void btnSubscribeForSpotsRequest_Click(object sender, EventArgs e)
        {
            SendAuthorizationRequest();
            var accountID  = ddlTradingAccounts.SelectedValue;
            var token      = Session["Token"].ToString();
            var msgFactory = new OpenApiMessagesFactory();
            var msg        = msgFactory.CreateSubscribeForSpotsRequest(Convert.ToInt32(accountID), token, "EURUSD");

            Transmit(msg);
            byte[] _message     = Listen(_apiSocket);
            var    protoMessage = msgFactory.GetMessage(_message);

            lblResponse.Text = OpenApiMessagesPresentation.ToString(protoMessage);
        }
        private void StartSubscribes(long ctraderAccountId)
        {
            //get the associated user config
            UserConfig config = Users.Where(x => x.Value.AccountId == ctraderAccountId).Select(x => x.Value).FirstOrDefault();

            if (config == null)
            {
                ErrorHandler?.Invoke("Could not find account " + ctraderAccountId + ". Ticks will not be recorded for this account.");
                return;
            }

            //start subscribing to the tick data
            var msgFactory = new OpenApiMessagesFactory();

            foreach (Symbol s in config.Symbols)
            {
                _trasmitQueue.Enqueue(msgFactory.CreateSubscribeForSpotsRequest(ctraderAccountId, s.Id));
            }

            StartWrites(config);
        }