private void SendRequestForOpenOrders(IWebSocketClientConnection connection, int page = 0) { JObject orders_list_request = new JObject(); orders_list_request["MsgType"] = "U4"; orders_list_request["OrdersReqID"] = connection.NextOutgoingSeqNum(); orders_list_request["Page"] = page; orders_list_request["PageSize"] = 20; orders_list_request["Filter"] = new JArray("has_leaves_qty eq 1" /*"has_cum_qty eq 1"*/); connection.SendMessage(orders_list_request.ToString()); }
public void SendTestRequest(IWebSocketClientConnection connection) { JObject test_request = new JObject(); test_request["MsgType"] = "1"; test_request["FingerPrint"] = connection.Device.FingerPrint; test_request["STUNTIP"] = connection.Device.Stuntip; test_request["TestReqID"] = connection.NextOutgoingSeqNum().ToString(); test_request["SendTime"] = Util.ConvertToUnixTimestamp(DateTime.Now).ToString(); string test_request_msg = test_request.ToString(); connection.SendMessage(test_request_msg); }
public void OnOpen(IWebSocketClientConnection connection) { Debug.Assert(connection.IsConnected); Debug.Assert(!connection.IsLoggedOn); OnLogEvent(LogStatusType.INFO, "Connection Succeeded"); _connections.Add(connection); // dispatch the connection opened DispatchEvent(SystemEventType.OPENED, connection); // build the json Login Request Message JObject login_request = new JObject(); login_request["MsgType"] = "BE"; login_request["UserReqID"] = connection.NextOutgoingSeqNum(); login_request["UserReqTyp"] = "1"; login_request["Username"] = connection.UserAccount.Username; login_request["Password"] = connection.UserAccount.Password; login_request["BrokerID"] = connection.UserAccount.BrokerId; login_request["CancelOnDisconnect"] = "1"; // enabled so that all session orders are automatically cancelled upon a disconnection (should work in next backend version) if (connection.UserAccount.SecondFactor != null && connection.UserAccount.SecondFactor != string.Empty) { login_request["SecondFactor"] = connection.UserAccount.SecondFactor; } login_request["UserAgent"] = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.76 Mobile Safari/537.36"; login_request["UserAgentLanguage"] = "en-US"; login_request["UserAgentTimezoneOffset"] = ":180,"; login_request["UserAgentPlatform"] = "Linux x86_64"; login_request["FingerPrint"] = connection.Device.FingerPrint; login_request["STUNTIP"] = connection.Device.Stuntip; // send the login request Message on wire connection.SendMessage(login_request.ToString()); }
private void StartInitialRequestsAfterLogon(IWebSocketClientConnection connection) { // 1. cancel all user orders SendRequestToCancelAllOrders(connection); // not necessary if cancel on disconnect is active // 2. send the balance request JObject balance_request = new JObject(); balance_request["MsgType"] = "U2"; balance_request["BalanceReqID"] = connection.NextOutgoingSeqNum(); balance_request["FingerPrint"] = connection.Device.FingerPrint; balance_request["STUNTIP"] = connection.Device.Stuntip; connection.SendMessage(balance_request.ToString()); // 3. send market data request JObject marketdata_request = new JObject(); marketdata_request["MsgType"] = "V"; marketdata_request["MDReqID"] = connection.NextOutgoingSeqNum(); marketdata_request["SubscriptionRequestType"] = "1"; marketdata_request["MarketDepth"] = 0; marketdata_request["MDUpdateType"] = "1"; marketdata_request["MDEntryTypes"] = new JArray("0", "1", "2"); // bid, offer, trade marketdata_request["Instruments"] = new JArray(_tradingSymbol); marketdata_request["FingerPrint"] = connection.Device.FingerPrint; marketdata_request["STUNTIP"] = connection.Device.Stuntip; connection.SendMessage(marketdata_request.ToString()); // 4. send security status request JObject securitystatus_request = new JObject(); securitystatus_request["MsgType"] = "e"; securitystatus_request["SecurityStatusReqID"] = connection.NextOutgoingSeqNum(); securitystatus_request["SubscriptionRequestType"] = "1"; JArray instruments = new JArray(); instruments.Add("BLINK:BTCBRL"); instruments.Add("BLINK:BTCUSD"); instruments.Add("BLINK:BTCVND"); instruments.Add("BLINK:BTCVEF"); instruments.Add("BLINK:BTCPKR"); instruments.Add("BLINK:BTCCLP"); instruments.Add("BITSTAMP:BTCUSD"); instruments.Add("ITBIT:BTCUSD"); instruments.Add("BITFINEX:BTCUSD"); instruments.Add("BTRADE:BTCUSD"); instruments.Add("MBT:BTCBRL"); instruments.Add("KRAKEN:BTCEUR"); instruments.Add("COINFLOOR:BTCGBP"); instruments.Add("UOL:USDBRL"); instruments.Add("UOL:USDBRT"); instruments.Add("OKCOIN:BTCCNY"); securitystatus_request["Instruments"] = instruments; securitystatus_request["FingerPrint"] = connection.Device.FingerPrint; securitystatus_request["STUNTIP"] = connection.Device.Stuntip; connection.SendMessage(securitystatus_request.ToString()); // 5. send the trade history request JObject trades_request = new JObject(); trades_request["MsgType"] = "U32"; trades_request["TradeHistoryReqID"] = connection.NextOutgoingSeqNum(); //trades_request["Filter"] = new JArray("Symbol eq 'BTCBRL'"); // not working //trades_request["SymbolList"] = new JArray("BTCBRL"); // not working trades_request["FingerPrint"] = connection.Device.FingerPrint; trades_request["STUNTIP"] = connection.Device.Stuntip; connection.SendMessage(trades_request.ToString()); // 6. send request for all "open" orders SendRequestForOpenOrders(connection); }