예제 #1
0
 /// <summary>
 /// This is the taker volume for both buyers and sellers. This shows the influx and exit of funds in and out of {coin}.
 /// </summary>
 /// <param name="currency">Currency</param>
 /// <param name="instrumentType">Instrument Type</param>
 /// <param name="period">period, the default is 5m, e.g. [5m/1H/1D]</param>
 /// <param name="begin">begin, e.g. 1597026383085</param>
 /// <param name="end">end, e.g. 1597026383011</param>
 /// <param name="ct">Cancellation Token</param>
 /// <returns></returns>
 public virtual WebCallResult <IEnumerable <OkexTakerVolume> > GetRubikTakerVolume(
     string currency,
     OkexInstrumentType instrumentType,
     OkexPeriod period    = OkexPeriod.FiveMinutes,
     long?begin           = null,
     long?end             = null,
     CancellationToken ct = default) => GetRubikTakerVolume_Async(currency, instrumentType, period, begin, end, ct).Result;
예제 #2
0
        /// <summary>
        /// This is the taker volume for both buyers and sellers. This shows the influx and exit of funds in and out of {coin}.
        /// </summary>
        /// <param name="currency">Currency</param>
        /// <param name="instrumentType">Instrument Type</param>
        /// <param name="period">period, the default is 5m, e.g. [5m/1H/1D]</param>
        /// <param name="begin">begin, e.g. 1597026383085</param>
        /// <param name="end">end, e.g. 1597026383011</param>
        /// <param name="ct">Cancellation Token</param>
        /// <returns></returns>
        public virtual async Task <WebCallResult <IEnumerable <OkexTakerVolume> > > GetRubikTakerVolume_Async(
            string currency,
            OkexInstrumentType instrumentType,
            OkexPeriod period    = OkexPeriod.FiveMinutes,
            long?begin           = null,
            long?end             = null,
            CancellationToken ct = default)
        {
            var parameters = new Dictionary <string, object> {
                { "ccy", currency },
                { "instType", JsonConvert.SerializeObject(instrumentType, new InstrumentTypeConverter(false)) },
                { "period", JsonConvert.SerializeObject(period, new PeriodConverter(false)) },
            };

            parameters.AddOptionalParameter("begin", begin?.ToString(OkexGlobals.OkexCultureInfo));
            parameters.AddOptionalParameter("end", end?.ToString(OkexGlobals.OkexCultureInfo));

            var result = await SendRequestAsync <OkexRestApiResponse <IEnumerable <OkexTakerVolume> > >(GetUrl(Endpoints_V5_RubikStat_TakerVolume), HttpMethod.Get, ct, parameters).ConfigureAwait(false);

            if (!result.Success)
            {
                return(WebCallResult <IEnumerable <OkexTakerVolume> > .CreateErrorResult(result.ResponseStatusCode, result.ResponseHeaders, result.Error));
            }
            if (result.Data.ErrorCode > 0)
            {
                return(WebCallResult <IEnumerable <OkexTakerVolume> > .CreateErrorResult(result.ResponseStatusCode, result.ResponseHeaders, new ServerError(result.Data.ErrorCode, result.Data.ErrorMessage, result.Data.Data)));
            }

            return(new WebCallResult <IEnumerable <OkexTakerVolume> >(result.ResponseStatusCode, result.ResponseHeaders, result.Data.Data, null));
        }
예제 #3
0
        /// <summary>
        /// This shows what option strikes are the most popular for each expiration.
        /// </summary>
        /// <param name="currency">Currency</param>
        /// <param name="expiryTime">expiry time (Format: YYYYMMdd, for example: "20210623")</param>
        /// <param name="period">period, the default is 8H. e.g. [8H/1D]</param>
        /// <param name="ct">Cancellation Token</param>
        /// <returns></returns>
        public virtual async Task <WebCallResult <IEnumerable <OkexInterestVolumeStrike> > > GetRubikInterestVolumeStrike_Async(
            string currency,
            string expiryTime,
            OkexPeriod period    = OkexPeriod.FiveMinutes,
            CancellationToken ct = default)
        {
            var parameters = new Dictionary <string, object> {
                { "ccy", currency },
                { "expTime", expiryTime },
                { "period", JsonConvert.SerializeObject(period, new PeriodConverter(false)) },
            };

            var result = await SendRequestAsync <OkexRestApiResponse <IEnumerable <OkexInterestVolumeStrike> > >(GetUrl(Endpoints_V5_RubikStat_OptionOpenInterestVolumeStrike), HttpMethod.Get, ct, parameters).ConfigureAwait(false);

            if (!result.Success)
            {
                return(WebCallResult <IEnumerable <OkexInterestVolumeStrike> > .CreateErrorResult(result.ResponseStatusCode, result.ResponseHeaders, result.Error));
            }
            if (result.Data.ErrorCode > 0)
            {
                return(WebCallResult <IEnumerable <OkexInterestVolumeStrike> > .CreateErrorResult(result.ResponseStatusCode, result.ResponseHeaders, new ServerError(result.Data.ErrorCode, result.Data.ErrorMessage, result.Data.Data)));
            }

            return(new WebCallResult <IEnumerable <OkexInterestVolumeStrike> >(result.ResponseStatusCode, result.ResponseHeaders, result.Data.Data, null));
        }
