0

There is a websocket application made in c # of ftx stock exchange. It works fine on Console, but with WindowsForms, I can't transfer data onto textbox.

Is there a way to do this?

https://github.com/ftexchange/FtxApi

johnvayne
  • 79
  • 3
  • 8
  • 2
    Welcome to Stackoverflow, please put the relevant code snippet into your question as it relates to your attempt to get it to work. – Brett Caswell Jan 30 '20 at 09:26
  • 1
    also, this referenced console\client codebase references to SuperSocket namespace and types (as well as WebSocket4Net) as a dependency packages. It does not reference to websocket-sharp. Please update your tags as it relates to the technologies you're using. Ensure you provide code showing that usage. – Brett Caswell Jan 30 '20 at 09:38

2 Answers2

0

The code below receives data via websocket. But I can't import it into textBox in form1

In short, it needs to be integrated on the form. I don't want with console

namespace FtxApi_Test
{
    class Program
    {
        static void Main()
        {
            var client = new Client("_T68V7HmuHoiHlKmpUcOcbNOXkNWpzL-FvpO1VMa", "TsmQWQ4bXrOHzCVbD7vFzZtI-gs7j8tvh684hPY6");
            var api = new FtxRestApi(client);
            var wsApi = new FtxWebSocketApi("wss://ftx.com/ws/");

            WebSocketTests(wsApi, client).Wait();

            Console.ReadLine();
        }

        private static async Task WebSocketTests(FtxWebSocketApi wsApi, Client client)
        {
            var ins = "BTC-PERP";

            wsApi.OnWebSocketConnect += () =>
            {
                wsApi.SendCommand(FtxWebSockerRequestGenerator.GetAuthRequest(client));
                wsApi.SendCommand(FtxWebSockerRequestGenerator.GetSubscribeRequest("orderbook", ins));
                wsApi.SendCommand(FtxWebSockerRequestGenerator.GetSubscribeRequest("trades", ins));
                wsApi.SendCommand(FtxWebSockerRequestGenerator.GetSubscribeRequest("ticker", ins));
                wsApi.SendCommand(FtxWebSockerRequestGenerator.GetSubscribeRequest("fills"));
                wsApi.SendCommand(FtxWebSockerRequestGenerator.GetSubscribeRequest("orders"));
            };

            await wsApi.Connect();
        }
    }
}
johnvayne
  • 79
  • 3
  • 8
0

Declare

private static async **void** WebSocketTests(FtxWebSocketApi wsApi, Client client)

instead of

private static async **Task** WebSocketTests(FtxWebSocketApi wsApi, Client client)
Nadeem Taj
  • 1
  • 4
  • 21