Beispiel #1
0
        private void btnClosePosition_Click(object sender, EventArgs e)
        {
            var msgFactory = new OpenApiMessagesFactory();
            var msg        = msgFactory.CreateClosePositionRequest(Convert.ToInt32(_accountID), _token, Convert.ToInt64(txtPositionID.Text), Convert.ToInt64(txtVolume.Text));

            Transmit(msg);
        }
        public void CloseTrade(UserConfig config, long positionId, long size, string clientMsgId)
        {
            var          msgFactory = new OpenApiMessagesFactory();
            ProtoMessage _msg       = msgFactory.CreateClosePositionRequest(config.AccountId, config.Token, positionId, size, clientMsgId);

            //create the trade request message and queue it
            _trasmitQueue.Enqueue(_msg);
        }
Beispiel #3
0
        void SendClosePositionRequest(OpenApiMessagesFactory msgFactory, Queue writeQueue)
        {
            var _msg = msgFactory.CreateClosePositionRequest(AccountId, AccessToken, positionId, testVolume, clientMsgId);

            if (isDebugIsOn)
            {
                Console.WriteLine("SendClosePositionRequest() Message to be sent:\n{0}", OpenApiMessagesPresentation.ToString(_msg));
            }
            writeQueue.Enqueue(_msg.ToByteArray());
        }
        private void SendClosePositionRequest(long testAccountId)
        {
            var _msg = outgoingMsgFactory.CreateClosePositionRequest(testAccountId, authToken, testPositionId, testVolume, clientMsgId);

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

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

            lblResponse.Text = OpenApiMessagesPresentation.ToString(protoMessage);
        }
Beispiel #6
0
        public JsonResult SendClosePosition([FromBody] Params param)
        {
            _tcpClient = new TcpClient(param.ApiHost, param.ApiPort);;
            _apiSocket = new SslStream(_tcpClient.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null);
            _apiSocket.AuthenticateAsClient(param.ApiHost);
            SendAuthorizationRequest(param);
            List <string> data = new List <string>();

            var msgFactory = new OpenApiMessagesFactory();

            if (!string.IsNullOrEmpty(param.SelectedType))
            {
                foreach (var p in param.SelectedPositions)
                {
                    var msg = msgFactory.CreateClosePositionRequest(param.AccountId, param.AccessToken, p.PositionId, p.Volume);
                    Transmit(msg);
                }
            }
            byte[] _message     = Listen(_apiSocket);
            var    protoMessage = msgFactory.GetMessage(_message);

            data.Add(OpenApiMessagesPresentation.ToString(protoMessage));
            return(Json(new { data }));
        }