예제 #4
0
 /// <summary>
 /// This shows the relative buy/sell volume for calls and puts. It shows whether traders are bullish or bearish on price and volatility.
 /// </summary>
 /// <param name="currency">Currency</param>
 /// <param name="period">period, the default is 8H. e.g. [8H/1D]</param>
 /// <param name="ct">Cancellation Token</param>
 /// <returns></returns>
 public virtual WebCallResult <OkexTakerFlow> GetRubikTakerFlow(
     string currency,
     OkexPeriod period    = OkexPeriod.FiveMinutes,
     CancellationToken ct = default) => GetRubikTakerFlow_Async(currency, period, ct).Result;
예제 #5
0
 /// <summary>
 /// This shows the relative buy/sell volume for calls and puts. It shows whether traders are bullish or bearish on price and volatility.
 /// </summary>
 /// <param name="currency">Currency</param>
 /// <param name="period">period, the default is 8H. e.g. [8H/1D]</param>
 /// <param name="ct">Cancellation Token</param>
 /// <returns></returns>
 public virtual WebCallResult <IEnumerable <OkexPutCallRatio> > GetRubikPutCallRatio(
     string currency,
     OkexPeriod period    = OkexPeriod.FiveMinutes,
     CancellationToken ct = default) => GetRubikPutCallRatio_Async(currency, period, ct).Result;
예제 #6
0
 /// <summary>
 /// This shows what option strikes are the most popular for each expiration.
 /// </summary>
 /// <param name="currency">Currency</param>
 /// <param name="expiryTime">expiry time (Format: YYYYMMdd, for example: "20210623")</param>
 /// <param name="period">period, the default is 8H. e.g. [8H/1D]</param>
 /// <param name="ct">Cancellation Token</param>
 /// <returns></returns>
 public virtual WebCallResult <IEnumerable <OkexInterestVolumeStrike> > GetRubikInterestVolumeStrike(
     string currency,
     string expiryTime,
     OkexPeriod period    = OkexPeriod.FiveMinutes,
     CancellationToken ct = default) => GetRubikInterestVolumeStrike_Async(currency, expiryTime, period, ct).Result;
예제 #7
0
 /// <summary>
 /// Open interest is the sum of all long and short futures and perpetual swap positions.
 /// </summary>
 /// <param name="currency">Currency</param>
 /// <param name="period">period, the default is 5m, e.g. [5m/1H/1D]</param>
 /// <param name="begin">begin, e.g. 1597026383085</param>
 /// <param name="end">end, e.g. 1597026383011</param>
 /// <param name="ct">Cancellation Token</param>
 /// <returns></returns>
 public virtual WebCallResult <IEnumerable <OkexInterestVolume> > GetRubikContractSummary(
     string currency,
     OkexPeriod period    = OkexPeriod.FiveMinutes,
     long?begin           = null,
     long?end             = null,
     CancellationToken ct = default) => GetRubikContractSummary_Async(currency, period, begin, end, ct).Result;
예제 #8
0
 /// <summary>
 /// This shows the sum of all open positions and how much total trading volume has taken place.
 /// </summary>
 /// <param name="currency">Currency</param>
 /// <param name="period">period, the default is 8H. e.g. [8H/1D]</param>
 /// <param name="ct">Cancellation Token</param>
 /// <returns></returns>
 public virtual WebCallResult <IEnumerable <OkexInterestVolume> > GetRubikOptionsSummary(
     string currency,
     OkexPeriod period    = OkexPeriod.FiveMinutes,
     CancellationToken ct = default) => GetRubikOptionsSummary_Async(currency, period, ct).Result;
예제 #9
0
 /// <summary>
 /// This is the ratio of users with net long vs short positions. It includes data from futures and perpetual swaps.
 /// </summary>
 /// <param name="currency">Currency</param>
 /// <param name="period">period, the default is 5m, e.g. [5m/1H/1D]</param>
 /// <param name="begin">begin, e.g. 1597026383085</param>
 /// <param name="end">end, e.g. 1597026383011</param>
 /// <param name="ct">Cancellation Token</param>
 /// <returns></returns>
 public virtual WebCallResult <IEnumerable <OkexRatio> > GetRubikLongShortRatio(
     string currency,
     OkexPeriod period    = OkexPeriod.FiveMinutes,
     long?begin           = null,
     long?end             = null,
     CancellationToken ct = default) => GetRubikLongShortRatio_Async(currency, period, begin, end, ct).Result;
