Пример #1
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='request'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <object> GetCandlesHistoryBatchOrErrorAsync(this ICandleshistoryservice operations, GetCandlesHistoryBatchRequest request = default(GetCandlesHistoryBatchRequest), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetCandlesHistoryBatchOrErrorWithHttpMessagesAsync(request, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Пример #2
0
 /// <summary>
 /// Pairs for which hisotry can be requested
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <IList <string> > GetAvailableAssetPairsAsync(this ICandleshistoryservice operations, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetAvailableAssetPairsWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Пример #3
0
 /// <summary>
 /// Checks service is alive
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <IsAliveResponse> IsAliveAsync(this ICandleshistoryservice operations, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.IsAliveWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Пример #4
0
 /// <summary>
 /// Candles history from db
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='assetPairId'>
 /// Asset pair ID
 /// </param>
 /// <param name='priceType'>
 /// Price type. Possible values include: 'Unspecified', 'Bid', 'Ask', 'Mid',
 /// 'Trades'
 /// </param>
 /// <param name='timeInterval'>
 /// Time interval. Possible values include: 'Unspecified', 'Sec', 'Minute',
 /// 'Min5', 'Min15', 'Min30', 'Hour', 'Hour4', 'Hour6', 'Hour12', 'Day',
 /// 'Week', 'Month'
 /// </param>
 /// <param name='fromMoment'>
 /// From moment in ISO 8601 (inclusive)
 /// </param>
 /// <param name='toMoment'>
 /// To moment in ISO 8601 (exclusive)
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <object> GetCandlesHistoryFromDbOrErrorAsync(this ICandleshistoryservice operations, string assetPairId, CandlePriceType priceType, CandleTimeInterval timeInterval, System.DateTime fromMoment, System.DateTime toMoment, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetCandlesHistoryFromDbWithHttpMessagesAsync(assetPairId, priceType, timeInterval, fromMoment, toMoment, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Пример #5
0
 public AvgSpotRatesService(ILog log, ICandleshistoryservice candlesHistoryService, ISystem system,
                            IMarketMakerService marketMakerService)
     : base(Startup.ServiceName + '_' + nameof(AvgSpotRatesService),
            (int)TimeSpan.FromMinutes(1).TotalMilliseconds, log)
 {
     _candlesHistoryService = candlesHistoryService;
     _system             = system;
     _marketMakerService = marketMakerService;
     _log = log;
 }
        // ReSharper disable once UnusedMember.Global
        public static async Task <IReadOnlyDictionary <string, CandlesHistoryResponseModel> > TryGetCandlesHistoryBatchAsync(
            this ICandleshistoryservice service,
            IList <string> assetPairs,
            CandlePriceType priceType,
            CandleTimeInterval timeInterval,
            DateTime fromMoment,
            DateTime toMoment,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            var result = await service.GetCandlesHistoryBatchOrErrorAsync(new GetCandlesHistoryBatchRequest(priceType, timeInterval, fromMoment, toMoment, assetPairs), cancellationToken);

            return(result as IReadOnlyDictionary <string, CandlesHistoryResponseModel>);
        }
Пример #7
0
 public ApiService(
     ILykkeWalletAPIv1Client walletApiV1Client,
     ILykkeWalletAPIv2Client walletApiV2Client,
     IAssetsService assetsService,
     AssetsHelper assetsHelper,
     IMyNoSqlServerDataReader <PriceEntity> pricesReader,
     PricesStreamService priceStreamService,
     CandlesStreamService candlesStreamService,
     OrderbookStreamService orderbookStreamService,
     PublicTradesStreamService publicTradesStreamService,
     ICandleshistoryservice candlesHistoryService,
     ValidationService validationService,
     OrderbooksService orderbooksService,
     SessionService sessionService,
     IMatchingEngineClient matchingEngineClient,
     IBalancesClient balancesClient,
     IClientAccountClient clientAccountClient,
     IRateCalculatorClient rateCalculatorClient,
     ITradesAdapterClient tradesAdapterClient,
     IRegistrationServiceClient registrationServiceClient,
     IPushNotificationsClient pushNotificationsClient,
     WalletApiConfig walletApiConfig,
     AppConfig config,
     IMapper mapper
     )
 {
     _walletApiV1Client         = walletApiV1Client;
     _walletApiV2Client         = walletApiV2Client;
     _assetsService             = assetsService;
     _assetsHelper              = assetsHelper;
     _pricesReader              = pricesReader;
     _priceStreamService        = priceStreamService;
     _candlesStreamService      = candlesStreamService;
     _orderbookStreamService    = orderbookStreamService;
     _publicTradesStreamService = publicTradesStreamService;
     _candlesHistoryService     = candlesHistoryService;
     _validationService         = validationService;
     _orderbooksService         = orderbooksService;
     _sessionService            = sessionService;
     _matchingEngineClient      = matchingEngineClient;
     _balancesClient            = balancesClient;
     _clientAccountClient       = clientAccountClient;
     _rateCalculatorClient      = rateCalculatorClient;
     _tradesAdapterClient       = tradesAdapterClient;
     _registrationServiceClient = registrationServiceClient;
     _pushNotificationsClient   = pushNotificationsClient;
     _walletApiConfig           = walletApiConfig;
     _config = config;
     _mapper = mapper;
 }
 public InitService(
     IDatabase database,
     ILykkeMarketProfile marketProfileClient,
     ICandleshistoryservice candlesHistoryClient,
     IMyNoSqlServerDataWriter <Ticker> tickerWriter,
     IMyNoSqlServerDataWriter <Price> priceWriter,
     TimeSpan marketDataInterval
     )
 {
     _database             = database;
     _marketProfileClient  = marketProfileClient;
     _candlesHistoryClient = candlesHistoryClient;
     _tickerWriter         = tickerWriter;
     _priceWriter          = priceWriter;
     _marketDataInterval   = marketDataInterval;
 }
        // ReSharper disable once UnusedMember.Global
        public static async Task <IReadOnlyDictionary <string, CandlesHistoryResponseModel> > GetCandlesHistoryBatchAsync(
            this ICandleshistoryservice service,
            IList <string> assetPairs,
            CandlePriceType priceType,
            CandleTimeInterval timeInterval,
            DateTime fromMoment,
            DateTime toMoment,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            var result = await service.GetCandlesHistoryBatchOrErrorAsync(new GetCandlesHistoryBatchRequest(priceType, timeInterval, fromMoment, toMoment, assetPairs), cancellationToken);

            switch (result)
            {
            case IReadOnlyDictionary <string, CandlesHistoryResponseModel> candlesHistoryResponseModel:
                return(candlesHistoryResponseModel);

            case ErrorResponse errorResponse:
                throw new ErrorResponseException(errorResponse);
            }

            throw new InvalidOperationException($"Unexpected response type: {result?.GetType()}");
        }
        // ReSharper disable once UnusedMember.Global
        public static async Task <CandlesHistoryResponseModel> GetCandlesHistoryFromDbAsync(this ICandleshistoryservice service, string assetPairId, CandlePriceType priceType, CandleTimeInterval timeInterval, DateTime fromMoment, DateTime toMoment, CancellationToken cancellationToken = default(CancellationToken))
        {
            var result = await service.GetCandlesHistoryFromDbOrErrorAsync(assetPairId, priceType, timeInterval, fromMoment, toMoment, cancellationToken);

            switch (result)
            {
            case CandlesHistoryResponseModel candlesHistoryResponseModel:
                return(candlesHistoryResponseModel);

            case ErrorResponse errorResponse:
                throw new ErrorResponseException(errorResponse);
            }

            throw new InvalidOperationException($"Unexpected response type: {result?.GetType()}");
        }
        // ReSharper disable once UnusedMember.Global
        public static async Task <CandlesHistoryResponseModel> TryGetCandlesHistoryAsync(this ICandleshistoryservice service, string assetPairId, CandlePriceType priceType, CandleTimeInterval timeInterval, DateTime fromMoment, DateTime toMoment, CancellationToken cancellationToken = default(CancellationToken))
        {
            var result = await service.GetCandlesHistoryOrErrorAsync(assetPairId, priceType, timeInterval, fromMoment, toMoment, cancellationToken);

            return(result as CandlesHistoryResponseModel);
        }
Пример #12
0
 /// <summary>
 /// Asset's candles history
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='assetPairId'>
 /// Asset pair ID
 /// </param>
 /// <param name='priceType'>
 /// Price type. Possible values include: 'Unspecified', 'Bid', 'Ask', 'Mid',
 /// 'Trades'
 /// </param>
 /// <param name='timeInterval'>
 /// Time interval. Possible values include: 'Unspecified', 'Sec', 'Minute',
 /// 'Min5', 'Min15', 'Min30', 'Hour', 'Hour4', 'Hour6', 'Hour12', 'Day',
 /// 'Week', 'Month'
 /// </param>
 /// <param name='fromMoment'>
 /// From moment in ISO 8601 (inclusive)
 /// </param>
 /// <param name='toMoment'>
 /// To moment in ISO 8601 (exclusive)
 /// </param>
 public static object GetCandlesHistoryOrError(this ICandleshistoryservice operations, string assetPairId, CandlePriceType priceType, CandleTimeInterval timeInterval, System.DateTime fromMoment, System.DateTime toMoment)
 {
     return(operations.GetCandlesHistoryOrErrorAsync(assetPairId, priceType, timeInterval, fromMoment, toMoment).GetAwaiter().GetResult());
 }
Пример #13
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='request'>
 /// </param>
 public static object GetCandlesHistoryBatchOrError(this ICandleshistoryservice operations, GetCandlesHistoryBatchRequest request = default(GetCandlesHistoryBatchRequest))
 {
     return(operations.GetCandlesHistoryBatchOrErrorAsync(request).GetAwaiter().GetResult());
 }
Пример #14
0
 /// <summary>
 /// Pairs for which hisotry can be requested
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 public static IList <string> GetAvailableAssetPairs(this ICandleshistoryservice operations)
 {
     return(operations.GetAvailableAssetPairsAsync().GetAwaiter().GetResult());
 }
Пример #15
0
 /// <summary>
 /// Checks service is alive
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 public static IsAliveResponse IsAlive(this ICandleshistoryservice operations)
 {
     return(operations.IsAliveAsync().GetAwaiter().GetResult());
 }