Beispiel #1
0
 public SpecialLiquidationCommandsHandler(
     ITradingEngine tradingEngine,
     IDateService dateService,
     IOrderReader orderReader,
     IChaosKitty chaosKitty,
     IOperationExecutionInfoRepository operationExecutionInfoRepository,
     ILog log,
     MarginTradingSettings marginTradingSettings,
     IAssetPairsCache assetPairsCache,
     IAssetPairDayOffService assetPairDayOffService,
     IExchangeConnectorService exchangeConnectorService,
     IIdentityGenerator identityGenerator,
     IAccountsCacheService accountsCacheService)
 {
     _tradingEngine = tradingEngine;
     _dateService   = dateService;
     _orderReader   = orderReader;
     _chaosKitty    = chaosKitty;
     _operationExecutionInfoRepository = operationExecutionInfoRepository;
     _log = log;
     _marginTradingSettings    = marginTradingSettings;
     _assetPairsCache          = assetPairsCache;
     _assetPairDayOffService   = assetPairDayOffService;
     _exchangeConnectorService = exchangeConnectorService;
     _identityGenerator        = identityGenerator;
     _accountsCacheService     = accountsCacheService;
 }
Beispiel #2
0
 public SnapshotService(
     IScheduleSettingsCacheService scheduleSettingsCacheService,
     IAccountsCacheService accountsCacheService,
     IQuoteCacheService quoteCacheService,
     IFxRateCacheService fxRateCacheService,
     IOrderReader orderReader,
     IDateService dateService,
     ITradingEngineSnapshotsRepository tradingEngineSnapshotsRepository,
     ISnapshotValidationService snapshotValidationService,
     IQueueValidationService queueValidationService,
     IMarginTradingBlobRepository blobRepository,
     ILog log,
     IFinalSnapshotCalculator finalSnapshotCalculator)
 {
     _scheduleSettingsCacheService = scheduleSettingsCacheService;
     _accountsCacheService         = accountsCacheService;
     _quoteCacheService            = quoteCacheService;
     _fxRateCacheService           = fxRateCacheService;
     _orderReader = orderReader;
     _dateService = dateService;
     _tradingEngineSnapshotsRepository = tradingEngineSnapshotsRepository;
     _snapshotValidationService        = snapshotValidationService;
     _queueValidationService           = queueValidationService;
     _blobRepository          = blobRepository;
     _log                     = log;
     _finalSnapshotCalculator = finalSnapshotCalculator;
 }
Beispiel #3
0
 public OvernightSwapService(
     IOvernightSwapCache overnightSwapCache,
     IAccountAssetsCacheService accountAssetsCacheService,
     IAccountsCacheService accountsCacheService,
     ICommissionService commissionService,
     IOvernightSwapStateRepository overnightSwapStateRepository,
     IOvernightSwapHistoryRepository overnightSwapHistoryRepository,
     IOrderReader orderReader,
     IThreadSwitcher threadSwitcher,
     IDateService dateService,
     AccountManager accountManager,
     MarginSettings marginSettings,
     ILog log)
 {
     _overnightSwapCache             = overnightSwapCache;
     _accountAssetsCacheService      = accountAssetsCacheService;
     _accountsCacheService           = accountsCacheService;
     _commissionService              = commissionService;
     _overnightSwapStateRepository   = overnightSwapStateRepository;
     _overnightSwapHistoryRepository = overnightSwapHistoryRepository;
     _orderReader    = orderReader;
     _threadSwitcher = threadSwitcher;
     _dateService    = dateService;
     _accountManager = accountManager;
     _marginSettings = marginSettings;
     _log            = log;
 }
Beispiel #4
0
 public AccountsController(IAccountsCacheService accountsCacheService,
                           IOrderReader orderReader,
                           ICqrsSender cqrsSender)
 {
     _accountsCacheService = accountsCacheService;
     _orderReader          = orderReader;
     _cqrsSender           = cqrsSender;
 }
 public OrderController(
     OrderApiConfiguration configuration,
     IOrderReader orderReader,
     ICommandQueueClient queueClient)
 {
     _configuration = configuration;
     _orderReader   = orderReader;
     _queueClient   = queueClient;
 }
 public PendingOrdersCleaningService(ILog log, IOrderReader orderReader, ITradingEngine tradingEngine,
                                     IAssetPairDayOffService assetDayOffService)
     : base(nameof(PendingOrdersCleaningService), 60000, log)
 {
     _log                = log;
     _orderReader        = orderReader;
     _tradingEngine      = tradingEngine;
     _assetDayOffService = assetDayOffService;
 }
 public ShopifyServiceBusTriggerManager(IOrderReader orderReader, IOrderFilter orderCreatedFilter, IOrderToTrelloCardMapper orderMapper, TrelloClient trelloClient, ILogger <ShopifyServiceBusTriggerManager> logger, SheetsClient sheetsClient)
 {
     _orderReader        = orderReader;
     _orderCreatedFilter = orderCreatedFilter;
     _orderMapper        = orderMapper;
     _trelloClient       = trelloClient;
     _logger             = logger;
     _sheetsClient       = sheetsClient;
 }
