public WormholeSender(IReactiveTrader reactiveTrader) { _wormhole = new Wormhole(WormHoleConstants.AppGroup, WormHoleConstants.Directory); _wormhole.ListenForMessage <string>(WormHoleConstants.StartUpdates, currencyPair => { Console.WriteLine($"Starting Watch updates for {currencyPair}"); _wormholeSubscription.Dispose(); _wormholeSubscription = reactiveTrader .PricingServiceClient .GetSpotStream(currencyPair) .Distinct(x => x.CreationTimestamp) .Subscribe(price => { Console.WriteLine($"Sending update for {currencyPair}: {price.Ask} / {price.Bid}"); _wormhole.PassMessage(WormHoleConstants.CurrencyUpdate, price); }); }); _wormhole.ListenForMessage <string>(WormHoleConstants.StopUpdates, _ => { Console.WriteLine($"Stopping Watch updates"); _wormholeSubscription.Dispose(); }); }
public TickerViewModelFactory( IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService) { this.reactiveTrader = reactiveTrader; this.concurrencyService = concurrencyService; }
public ConnectivityStatusViewModel( IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService, ILoggerFactory loggerFactory, IProcessorMonitor processorMonitor) { _processorMonitor = processorMonitor; _priceLatencyRecorder = reactiveTrader.PriceLatencyRecorder; var log = loggerFactory.Create(typeof(ConnectivityStatusViewModel)); if (!_processorMonitor.IsAvailable) { CpuPercent = "N/A"; CpuTime = "N/A"; } _subscriptions.Add(reactiveTrader.ConnectionStatusStream .ObserveOn(concurrencyService.Dispatcher) .SubscribeOn(concurrencyService.TaskPool) .Subscribe( OnStatusChange, ex => log.Error("An error occurred within the connection status stream.", ex))); _subscriptions.Add(Observable .Interval(StatsFrequency, concurrencyService.Dispatcher) .Subscribe(_ => OnTimerTick())); }
public SpotTilesViewModel(IReactiveTrader reactiveTrader, Func<ICurrencyPair, SpotTileSubscriptionMode, ISpotTileViewModel> spotTileFactory, IConcurrencyService concurrencyService, ILoggerFactory loggerFactory) { _referenceDataRepository = reactiveTrader.ReferenceData; _spotTileFactory = spotTileFactory; _concurrencyService = concurrencyService; _log = loggerFactory.Create(typeof (SpotTilesViewModel)); SpotTiles = new ObservableCollection<ISpotTileViewModel>(); _config = spotTileFactory(null, SpotTileSubscriptionMode.Conflate); _config.ToConfig(); SpotTiles.Add(_config); _subscriptions.Add( _config.Config.ObserveProperty(p => p.SubscriptionMode) .Subscribe(subscriptionMode => SpotTiles.Where(vm => vm.Pricing != null).ForEach(vm => vm.Pricing.SubscriptionMode = subscriptionMode))); _subscriptions.Add( _config.Config.ObserveProperty(p => p.ExecutionMode) .Subscribe(executionMode => SpotTiles.Where(vm => vm.Pricing != null).ForEach(vm => vm.Pricing.ExecutionMode = executionMode))); LoadSpotTiles(); }
public TradesViewController(IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService) : base(UITableViewStyle.Plain) { _reactiveTrader = reactiveTrader; _concurrencyService = concurrencyService; Title = "Trades"; TabBarItem.Image = UIImage.FromBundle("tab_trades"); _model = new TradeTilesModel(_reactiveTrader, _concurrencyService); _model.DoneTrades.CollectionChanged += (sender, e) => { // todo - handle insertions/removals properly UITableView table = this.TableView; if (table != null) { if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add && e.NewItems.Count == 1) { table.InsertRows( new [] { NSIndexPath.Create(0, e.NewStartingIndex) }, UITableViewRowAnimation.Top); } else { table.ReloadData(); } } }; _model.Initialise(); }
public WormholeSender(IReactiveTrader reactiveTrader) { _wormhole = new Wormhole(WormHoleConstants.AppGroup, WormHoleConstants.Directory); _wormhole.ListenForMessage<string>(WormHoleConstants.StartUpdates, currencyPair => { Console.WriteLine($"Starting Watch updates for {currencyPair}"); _wormholeSubscription.Dispose(); _wormholeSubscription = reactiveTrader .PricingServiceClient .GetSpotStream(currencyPair) .Distinct(x => x.CreationTimestamp) .Subscribe(price => { Console.WriteLine($"Sending update for {currencyPair}: {price.Ask} / {price.Bid}"); _wormhole.PassMessage(WormHoleConstants.CurrencyUpdate, price); }); }); _wormhole.ListenForMessage<string>(WormHoleConstants.StopUpdates, _ => { Console.WriteLine($"Stopping Watch updates"); _wormholeSubscription.Dispose(); }); }
public TradesViewController (IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService) : base (UITableViewStyle.Plain) { _reactiveTrader = reactiveTrader; _concurrencyService = concurrencyService; Title = "Trades"; TabBarItem.Image = UIImage.FromBundle ("tab_trades"); _model = new TradeTilesModel (_reactiveTrader, _concurrencyService); _model.DoneTrades.CollectionChanged += (sender, e) => { // todo - handle insertions/removals properly UITableView table = this.TableView; if (table != null) { if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add && e.NewItems.Count == 1) { table.InsertRows ( new [] { NSIndexPath.Create (0, e.NewStartingIndex) }, UITableViewRowAnimation.Top); } else { table.ReloadData (); } } }; _model.Initialise (); }
public SpotTilePricingViewModel(ICurrencyPair currencyPair, SpotTileSubscriptionMode spotTileSubscriptionMode, ISpotTileViewModel parent, Func<Direction, ISpotTilePricingViewModel, IOneWayPriceViewModel> oneWayPriceFactory, IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService, IConstantRatePump constantRatePump, ILoggerFactory loggerFactory) { _currencyPair = currencyPair; _subscriptionMode = spotTileSubscriptionMode; _parent = parent; _priceLatencyRecorder = reactiveTrader.PriceLatencyRecorder; _concurrencyService = concurrencyService; _constantRatePump = constantRatePump; _log = loggerFactory.Create(typeof(SpotTilePricingViewModel)); _priceSubscription = new SerialDisposable(); Bid = oneWayPriceFactory(Direction.SELL, this); Ask = oneWayPriceFactory(Direction.BUY, this); Notional = "1000000"; DealtCurrency = currencyPair.BaseCurrency; SpotDate = "SP"; IsSubscribing = true; SubscribeForPrices(); }
public SpotTilePricingViewModel(ICurrencyPair currencyPair, SpotTileSubscriptionMode spotTileSubscriptionMode, ISpotTileViewModel parent, Func <Direction, ISpotTilePricingViewModel, IOneWayPriceViewModel> oneWayPriceFactory, IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService, IConstantRatePump constantRatePump, ILoggerFactory loggerFactory) { _currencyPair = currencyPair; _subscriptionMode = spotTileSubscriptionMode; _parent = parent; _priceLatencyRecorder = reactiveTrader.PriceLatencyRecorder; _concurrencyService = concurrencyService; _constantRatePump = constantRatePump; _log = loggerFactory.Create(typeof(SpotTilePricingViewModel)); _priceSubscription = new SerialDisposable(); Bid = oneWayPriceFactory(Direction.SELL, this); Ask = oneWayPriceFactory(Direction.BUY, this); Notional = "1000000"; DealtCurrency = currencyPair.BaseCurrency; SpotDate = "SP"; IsSubscribing = true; SubscribeForPrices(); }
public SpotTilesViewModel(IReactiveTrader reactiveTrader, Func <ICurrencyPair, SpotTileSubscriptionMode, ISpotTileViewModel> spotTileFactory, IConcurrencyService concurrencyService, ILoggerFactory loggerFactory) { _referenceDataRepository = reactiveTrader.ReferenceData; _spotTileFactory = spotTileFactory; _concurrencyService = concurrencyService; _log = loggerFactory.Create(typeof(SpotTilesViewModel)); SpotTiles = new ObservableCollection <ISpotTileViewModel>(); _config = spotTileFactory(null, SpotTileSubscriptionMode.Conflate); _config.ToConfig(); SpotTiles.Add(_config); _subscriptions.Add( _config.Config.ObserveProperty(p => p.SubscriptionMode) .Subscribe(subscriptionMode => SpotTiles.Where(vm => vm.Pricing != null).ForEach(vm => vm.Pricing.SubscriptionMode = subscriptionMode))); _subscriptions.Add( _config.Config.ObserveProperty(p => p.ExecutionMode) .Subscribe(executionMode => SpotTiles.Where(vm => vm.Pricing != null).ForEach(vm => vm.Pricing.ExecutionMode = executionMode))); LoadSpotTiles(); }
public ConnectivityStatusViewModel( IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService, ILoggerFactory loggerFactory, IProcessorMonitor processorMonitor) { _processorMonitor = processorMonitor; _priceLatencyRecorder = reactiveTrader.PriceLatencyRecorder; var log = loggerFactory.Create(typeof (ConnectivityStatusViewModel)); if (!_processorMonitor.IsAvailable) { CpuPercent = "N/A"; CpuTime = "N/A"; } _subscriptions.Add(reactiveTrader.ConnectionStatusStream .ObserveOn(concurrencyService.Dispatcher) .SubscribeOn(concurrencyService.TaskPool) .Subscribe( OnStatusChange, ex => log.Error("An error occurred within the connection status stream.", ex))); _subscriptions.Add(Observable .Interval(StatsFrequency, concurrencyService.Dispatcher) .Subscribe(_ => OnTimerTick())); }
private void Connect(IReactiveTrader reactiveTrader) { App.Initialize(); _connectingSubscription = reactiveTrader .ConnectionStatusStream .Where(ci => ci.ConnectionStatus == ConnectionStatus.Connected) .Timeout(TimeSpan.FromSeconds(10)) .ObserveOn(App.Container.Resolve <IConcurrencyService>().Dispatcher) .Subscribe( _ => { _connectingSubscription.Dispose(); Spinner.Visibility = ViewStates.Gone; ConnectingLabel.Visibility = ViewStates.Gone; if (!App.IsTablet) { var logo = FindViewById <FrameLayout>(Resource.Id.logo); logo.Visibility = ViewStates.Gone; } }, ex => { _connectingSubscription.Dispose(); ConnectingLabel.Visibility = ViewStates.Visible; Connect(reactiveTrader); } ); }
public CurrencyPairViewModel(CurrencyPairStateDto currencyPairStateDto, IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService) { _currencyPairStateDto = currencyPairStateDto; _reactiveTrader = reactiveTrader; _concurrencyService = concurrencyService; Symbol = currencyPairStateDto.Symbol; Available = currencyPairStateDto.Enabled; Stale = currencyPairStateDto.Stale; CanModify = true; }
public NotificationGenerator(IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService) { _reactiveTrader = reactiveTrader; _concurrencyService = concurrencyService; NotificationsEnabled .Where(enabled => enabled) .Subscribe(_ => RegisterNotifications()) .Add(_disposables); }
private static async Task RunLoop(IReactiveTrader reactiveTraderApi) { Log.Info("Enter currency pair symbol and new state. Either E or D for enabled or disabled, or A or S for active or stale"); while (true) { var states = await reactiveTraderApi.Control.GetCurrencyPairStates(); var throughput = await reactiveTraderApi.Control.GetPriceFeedThroughput(); Print(states, throughput); await SendCommand(states, reactiveTraderApi); } }
public BlotterViewModel(IReactiveTrader reactiveTrader, Func<ITrade, bool, ITradeViewModel> tradeViewModelFactory, IConcurrencyService concurrencyService) { _tradeRepository = reactiveTrader.TradeRepository; _tradeViewModelFactory = tradeViewModelFactory; _concurrencyService = concurrencyService; Trades = new ObservableCollection<ITradeViewModel>(); LoadTrades(); }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { // Appearance UITableView.Appearance.BackgroundColor = Styles.RTDarkerBlue; UITableView.Appearance.SeparatorInset = UIEdgeInsets.Zero; UITabBar.Appearance.BarTintColor = Styles.RTDarkerBlue; // create a new window instance based on the screen size window = new UIWindow(UIScreen.MainScreen.Bounds); var cs = new ConcurrencyService(); _cs = cs; var logSource = new LogHub(); _loggerFactory = new LoggerFactory(logSource); #if DEBUG UIApplication.CheckForIllegalCrossThreadCalls = true; var logViewController = new LogViewController(cs, logSource); #endif _reactiveTrader = new Adaptive.ReactiveTrader.Client.Domain.ReactiveTrader(); _startUpViewController = new StartUpView(Initalize); Initalize(); _notificationHandler = new NotificationGenerator(_reactiveTrader, cs); _notificationHandler.Initialise(); var tradesViewController = new TradesViewController(_reactiveTrader, cs); var pricesViewController = new PriceTilesViewController(_reactiveTrader, cs); var statusViewController = new StatusViewController(_reactiveTrader, cs, _notificationHandler.NotificationsEnabled); tabBarController = new UITabBarController(); tabBarController.ViewControllers = new UIViewController[] { pricesViewController, tradesViewController, statusViewController #if DEBUG , logViewController #endif }; tabBarController.ModalTransitionStyle = UIModalTransitionStyle.CrossDissolve; window.RootViewController = _startUpViewController; window.MakeKeyAndVisible(); new WormholeSender(_reactiveTrader); return(true); }
public ConnectivityStatusViewModel( IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService) { reactiveTrader.ConnectionStatusStream .ObserveOn(concurrencyService.Dispatcher) .SubscribeOn(concurrencyService.TaskPool) .Subscribe( OnStatusChange, ex => log.Error("An error occurred within the connection status stream.", ex)); }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { // Appearance UITableView.Appearance.BackgroundColor = Styles.RTDarkerBlue; UITableView.Appearance.SeparatorInset = UIEdgeInsets.Zero; UITabBar.Appearance.BarTintColor = Styles.RTDarkerBlue; // create a new window instance based on the screen size window = new UIWindow(UIScreen.MainScreen.Bounds); var cs = new ConcurrencyService(); _cs = cs; var logSource = new LogHub(); _loggerFactory = new LoggerFactory(logSource); #if DEBUG UIApplication.CheckForIllegalCrossThreadCalls = true; var logViewController = new LogViewController(cs, logSource); #endif _reactiveTrader = new Adaptive.ReactiveTrader.Client.Domain.ReactiveTrader(); _startUpViewController = new StartUpView(Initalize); Initalize(); _notificationHandler = new NotificationGenerator(_reactiveTrader, cs); _notificationHandler.Initialise(); var tradesViewController = new TradesViewController(_reactiveTrader, cs); var pricesViewController = new PriceTilesViewController(_reactiveTrader, cs); var statusViewController = new StatusViewController(_reactiveTrader, cs, _notificationHandler.NotificationsEnabled); tabBarController = new UITabBarController(); tabBarController.ViewControllers = new UIViewController[] { pricesViewController, tradesViewController, statusViewController #if DEBUG , logViewController #endif }; tabBarController.ModalTransitionStyle = UIModalTransitionStyle.CrossDissolve; window.RootViewController = _startUpViewController; window.MakeKeyAndVisible(); new WormholeSender(_reactiveTrader); return true; }
public BlotterViewModel(IReactiveTrader reactiveTrader, Func<ITrade, bool, ITradeViewModel> tradeViewModelFactory, IConcurrencyService concurrencyService, ILoggerFactory loggerFactory) { _tradeRepository = reactiveTrader.TradeRepository; _tradeViewModelFactory = tradeViewModelFactory; _concurrencyService = concurrencyService; Trades = new ObservableCollection<ITradeViewModel>(); _log = loggerFactory.Create(typeof (BlotterViewModel)); LoadTrades(); }
public BlotterViewModel(IReactiveTrader reactiveTrader, Func <ITrade, bool, ITradeViewModel> tradeViewModelFactory, IConcurrencyService concurrencyService, ILoggerFactory loggerFactory) { _tradeRepository = reactiveTrader.TradeRepository; _tradeViewModelFactory = tradeViewModelFactory; _concurrencyService = concurrencyService; Trades = new ObservableCollection <ITradeViewModel>(); _log = loggerFactory.Create(typeof(BlotterViewModel)); LoadTrades(); }
public ConnectivityStatusViewModel(IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService) { _priceLatencyRecorder = reactiveTrader.PriceLatencyRecorder; reactiveTrader.ConnectionStatusStream .ObserveOn(concurrencyService.Dispatcher) .SubscribeOn(concurrencyService.ThreadPool) .Subscribe( OnStatusChange, ex => Log.Error("An error occurred within the connection status stream.", ex)); Observable .Interval(StatsFrequency, concurrencyService.Dispatcher) .Subscribe(OnTimerTick); }
public TickersViewModel(IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService, TickerViewModelFactory tickerViewModelFactory) { Tickers = new ObservableCollection<TickerViewModel>(); Tickers.Add(tickerViewModelFactory.Create("Yahoo")); Tickers.Add(tickerViewModelFactory.Create("Google")); Tickers.Add(tickerViewModelFactory.Create("Apple")); Tickers.Add(tickerViewModelFactory.Create("Facebook")); Tickers.Add(tickerViewModelFactory.Create("Microsoft")); Tickers.Add(tickerViewModelFactory.Create("Twitter")); this.tickerRepository = reactiveTrader.TickerRepository; this.concurrencyService = concurrencyService; LoadTrades(); }
public TickersViewModel(IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService, TickerViewModelFactory tickerViewModelFactory) { Tickers = new ObservableCollection <TickerViewModel>(); Tickers.Add(tickerViewModelFactory.Create("Yahoo")); Tickers.Add(tickerViewModelFactory.Create("Google")); Tickers.Add(tickerViewModelFactory.Create("Apple")); Tickers.Add(tickerViewModelFactory.Create("Facebook")); Tickers.Add(tickerViewModelFactory.Create("Microsoft")); Tickers.Add(tickerViewModelFactory.Create("Twitter")); this.tickerRepository = reactiveTrader.TickerRepository; this.concurrencyService = concurrencyService; LoadTrades(); }
public StatusFragment(IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService) { _reactiveTrader = reactiveTrader; _disposables.Add( _reactiveTrader.ConnectionStatusStream .SubscribeOn(concurrencyService.TaskPool) .ObserveOn(concurrencyService.Dispatcher) .Subscribe(OnStatusChange)); _disposables.Add( Observable.Interval(TimeSpan.FromSeconds(1), concurrencyService.TaskPool) .ObserveOn(concurrencyService.Dispatcher) .Subscribe(_ => OnTimer())); }
private static async Task UpdateThroughput(IReactiveTrader reactiveTrader, string arg) { int throughput = 0; if (int.TryParse(arg, out throughput)) { Log.InfoFormat("Setting through to {0:G}.", throughput); var result = await reactiveTrader.Control.SetPriceFeedThroughput(throughput); Log.Info("Set!"); } else { Log.Warn("Could not parse throughput. Please specify an integer."); } }
public MainViewModel(IReactiveTrader reactiveTrader, Func <CurrencyPairStateDto, ICurrencyPairViewModel> ccyViewModelFactory, IUserProvider userProvider, IConfigurationProvider configurationProvider, IConcurrencyService concurrencyService) { _reactiveTrader = reactiveTrader; _ccyViewModelFactory = ccyViewModelFactory; _userProvider = userProvider; _configurationProvider = configurationProvider; _concurrencyService = concurrencyService; RefreshCommand = new DelegateCommand(RefreshData); CurrencyPairs = new ObservableCollection <ICurrencyPairViewModel>(); ObserveThroughputs(); }
public MainViewModel(IReactiveTrader reactiveTrader, Func<CurrencyPairStateDto, ICurrencyPairViewModel> ccyViewModelFactory, IUserProvider userProvider, IConfigurationProvider configurationProvider, IConcurrencyService concurrencyService) { _reactiveTrader = reactiveTrader; _ccyViewModelFactory = ccyViewModelFactory; _userProvider = userProvider; _configurationProvider = configurationProvider; _concurrencyService = concurrencyService; RefreshCommand = new DelegateCommand(RefreshData); CurrencyPairs = new ObservableCollection<ICurrencyPairViewModel>(); ObserveThroughputs(); }
public StatusViewController(IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService) : base("StatusViewController", null) { _reactiveTrader = reactiveTrader; _concurrencyService = concurrencyService; Title = "Status"; TabBarItem.Image = UIImage.FromBundle("tab_status"); _disposables.Add( _reactiveTrader.ConnectionStatusStream .SubscribeOn(_concurrencyService.TaskPool) .ObserveOn(_concurrencyService.Dispatcher) .Subscribe(OnStatusChange)); _disposables.Add( Observable.Interval(TimeSpan.FromSeconds(1), _concurrencyService.TaskPool) .ObserveOn(_concurrencyService.Dispatcher) .Subscribe(_ => OnTimer())); }
public StatusViewController (IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService) : base ("StatusViewController", null) { _reactiveTrader = reactiveTrader; _concurrencyService = concurrencyService; Title = "Status"; TabBarItem.Image = UIImage.FromBundle ("tab_status"); _disposables.Add ( _reactiveTrader.ConnectionStatusStream .SubscribeOn (_concurrencyService.TaskPool) .ObserveOn (_concurrencyService.Dispatcher) .Subscribe (OnStatusChange)); _disposables.Add ( Observable.Interval (TimeSpan.FromSeconds(1), _concurrencyService.TaskPool) .ObserveOn (_concurrencyService.Dispatcher) .Subscribe(_ => OnTimer())); }
public PriceTilesViewController (IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService) : base(UITableViewStyle.Plain) { this._concurrencyService = concurrencyService; this._reactiveTrader = reactiveTrader; Title = "Prices"; TabBarItem.Image = UIImage.FromBundle ("tab_prices"); _model = new PriceTilesModel (_reactiveTrader, _concurrencyService); _model.ActiveCurrencyPairs.CollectionChanged += (sender, e) => { foreach (var model in e.NewItems.Cast<PriceTileModel>()) { model.OnChanged .Subscribe (OnItemChanged); } if (IsViewLoaded) { TableView.ReloadData (); } }; _model.Initialise (); }
public PriceTilesViewController(IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService) : base(UITableViewStyle.Plain) { this._concurrencyService = concurrencyService; this._reactiveTrader = reactiveTrader; Title = "Prices"; TabBarItem.Image = UIImage.FromBundle("tab_prices"); _model = new PriceTilesModel(_reactiveTrader, _concurrencyService); _model.ActiveCurrencyPairs.CollectionChanged += (sender, e) => { foreach (var model in e.NewItems.Cast <PriceTileModel>()) { model.OnChanged .Subscribe(OnItemChanged); } if (IsViewLoaded) { TableView.ReloadData(); } }; _model.Initialise(); }
public PriceTilesModel (IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService) { this._concurrencyService = concurrencyService; this._reactiveTrader = reactiveTrader; }
private static async Task UpdateCurrencyPairState(IEnumerable <CurrencyPairStateDto> states, IReactiveTrader reactiveTrader, string[] args) { var ccyPair = states.FirstOrDefault(state => string.Equals(args[0], state.Symbol, StringComparison.InvariantCultureIgnoreCase)); if (ccyPair == null) { Log.WarnFormat("Could not find symbol {0}", args[0]); return; } bool?setEnabled = null, setStale = null; foreach (var arg in args.Skip(1)) { switch (arg.ToUpperInvariant()) { case "S": setStale = true; break; case "A": setStale = false; break; case "E": setEnabled = true; break; case "D": setEnabled = false; break; } } Log.InfoFormat("From: {0}", ccyPair); if (setEnabled.HasValue) { ccyPair.Enabled = setEnabled.Value; } if (setStale.HasValue) { ccyPair.Stale = setStale.Value; } Log.InfoFormat("To: {0}", ccyPair); Log.Info("Setting.."); try { var result = await reactiveTrader.Control.SetCurrencyPairState(ccyPair.Symbol, ccyPair.Enabled, ccyPair.Stale); Log.Info("Set!"); } catch (Exception ex) { Log.Warn("Failed to set."); Log.Warn(ex); } }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { // Appearance UITableView.Appearance.BackgroundColor = Styles.RTDarkerBlue; UITableView.Appearance.SeparatorInset = UIEdgeInsets.Zero; UITabBar.Appearance.BarTintColor = Styles.RTDarkerBlue; // Black opaque status bar (which we request via Info.plist) not supported in iOS 7? // Xamarin 5.0.1 toolset out of date? UIApplication.SharedApplication.SetStatusBarStyle(UIStatusBarStyle.LightContent, false); UIApplication.SharedApplication.SetStatusBarHidden(false, true); // create a new window instance based on the screen size window = new UIWindow(UIScreen.MainScreen.Bounds); var cs = new ConcurrencyService(); var logSource = new LogHub(); var logging = new LoggerFactory(logSource); #if DEBUG UIApplication.CheckForIllegalCrossThreadCalls = true; var logViewController = new LogViewController(cs, logSource); #endif _reactiveTrader = new Adaptive.ReactiveTrader.Client.Domain.ReactiveTrader(); _reactiveTrader.Initialize(UserModel.Instance.TraderId, new [] { "https://reactivetrader.azurewebsites.net/signalr" }, logging); // _reactiveTrader.Initialize (UserModel.Instance.Id, new [] { "http://192.168.1.197:8080/signalr" }, logging); var tradesViewController = new TradesViewController(_reactiveTrader, cs); var pricesViewController = new PriceTilesViewController(_reactiveTrader, cs); var statusViewController = new StatusViewController(_reactiveTrader, cs); tabBarController = new UITabBarController(); tabBarController.ViewControllers = new UIViewController [] { pricesViewController, tradesViewController, statusViewController #if DEBUG , logViewController #endif }; var startUpViewController = new StartUpView(); startUpViewController.DisplayMessages(true, "Connecting.."); _reactiveTrader.ConnectionStatusStream .Where(ci => ci.ConnectionStatus == ConnectionStatus.Connected) .Timeout(TimeSpan.FromSeconds(15)) .ObserveOn(cs.Dispatcher) .Subscribe(_ => startUpViewController.PresentViewController(tabBarController, false, null), ex => startUpViewController.DisplayMessages(false, "Disconnected", "Unable to connect. Please restart the app.")); window.RootViewController = startUpViewController; // make the window visible window.MakeKeyAndVisible(); return(true); }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching (UIApplication app, NSDictionary options) { // Appearance UITableView.Appearance.BackgroundColor = Styles.RTDarkerBlue; UITableView.Appearance.SeparatorInset = UIEdgeInsets.Zero; UITabBar.Appearance.BarTintColor = Styles.RTDarkerBlue; // Black opaque status bar (which we request via Info.plist) not supported in iOS 7? // Xamarin 5.0.1 toolset out of date? UIApplication.SharedApplication.SetStatusBarStyle (UIStatusBarStyle.LightContent, false); UIApplication.SharedApplication.SetStatusBarHidden (false, true); // create a new window instance based on the screen size window = new UIWindow (UIScreen.MainScreen.Bounds); var cs = new ConcurrencyService (); var logSource = new LogHub (); var logging = new LoggerFactory (logSource); #if DEBUG UIApplication.CheckForIllegalCrossThreadCalls = true; var logViewController = new LogViewController(cs, logSource); #endif _reactiveTrader = new Adaptive.ReactiveTrader.Client.Domain.ReactiveTrader (); _reactiveTrader.Initialize (UserModel.Instance.TraderId, new [] { "https://reactivetrader.azurewebsites.net/signalr" }, logging); // _reactiveTrader.Initialize (UserModel.Instance.Id, new [] { "http://192.168.1.197:8080/signalr" }, logging); var tradesViewController = new TradesViewController (_reactiveTrader, cs); var pricesViewController = new PriceTilesViewController (_reactiveTrader, cs); var statusViewController = new StatusViewController (_reactiveTrader, cs); tabBarController = new UITabBarController (); tabBarController.ViewControllers = new UIViewController [] { pricesViewController, tradesViewController, statusViewController #if DEBUG , logViewController #endif }; var startUpViewController = new StartUpView (); startUpViewController.DisplayMessages (true, "Connecting.."); _reactiveTrader.ConnectionStatusStream .Where (ci => ci.ConnectionStatus == ConnectionStatus.Connected) .Timeout (TimeSpan.FromSeconds (15)) .ObserveOn (cs.Dispatcher) .Subscribe (_ => startUpViewController.PresentViewController (tabBarController, false, null), ex => startUpViewController.DisplayMessages (false, "Disconnected", "Unable to connect. Please restart the app.")); window.RootViewController = startUpViewController; // make the window visible window.MakeKeyAndVisible (); return true; }
private async static Task SendCommand(IEnumerable<CurrencyPairStateDto> states, IReactiveTrader reactiveTrader) { var commandLine = Console.ReadLine(); var args = commandLine.Split(new [] { ' '}, StringSplitOptions.RemoveEmptyEntries); if (args.Length > 1) { await UpdateCurrencyPairState(states, reactiveTrader, args); } else { await UpdateThroughput(reactiveTrader, args[0]); } }
private void Connect(IReactiveTrader reactiveTrader) { App.Initialize(); _connectingSubscription = reactiveTrader .ConnectionStatusStream .Where(ci => ci.ConnectionStatus == ConnectionStatus.Connected) .Timeout(TimeSpan.FromSeconds(10)) .ObserveOn(App.Container.Resolve<IConcurrencyService>().Dispatcher) .Subscribe( _ => { _connectingSubscription.Dispose(); Spinner.Visibility = ViewStates.Gone; ConnectingLabel.Visibility = ViewStates.Gone; if (!App.IsTablet) { var logo = FindViewById<FrameLayout>(Resource.Id.logo); logo.Visibility = ViewStates.Gone; } }, ex => { _connectingSubscription.Dispose(); ConnectingLabel.Visibility = ViewStates.Visible; Connect(reactiveTrader); } ); }
public PriceTilesModel(IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService) { this._concurrencyService = concurrencyService; this._reactiveTrader = reactiveTrader; }
private async static Task SendCommand(IEnumerable <CurrencyPairStateDto> states, IReactiveTrader reactiveTrader) { var commandLine = Console.ReadLine(); var args = commandLine.Split(new [] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (args.Length > 1) { await UpdateCurrencyPairState(states, reactiveTrader, args); } else { await UpdateThroughput(reactiveTrader, args[0]); } }
private static async Task UpdateCurrencyPairState(IEnumerable<CurrencyPairStateDto> states, IReactiveTrader reactiveTrader, string[] args) { var ccyPair = states.FirstOrDefault(state => string.Equals(args[0], state.Symbol, StringComparison.InvariantCultureIgnoreCase)); if (ccyPair == null) { Log.WarnFormat("Could not find symbol {0}", args[0]); return; } bool? setEnabled = null, setStale = null; foreach (var arg in args.Skip(1)) { switch (arg.ToUpperInvariant()) { case "S": setStale = true; break; case "A": setStale = false; break; case "E": setEnabled = true; break; case "D": setEnabled = false; break; } } Log.InfoFormat("From: {0}", ccyPair); if (setEnabled.HasValue) { ccyPair.Enabled = setEnabled.Value; } if (setStale.HasValue) { ccyPair.Stale = setStale.Value; } Log.InfoFormat("To: {0}", ccyPair); Log.Info("Setting.."); try { var result = await reactiveTrader.Control.SetCurrencyPairState(ccyPair.Symbol, ccyPair.Enabled, ccyPair.Stale); Log.Info("Set!"); } catch (Exception ex) { Log.Warn("Failed to set."); Log.Warn(ex); } }
public TradeTilesModel(IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService) { _reactiveTrader = reactiveTrader; _concurrencyService = concurrencyService; }
public TradeTilesModel (IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService) { _reactiveTrader = reactiveTrader; _concurrencyService = concurrencyService; }