예제 #10
0
        /// <summary>
        /// Retrieve the candlesticks data of the index. Data will be pushed every 500 ms.
        /// </summary>
        /// <param name="intrumentId">Instrument ID</param>
        /// <param name="period">Period</param>
        /// <param name="onData">On Data Handler</param>
        /// <returns></returns>
        public virtual async Task <CallResult <UpdateSubscription> > SubscribeToIndexCandlesticks_Async(string intrumentId, OkexPeriod period, Action <OkexCandlestick> onData)
        {
            var internalHandler = new Action <DataEvent <OkexSocketUpdateResponse <IEnumerable <OkexCandlestick> > > >(data =>
            {
                foreach (var d in data.Data.Data)
                {
                    d.Instrument = intrumentId;
                    onData(d);
                }
            });

            var jc      = JsonConvert.SerializeObject(period, new PeriodConverter(false));
            var request = new OkexSocketRequest(OkexSocketOperation.Subscribe, "index-candle" + jc, intrumentId);

            return(await SubscribeAsync(request, null, false, internalHandler).ConfigureAwait(false));
        }
예제 #11
0
 /// <summary>
 /// Retrieve the candlesticks data of the index. Data will be pushed every 500 ms.
 /// </summary>
 /// <param name="intrumentId">Instrument ID</param>
 /// <param name="period">Period</param>
 /// <param name="onData">On Data Handler</param>
 /// <returns></returns>
 public virtual CallResult <UpdateSubscription> SubscribeToIndexCandlesticks(string intrumentId, OkexPeriod period, Action <OkexCandlestick> onData) => SubscribeToIndexCandlesticks_Async(intrumentId, period, onData).Result;
예제 #12
0
        /// <summary>
        /// Retrieve the candlestick charts of mark price. This endpoint can retrieve the latest 1,440 data entries. Charts are returned in groups based on the requested bar.
        /// </summary>
        /// <param name="instrumentId">Instrument ID</param>
        /// <param name="period">Bar size, the default is 1m</param>
        /// <param name="after">Pagination of data to return records earlier than the requested ts, Unix timestamp format in milliseconds, e.g. 1597026383085</param>
        /// <param name="before">Pagination of data to return records newer than the requested ts, Unix timestamp format in milliseconds, e.g. 1597026383085</param>
        /// <param name="limit">Number of results per request. The maximum is 100; the default is 100.</param>
        /// <param name="ct">Cancellation Token</param>
        /// <returns></returns>
        public virtual async Task <WebCallResult <IEnumerable <OkexCandlestick> > > GetMarkPriceCandlesticks_Async(string instrumentId, OkexPeriod period, long?after = null, long?before = null, int limit = 100, CancellationToken ct = default)
        {
            if (limit < 1 || limit > 100)
            {
                throw new ArgumentException("Limit can be between 1-100.");
            }

            var parameters = new Dictionary <string, object>
            {
                { "instId", instrumentId },
                { "bar", JsonConvert.SerializeObject(period, new PeriodConverter(false)) },
            };

            parameters.AddOptionalParameter("after", after?.ToString());
            parameters.AddOptionalParameter("before", before?.ToString());
            parameters.AddOptionalParameter("limit", limit.ToString());

            var result = await SendRequestAsync <OkexRestApiResponse <IEnumerable <OkexCandlestick> > >(GetUrl(Endpoints_V5_Market_MarkPriceCandles), HttpMethod.Get, ct, parameters).ConfigureAwait(false);

            if (!result.Success)
            {
                return(WebCallResult <IEnumerable <OkexCandlestick> > .CreateErrorResult(result.ResponseStatusCode, result.ResponseHeaders, result.Error));
            }
            if (result.Data.ErrorCode > 0)
            {
                return(WebCallResult <IEnumerable <OkexCandlestick> > .CreateErrorResult(result.ResponseStatusCode, result.ResponseHeaders, new ServerError(result.Data.ErrorCode, result.Data.ErrorMessage, result.Data.Data)));
            }

            foreach (var candle in result.Data.Data)
            {
                candle.Instrument = instrumentId;
            }
            return(new WebCallResult <IEnumerable <OkexCandlestick> >(result.ResponseStatusCode, result.ResponseHeaders, result.Data.Data, null));
        }
예제 #13
0
 /// <summary>
 /// Retrieve the candlestick charts of mark price. This endpoint can retrieve the latest 1,440 data entries. Charts are returned in groups based on the requested bar.
 /// </summary>
 /// <param name="instrumentId">Instrument ID</param>
 /// <param name="period">Bar size, the default is 1m</param>
 /// <param name="after">Pagination of data to return records earlier than the requested ts, Unix timestamp format in milliseconds, e.g. 1597026383085</param>
 /// <param name="before">Pagination of data to return records newer than the requested ts, Unix timestamp format in milliseconds, e.g. 1597026383085</param>
 /// <param name="limit">Number of results per request. The maximum is 100; the default is 100.</param>
 /// <param name="ct">Cancellation Token</param>
 /// <returns></returns>
 public virtual WebCallResult <IEnumerable <OkexCandlestick> > GetMarkPriceCandlesticks(string instrumentId, OkexPeriod period, long?after = null, long?before = null, int limit = 100, CancellationToken ct = default)
 => GetMarkPriceCandlesticks_Async(instrumentId, period, after, before, limit, ct).Result;