Beispiel #8
0
 public RabbitMqNotifyService(IDateService dateService, MarginTradingSettings settings,
                              IIndex <string, IMessageProducer <string> > publishers, ILog log, IOrderReader orderReader)
 {
     _dateService = dateService;
     _settings    = settings;
     _publishers  = publishers;
     _log         = log;
     _orderReader = orderReader;
 }
        public static OpenPositionContract ConvertToContract(this Position position, IOrderReader orderReader)
        {
            var relatedOrders = new List <RelatedOrderInfoContract>();

            foreach (var relatedOrderInfo in position.RelatedOrders)
            {
                if (orderReader.TryGetOrderById(relatedOrderInfo.Id, out var relatedOrder))
                {
                    relatedOrders.Add(new RelatedOrderInfoContract
                    {
                        Id                = relatedOrder.Id,
                        Price             = relatedOrder.Price ?? 0,
                        Type              = relatedOrder.OrderType.ToType <OrderTypeContract>(),
                        Status            = relatedOrder.Status.ToType <OrderStatusContract>(),
                        ModifiedTimestamp = relatedOrder.LastModified,
                        TrailingDistance  = relatedOrder.TrailingDistance
                    });
                }
            }

            return(new OpenPositionContract
            {
                AccountId = position.AccountId,
                AssetPairId = position.AssetPairId,
                CurrentVolume = position.Volume,
                Direction = position.Direction.ToType <PositionDirectionContract>(),
                Id = position.Id,
                OpenPrice = position.OpenPrice,
                OpenFxPrice = position.OpenFxPrice,
                ClosePrice = position.ClosePrice,
                ExpectedOpenPrice = position.ExpectedOpenPrice,
                OpenTradeId = position.OpenTradeId,
                OpenOrderType = position.OpenOrderType.ToType <OrderTypeContract>(),
                OpenOrderVolume = position.OpenOrderVolume,
                PnL = position.GetFpl(),
                UnrealizedPnl = position.GetUnrealisedFpl(),
                ChargedPnl = position.ChargedPnL,
                Margin = position.GetMarginMaintenance(),
                FxRate = position.CloseFxPrice,
                FxAssetPairId = position.FxAssetPairId,
                FxToAssetPairDirection = position.FxToAssetPairDirection.ToType <FxToAssetPairDirectionContract>(),
                RelatedOrders = position.RelatedOrders.Select(o => o.Id).ToList(),
                RelatedOrderInfos = relatedOrders,
                OpenTimestamp = position.OpenDate,
                ModifiedTimestamp = position.LastModified,
                TradeId = position.Id,
                AdditionalInfo = position.AdditionalInfo,
                Status = position.Status.ToType <PositionStatusContract>(),
                ForceOpen = position.ForceOpen,
                TradingConditionId = position.TradingConditionId,
                SwapTotal = position.SwapTotal
            });
        }
Beispiel #10
0
 public PickJob(ILog logger,
                IOrderReader sourceRepository,
                IOrderWriter destinationRepository,
                IOmsManhattanOrderMapRepository omsManhattanOrderMapRepository,
                IOrderHistoryRepository orderHistoryRepository)
 {
     _logger = logger;
     _orderHistoryRepository         = orderHistoryRepository;
     DestinationRepository           = destinationRepository;
     _omsManhattanOrderMapRepository = omsManhattanOrderMapRepository;
     SourceRepository = sourceRepository;
 }
Beispiel #11
0
 public AssetPairProjection(
     ITradingEngine tradingEngine,
     IAssetPairsCache assetPairsCache,
     IOrderReader orderReader,
     IScheduleSettingsCacheService scheduleSettingsCacheService,
     ILog log)
 {
     _tradingEngine   = tradingEngine;
     _assetPairsCache = assetPairsCache;
     _orderReader     = orderReader;
     _scheduleSettingsCacheService = scheduleSettingsCacheService;
     _log = log;
 }
Beispiel #12
0
 public AccountAssetsManager(
     AccountAssetsCacheService accountAssetsCacheService,
     IAccountAssetPairsRepository accountAssetPairsRepository,
     MarginSettings settings,
     IClientNotifyService clientNotifyService,
     IOrderReader orderReader)
 {
     _accountAssetsCacheService = accountAssetsCacheService;
     _pairsRepository           = accountAssetPairsRepository;
     _settings            = settings;
     _clientNotifyService = clientNotifyService;
     _orderReader         = orderReader;
 }
