예제 #1
0
        public BitmexDataService(TradinServer tradingServer, DataBase data_base)
        {
            if (tradingServer == TradinServer.Real)
            {
                WebSocket = new WebSocketWrapper("wss://www.bitmex.com/realtime");
                Api       = new BitMEXApi(Settings.bitmexApiKey, Settings.bitmexApiSecret, true);           // false - demo, true - real account
            }
            else
            {
                WebSocket = new WebSocketWrapper("wss://testnet.bitmex.com/realtime");
                Api       = new BitMEXApi(Settings.bitmexDemoApiKey, Settings.bitmexDemoApiSecret, false);
            }

            dataBase = data_base;             // Data base methods are gonna be called in TradeBitmex etc.

            Instruments      = Api.GetActiveInstruments().OrderByDescending(a => a.Volume24H).ToList().AsReadOnly();
            ActiveInstrument = Instruments[0];

            WebSocket.Connect();

            // Authenticate websocket API
            var apiExpires = Api.GetExpiresArg();

            if (tradingServer == TradinServer.Real)
            {
                var signature = Api.GetWebSocketSignatureString(Settings.bitmexApiSecret, apiExpires);
                WebSocket.Send($@"{{""op"": ""authKeyExpires"", ""args"": [""{Settings.bitmexApiKey}"", {apiExpires}, ""{signature}""]}}");
            }
            else
            {
                var signature = Api.GetWebSocketSignatureString(Settings.bitmexDemoApiSecret, apiExpires);
                WebSocket.Send($@"{{""op"": ""authKeyExpires"", ""args"": [""{Settings.bitmexDemoApiKey}"", {apiExpires}, ""{signature}""]}}");
            }
        }
예제 #2
0
        public HitBtcDataService(TradinServer tradingServer)
        {
            if (tradingServer == TradinServer.Real)
            {
                WebSocket = new WebSocketWrapper("wss://api.hitbtc.com/api/2/ws");
            }
            else
            {
                // There is no DEMO at HitBtc
            }

            WebSocket.Connect();

            if (tradingServer == TradinServer.Real)
            {
                // Auth
                WebSocket.Send("{\"method\": \"login\",\"params\": {\"algo\": \"BASIC\",\"pKey\": \"" + Settings.pKey + "\",\"sKey\": \"" + Settings.sKey + "\"}}");
            }
            else
            {
                // There is no DEMO at HitBtc
            }
        }