示例#1
0
        public Task <TradeDto> Execute(TradeRequestDto tradeRequest)
        {
            var user = ContextUtil.GetUserName(Context);

            Log.InfoFormat("Received trade request {0} from user {1}", tradeRequest, user);

            var trade = _executionService.Execute(tradeRequest, user);

            Log.InfoFormat("Trade executed: {0}", trade);

            return(trade);
        }
示例#2
0
        public IEnumerable <CurrencyPairStateDto> GetCurrencyPairStates()
        {
            Log.InfoFormat("Returning all currency pair states to {0}.", ContextUtil.GetUserName(Context));

            return(_currencyPairRepository.GetAllCurrencyPairInfos()
                   .Select(cpi => new CurrencyPairStateDto
            {
                Symbol = cpi.CurrencyPair.Symbol,
                Enabled = cpi.Enabled,
                Stale = cpi.Stale
            })
                   .ToList());
        }
示例#3
0
        public async Task SubscribeAnalytics()
        {
            _contextHolder.AnalyticsHubClients = Clients;

            var user = ContextUtil.GetUserName(Context);

            Log.InfoFormat("Received analytics subscription from use {0}", user);

            await Groups.Add(Context.ConnectionId, ServiceConstants.Server.AnalyticsGroup);

            Log.InfoFormat("Connection {0} of user {1} added to group '{2}'", Context.ConnectionId, user, ServiceConstants.Server.AnalyticsGroup);

            var analytics = _analyticsService.CurrentPositionUpdatesDto;
            await Clients.Caller.OnNewAnalytics(analytics);

            Log.InfoFormat("Snapshot published to {0}", Context.ConnectionId);
        }
示例#4
0
        public async Task SubscribeTrades()
        {
            _contextHolder.BlotterHubClients = Clients;

            var user = ContextUtil.GetUserName(Context);

            Log.InfoFormat("Received trade subscription from user {0}", user);

            // add client to the trade notification group
            await Groups.Add(Context.ConnectionId, BlotterGroupName);

            Log.InfoFormat("Connection {0} of user {1} added to group '{2}'", Context.ConnectionId, user, BlotterGroupName);

            var trades = _tradeRepository.GetAllTrades();
            await Clients.Caller.OnNewTrade(trades);

            Log.InfoFormat("Snapshot published to {0}", Context.ConnectionId);
        }
示例#5
0
        public UnitDto SetCurrencyPairState(CurrencyPairStateDto request)
        {
            var currencyPair = _currencyPairRepository.GetAllCurrencyPairInfos()
                               .FirstOrDefault(cpi => cpi.CurrencyPair.Symbol == request.Symbol);

            if (currencyPair != null)
            {
                Log.InfoFormat("Received set currency pair state [{0}] from {1}.", request.Symbol, ContextUtil.GetUserName(Context));
                if (currencyPair.Enabled != request.Enabled)
                {
                    if (request.Enabled)
                    {
                        Log.InfoFormat("Enabling currency pair {0}.", request.Symbol);
                        _currencyPairUpdatePublisher.AddCurrencyPair(currencyPair.CurrencyPair);
                    }
                    else
                    {
                        Log.InfoFormat("Disabling currency pair {0}", request.Symbol);
                        _currencyPairUpdatePublisher.RemoveCurrencyPair(currencyPair.CurrencyPair);
                    }
                    currencyPair.Enabled = request.Enabled;
                }

                if (currencyPair.Stale != request.Stale)
                {
                    if (currencyPair.Stale)
                    {
                        Log.InfoFormat("Making currency pair {0} go stale.", request.Symbol);
                    }
                    else
                    {
                        Log.InfoFormat("Making currency pair {0} no longer stale.", request.Symbol);
                    }
                    currencyPair.Stale = request.Stale;
                }
            }
            else
            {
                Log.WarnFormat("Received set currency pair state for unknown currency pair {0} from {1}.", request.Symbol, ContextUtil.GetUserName(Context));
            }

            return(new UnitDto());
        }
示例#6
0
        public FeedThroughputDto SetPriceFeedThroughput()
        {
            var throughput = _priceFeed.GetUpdateFrequency();

            Log.InfoFormat("Returning price feed throughput of {0} to {1}.", throughput, ContextUtil.GetUserName(Context));
            return(new FeedThroughputDto
            {
                Throughput = throughput
            });
        }
示例#7
0
 public UnitDto SetPriceFeedThroughput(FeedThroughputDto throughputDto)
 {
     Log.InfoFormat("Received set price feed throughput command to {0} from {1}.", throughputDto.Throughput, ContextUtil.GetUserName(Context));
     _priceFeed.SetUpdateFrequency(throughputDto.Throughput);
     return(new UnitDto());
 }