Beispiel #13
0
 public SnapshotValidationService(
     ITradingEngineSnapshotsRepository tradingEngineSnapshotsRepository,
     IOrdersHistoryRepository ordersHistoryRepository,
     IPositionsHistoryRepository positionsHistoryRepository,
     IOrderReader orderCache,
     ILog log)
 {
     _tradingEngineSnapshotsRepository = tradingEngineSnapshotsRepository;
     _ordersHistoryRepository          = ordersHistoryRepository;
     _positionsHistoryRepository       = positionsHistoryRepository;
     _orderCache = orderCache;
     _log        = log;
 }
Beispiel #14
0
 public AccountsController(IAccountsCacheService accountsCacheService,
                           IDateService dateService,
                           AccountManager accountManager,
                           IOrderReader orderReader,
                           TradingConditionsCacheService tradingConditionsCache,
                           ICqrsSender cqrsSender)
 {
     _accountsCacheService   = accountsCacheService;
     _dateService            = dateService;
     _accountManager         = accountManager;
     _orderReader            = orderReader;
     _tradingConditionsCache = tradingConditionsCache;
     _cqrsSender             = cqrsSender;
 }
Beispiel #15
0
        public BackOfficeController(
            IAccountsCacheService accountsCacheService,
            AccountManager accountManager,
            MatchingEngineRoutesManager routesManager,
            IOrderReader ordersReader,
            IMarginTradingEnablingService marginTradingEnablingService)
        {
            _accountsCacheService = accountsCacheService;

            _accountManager = accountManager;
            _routesManager  = routesManager;
            _ordersReader   = ordersReader;
            _marginTradingEnablingService = marginTradingEnablingService;
        }
        public static OrderContract ConvertToContract(this Order order, IOrderReader orderReader)
        {
            var relatedOrders = new List <Order>();

            foreach (var relatedOrderInfo in order.RelatedOrders)
            {
                if (orderReader.TryGetOrderById(relatedOrderInfo.Id, out var relatedOrder))
                {
                    relatedOrders.Add(relatedOrder);
                }
            }

            return(order.ConvertToContract(relatedOrders));
        }
Beispiel #17
0
        public RabbitMqNotifyService(IDateService dateService,
                                     MarginTradingSettings settings,
                                     ILog log,
                                     IOrderReader orderReader,
                                     IRabbitMqService rabbitMqService)
        {
            _dateService = dateService;
            _settings    = settings;
            _log         = log;
            _orderReader = orderReader;
            _publishers  = new Dictionary <string, Lykke.RabbitMqBroker.Publisher.IMessageProducer <string> >();

            RegisterPublishers(rabbitMqService);
        }
Beispiel #18
0
 public DeleteAccountsCommandsHandler(
     IOrderReader orderReader,
     IDateService dateService,
     IAccountsCacheService accountsCacheService,
     ITradingEngine tradingEngine,
     IChaosKitty chaosKitty,
     IOperationExecutionInfoRepository operationExecutionInfoRepository,
     ILog log)
 {
     _orderReader                      = orderReader;
     _dateService                      = dateService;
     _accountsCacheService             = accountsCacheService;
     _tradingEngine                    = tradingEngine;
     _chaosKitty                       = chaosKitty;
     _operationExecutionInfoRepository = operationExecutionInfoRepository;
     _log = log;
 }
Beispiel #19
0
 public SpecialLiquidationSaga(
     IDateService dateService,
     IChaosKitty chaosKitty,
     IOperationExecutionInfoRepository operationExecutionInfoRepository,
     IOrderReader orderReader,
     ISpecialLiquidationService specialLiquidationService,
     MarginTradingSettings marginTradingSettings,
     CqrsContextNamesSettings cqrsContextNamesSettings)
 {
     _dateService = dateService;
     _chaosKitty  = chaosKitty;
     _operationExecutionInfoRepository = operationExecutionInfoRepository;
     _orderReader = orderReader;
     _specialLiquidationService = specialLiquidationService;
     _marginTradingSettings     = marginTradingSettings;
     _cqrsContextNamesSettings  = cqrsContextNamesSettings;
 }
Beispiel #20
0
 public SnapshotService(
     IScheduleSettingsCacheService scheduleSettingsCacheService,
     IAccountsCacheService accountsCacheService,
     IQuoteCacheService quoteCacheService,
     IFxRateCacheService fxRateCacheService,
     IOrderReader orderReader,
     IDateService dateService,
     ITradingEngineSnapshotsRepository tradingEngineSnapshotsRepository)
 {
     _scheduleSettingsCacheService = scheduleSettingsCacheService;
     _accountsCacheService         = accountsCacheService;
     _quoteCacheService            = quoteCacheService;
     _fxRateCacheService           = fxRateCacheService;
     _orderReader = orderReader;
     _dateService = dateService;
     _tradingEngineSnapshotsRepository = tradingEngineSnapshotsRepository;
 }
