public TradePriceUpdateJob(ITradeService tradeService, IMarketPriceService marketPriceService) { _job = tradeService.Trades.Connect() .Filter(trade => trade.Status == TradeStatus.Live) .Group(trade => trade.CurrencyPair) .SubscribeMany(groupedData => { var locker = new object(); decimal latestPrice = 0; //subscribe to price and update trades with the latest price var priceHasChanged = marketPriceService.ObservePrice(groupedData.Key) .Synchronize(locker) .Subscribe(price => { latestPrice = price; UpdateTradesWithPrice(groupedData.Cache.Items, latestPrice); }); //connect to data changes and update with the latest price var dataHasChanged = groupedData.Cache.Connect() .WhereReasonsAre(ChangeReason.Add, ChangeReason.Update) .Synchronize(locker) .Subscribe(changes => UpdateTradesWithPrice(changes.Select(change => change.Current), latestPrice)); return(new CompositeDisposable(priceHasChanged, dataHasChanged)); }) .Subscribe(); }
public TradePriceUpdateJob(ITradeService tradeService, IMarketPriceService marketPriceService) { _job = tradeService.Trades.Connect() .Filter(trade => trade.Status == TradeStatus.Live) .Group(trade => trade.CurrencyPair) .SubscribeMany(groupedData => { var locker = new object(); decimal latestPrice = 0; //subscribe to price and update trades with the latest price var priceHasChanged = marketPriceService.ObservePrice(groupedData.Key) .Synchronize(locker) .Subscribe(price => { latestPrice = price; UpdateTradesWithPrice(groupedData.Cache.Items, latestPrice); }); //connect to data changes and update with the latest price var dataHasChanged = groupedData.Cache.Connect() .WhereReasonsAre(ChangeReason.Add, ChangeReason.Update) .Synchronize(locker) .Subscribe(changes => UpdateTradesWithPrice(changes.Select(change => change.Current), latestPrice)); return new CompositeDisposable(priceHasChanged, dataHasChanged); }) .Subscribe(); }
public ListViewModel(IMarketPriceService marketPriceService, IActualPriceService actualPriceService) { _marketPriceService = marketPriceService; _actualPriceService = actualPriceService; LoadDataCommand = new Command(LoadDataExecuteCommand); LoadDataExecuteCommand(); }
public AssetController( ILogger <AssetController> logger, IAssetService assetService, IMarketPriceService marketPriceService) : base(logger) { _assetService = assetService; _marketPriceService = marketPriceService; }
public MainVieWModel(IActualPriceService actualPriceService, IMarketPriceService marketPriceService) { _actualPriceService = actualPriceService; _marketPriceService = marketPriceService; IsBusy = false; ErrorMessage = false; LoadDataCommand = new Command(async() => await LoadDataExecuteCommand()); MessagingCenter.Subscribe <MainPage>(this, LOAD_DATA, async(sender) => { await LoadDataExecuteCommand(); }); }
public StoreController( IAppUserService AppUserService, IDistrictService DistrictService, IOrganizationService OrganizationService, IProvinceService ProvinceService, IStatusService StatusService, IStoreGroupingService StoreGroupingService, IStoreStatusService StoreStatusService, IStoreTypeService StoreTypeService, IWardService WardService, IStoreService StoreService, IBusinessTypeService BusinessTypeService, IPositionService PositionService, IStoreDeliveryTimeService StoreDeliveryTimeService, IRelationshipCustomerTypeService RelationshipCustomerTypeService, IInfulenceLevelMarketService InfulenceLevelMarketService, IMarketPriceService MarketPriceService, IConsultingServiceService ConsultingServiceService, ICooperativeAttitudeService CooperativeAttitudeService, ICurrencyService CurrencyService, ICurrentContext CurrentContext , IHttpContextAccessor httpContextAccessor, DataContext _DataContext ) : base(httpContextAccessor, _DataContext) { this.AppUserService = AppUserService; this.DistrictService = DistrictService; this.OrganizationService = OrganizationService; this.ProvinceService = ProvinceService; this.StatusService = StatusService; this.StoreGroupingService = StoreGroupingService; this.StoreStatusService = StoreStatusService; this.StoreTypeService = StoreTypeService; this.WardService = WardService; this.StoreService = StoreService; this.BusinessTypeService = BusinessTypeService; this.PositionService = PositionService; this.StoreDeliveryTimeService = StoreDeliveryTimeService; this.RelationshipCustomerTypeService = RelationshipCustomerTypeService; this.InfulenceLevelMarketService = InfulenceLevelMarketService; this.MarketPriceService = MarketPriceService; this.ConsultingServiceService = ConsultingServiceService; this.CooperativeAttitudeService = CooperativeAttitudeService; this.CurrencyService = CurrencyService; this.CurrentContext = CurrentContext; }