/// <inheritdoc />
        public FtxWebsocketClient(IFtxCommunicator communicator)
        {
            FtxValidations.ValidateInput(communicator, nameof(communicator));

            _communicator = communicator;
            _messageReceivedSubscription = _communicator.MessageReceived.Subscribe(HandleMessage);

            JsonSerializer.SetDefaultResolver(StandardResolver.CamelCase);
        }
        public AuthenticationRequest(string apiKey, string apiSecret)
        {
            FtxValidations.ValidateInput(apiKey, nameof(apiKey));
            FtxValidations.ValidateInput(apiSecret, nameof(apiSecret));

            _apiKey = apiKey;

            _authNonce = FtxAuthentication.CreateAuthNonce();
            var authPayload = FtxAuthentication.CreateAuthPayload(_authNonce);

            _authSig = FtxAuthentication.CreateSignature(apiSecret, authPayload);
        }
        /// <summary>
        /// Serializes request and sends message via websocket communicator.
        /// It logs and re-throws every exception.
        /// </summary>
        /// <param name="request">Request/message to be sent</param>
        public void Send <T>(T request) where T : RequestBase
        {
            try
            {
                FtxValidations.ValidateInput(request, nameof(request));

                var serialized = FtxJsonSerializer.Serialize(request);
                _communicator.Send(serialized);
            }
            catch (Exception e)
            {
                Log.Error(e, L($"Exception while sending message '{request}'. Error: {e.Message}"));
                throw;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Subscribe to order book from selected pair ('BTC-PERP', etc)
        /// </summary>
        public TickerSubscribeRequest(string pair)
        {
            FtxValidations.ValidateInput(pair, nameof(pair));

            Market = pair;
        }