Beispiel #21
0
 public PickTicketConfirmationJob(ILog logger,
                                  IOrderReader sourceRepository,
                                  IOrderWriter destinationRepository,
                                  IPickTicketProcessingRepository pickTicketProcessingRepository,
                                  IAuroraPickTicketRepository auroraPickTicketRepository,
                                  IOmsManhattanOrderMapRepository omsManhattanOrderMapRepository,
                                  IOrderHistoryRepository orderHistoryRepository,
                                  ICarrierReadRepository carrierReadRepository)
 {
     _logger                         = logger;
     SourceRepository                = sourceRepository;
     DestinationRepository           = destinationRepository;
     _pickTicketProcessingRepository = pickTicketProcessingRepository;
     _auroraPickTicketRepository     = auroraPickTicketRepository;
     _omsManhattanOrderMapRepository = omsManhattanOrderMapRepository;
     _orderHistoryRepository         = orderHistoryRepository;
     _carrierReadRepository          = carrierReadRepository;
 }
Beispiel #22
0
 public ProductChangedProjection(
     ITradingEngine tradingEngine,
     IAssetPairsCache assetPairsCache,
     IOrderReader orderReader,
     IScheduleSettingsCacheService scheduleSettingsCacheService,
     ITradingInstrumentsManager tradingInstrumentsManager,
     IRfqService rfqService,
     IRfqPauseService rfqPauseService,
     MarginTradingSettings mtSettings,
     ILog log,
     IQuoteCacheService quoteCache)
 {
     _tradingEngine   = tradingEngine;
     _assetPairsCache = assetPairsCache;
     _orderReader     = orderReader;
     _scheduleSettingsCacheService = scheduleSettingsCacheService;
     _tradingInstrumentsManager    = tradingInstrumentsManager;
     _rfqService      = rfqService;
     _rfqPauseService = rfqPauseService;
     _mtSettings      = mtSettings;
     _log             = log;
     _quoteCache      = quoteCache;
 }
Beispiel #23
0
        public async void Configure(IApplicationBuilder app, IHostingEnvironment env, IOrderReader orderReader)
        {
            app.UseCors("CorsPolicy");
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseMvc();
            app.AddStatusEndpoint();

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Orders API V1");
            });

            app.UseHealthChecks("/health/live", new HealthCheckOptions
            {
                Predicate = r => r.Name.Contains("self")
            });

            app.UseHealthChecks("/health/ready", new HealthCheckOptions
            {
                Predicate = r => r.Name.Contains("self") || r.Tags.Contains("dependency")
            });

            // TODO: Remove this temporary method used to prove health checks work with k8s
            app.Map("/switch", appBuilder =>
            {
                appBuilder.Run(async context =>
                {
                    running = !running;
                    await context.Response.WriteAsync($"{Environment.MachineName} running {running}");
                });
            });
        }
 public OrderService(IOrderReader orderReader)
 {
     _orderReader = orderReader;
 }
Beispiel #25
0
 private static string MapToFinalJson(IList <Position> positions, IOrderReader reader) =>
 positions.Select(p => p.ConvertToSnapshotContract(reader)).ToJson();
Beispiel #26
0
 private static string MapToFinalJson(IList <Order> orders, IOrderReader reader) =>
 orders.Select(o => o.ConvertToSnapshotContract(reader)).ToJson();
 /// <summary>
 /// Convert order to a model, supposed to be used for snapshot serialization
 /// </summary>
 /// <param name="order">Order domain model</param>
 /// <param name="status">Snapshot status</param>
 /// <param name="orderReader"></param>
 /// <returns></returns>
 public static object ConvertToSnapshotContract(this Order order, IOrderReader orderReader, SnapshotStatus status = SnapshotStatus.Final)
 {
     return(status == SnapshotStatus.Draft
         ? (object)order
         : order.ConvertToContract(orderReader));
 }
 /// <summary>
 /// Convert position to a model, supposed to be used for snapshot serialization
 /// </summary>
 /// <param name="position">Position domain model</param>
 /// <param name="status">Snapshot status</param>
 /// <param name="orderReader"></param>
 /// <returns></returns>
 public static object ConvertToSnapshotContract(this Position position, IOrderReader orderReader, SnapshotStatus status = SnapshotStatus.Final)
 {
     return(status == SnapshotStatus.Draft
         ? (object)position
         : position.ConvertToContract(orderReader));
 }
Beispiel #29
0
 public OrdersController(IOrderReader reader)
 {
     _reader = reader ?? throw new ArgumentNullException($"{GetType().Name}.Ctor - parameter {nameof(reader)} cannot be null.");
 }