public StrategyViewAllTradesViewModel() { DependencyContainer.ComposeParts(this); _broker = (BinanceBroker)_brokersService.Brokers.First(b => b.Name == "Binance"); _dispatcher = Dispatcher.CurrentDispatcher; ViewPairCommand = new DelegateCommand(o => ViewPair()); ChartViewModel.ChartTimeframeChangedAction += ChartTimeframeChangedAction; _testResultsStartedObserver = _results.TestRunStarted.Subscribe(newResults => { _trades = null; if (ChartViewModel.ChartPaneViewModels != null && ChartViewModel.ChartPaneViewModels.Count > 0) { ChartViewModel.ChartPaneViewModels[0].TradeAnnotations.Clear(); } }); _testResultsUpdatedObserver = _results.TestRunCompleted.Subscribe(newResults => { _trades = newResults; if (_trades.Count > 0) { ViewPairText = _trades[0].Market; } ViewPair(); }); }
public MainWindowViewModel() { Log.Info("Application started"); DependencyContainer.ComposeParts(this); _strategiesDirectory = Path.Combine(_dataDirectoryService.MainDirectoryWithApplicationName); // Setup brokers var brokers = new IBroker[] { _fxcm = new FxcmBroker { IncludeReportInUpdates = false } }; _brokersService.AddBrokers(brokers); RunStrategyLiveViewModel = new RunStrategyLiveViewModel(); LoginOutViewModel = new LoginOutViewModel(); RefreshStrategyFilenames(); }
public MainWindow() { InitializeComponent(); Title = Title + $" {typeof(MainWindow).Assembly.GetName().Version}"; DependencyContainer.ComposeParts(this); #if DEBUG Log.Info("Running in debug mode"); #else Logger.Visibility = Visibility.Collapsed; #endif var dispatcher = Dispatcher.CurrentDispatcher; Func <(Action <string> show, Action <string> updateText, Action close)> createProgressingViewFunc = () => { var view = new ProgressView(); view.Owner = this; return(text => { view.TextToShow.Text = text; view.ShowDialog(); }, txt => { if (dispatcher.CheckAccess()) { view.TextToShow.Text = txt; } else { dispatcher.BeginInvoke((Action)(() => { view.TextToShow.Text = txt; })); } }, () => view.Close()); }; Action <Action <string, string, string> > createLoginViewFunc = loginAction => { var view = new LoginView { Owner = this }; var loginVm = new LoginViewModel(() => view.Close(), loginAction); view.DataContext = loginVm; view.ShowDialog(); }; _vm = new MainWindowsViewModel(createLoginViewFunc, createProgressingViewFunc); _vm.SetParentWindow(this); DataContext = _vm; Closing += OnClosing; Loaded += MainWindow_Loaded; Height = SystemParameters.PrimaryScreenHeight * 0.70; Width = Height * 1.5; }
public QueryTradesViewModel() { DependencyContainer.ComposeParts(this); _broker = _brokersService.Brokers.First(b => b.Name == "FXCM"); _account = _brokersService.AccountsLookup[_broker]; SetInitialValue(); }
public MainWindow() { InitializeComponent(); DependencyContainer.ComposeParts(this); DataContext = new MainWindowsViewModel(); Closing += OnClosing; }
public SummaryViewModel() { DependencyContainer.ComposeParts(this); _broker = _brokersService.Brokers.First(b => b.Name == "FXCM"); var nowUTC = DateTime.UtcNow; var latestDate = new DateTime(nowUTC.Year, nowUTC.Month, nowUTC.Day, 23, 59, 59, DateTimeKind.Utc); VisibleRange = new DateRange(latestDate.AddMonths(-3), latestDate); MonthlyProfitVisibleRange = new DateRange(latestDate.AddMonths(-12), latestDate); }
public StrategyRunResultsChartViewModel() { _dispatcher = Dispatcher.CurrentDispatcher; DependencyContainer.ComposeParts(this); SeriesList = new ObservableCollection <IRenderableSeries>(); _testResultsStartedObserver = _results.TestRunStarted.Subscribe(UpdateChartData); _testResultsUpdatedObserver = _results.TestRunCompleted.Subscribe(UpdateChartData); ClearResultsChartCommand = new DelegateCommand(o => ClearResultsChart()); }
protected override void OnStartup(StartupEventArgs e) { Log.Info("Starting application"); DependencyContainer.AddAssembly(typeof(App).Assembly); DependencyContainer.AddAssembly(typeof(ChartingService).Assembly); DependencyContainer.AddAssembly(typeof(MarketDetailsService).Assembly); DependencyContainer.ComposeParts(this); _dataDirectoryService.SetApplicationName("TradeSimulator"); }
public RunStrategyLiveViewModel() { DependencyContainer.ComposeParts(this); RunLiveCommand = new DelegateCommand(o => RunLive()); _fxcm = (FxcmBroker)_brokersService.Brokers.First(x => x.Name == "FXCM"); _strategiesDirectory = _dataDirectoryService.MainDirectoryWithApplicationName; _logDirectory = DataDirectoryService.GetMainDirectoryWithApplicationName("FXCMTradeLog"); _brokersService.LoadBrokerAccounts(_tradeDetailsAutoCalculatorService, _logDirectory); _brokerAccount = _brokersService.AccountsLookup[_fxcm]; }
public MachineLearningChartViewModel() { DependencyContainer.ComposeParts(this); _broker = (BinanceBroker)_brokersService.Brokers.First(b => b.Name == "Binance"); ChartViewModel = new ChartViewModel(); ViewMarketCommand = new DelegateCommand(o => ViewMarket()); TimeframeOptions = new List <Timeframe>(); TimeframeOptions.AddRange(new[] { Timeframe.M15, Timeframe.H1, Timeframe.H2, Timeframe.H4, Timeframe.D1 }); SelectedTimeframe = Timeframe.H1; Market = "BTCUSDT"; }
public MachineLearningViewModel() { _dispatcher = Dispatcher; DependencyContainer.ComposeParts(this); CreatePointCommand = new DelegateCommand(o => CreatePoint()); ViewPointCommand = new DelegateCommand(o => ViewPoint()); CreatePointSetCommand = new DelegateCommand(o => CreatePointSet()); DeletePointSetCommand = new DelegateCommand(o => DeletePointSet()); DeletePointCommand = new DelegateCommand(o => DeletePoint()); TrainCommand = new DelegateCommand(o => Train(), o => IsTrainingEnabled); TestCommand = new DelegateCommand(o => TestModel(), o => IsTestEnabled); MLPointDoubleClickComamnd = new DelegateCommand(o => MLPointDoubleClicked()); Chart = new MachineLearningChartViewModel(); _chartClickedDisposable = ChartingService.ChartClickObservable.Subscribe(ChartClicked); Load(); }
protected override void OnStartup(StartupEventArgs e) { Log.Info("Starting application"); DependencyContainer.AddAssembly(typeof(App).Assembly); DependencyContainer.AddAssembly(typeof(ChartingService).Assembly); DependencyContainer.AddAssembly(typeof(BrokersService).Assembly); DependencyContainer.ComposeParts(this); _dataDirectoryService.SetApplicationName("FXCMTradeLog"); if (!Directory.Exists(_dataDirectoryService.MainDirectoryWithApplicationName)) { Directory.CreateDirectory(_dataDirectoryService.MainDirectoryWithApplicationName); } }
protected override void OnStartup(StartupEventArgs e) { var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly()); XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config")); Log.Info("Starting application"); DependencyContainer.AddAssembly(typeof(App).Assembly); DependencyContainer.AddAssembly(typeof(BrokersService).Assembly); DependencyContainer.AddAssembly(typeof(ChartingService).Assembly); DependencyContainer.AddAssembly(typeof(ModelPredictorService).Assembly); DependencyContainer.ComposeParts(this); _dataDirectoryService.SetApplicationName("AutomatedTrader"); }
public ChartViewModel() { DependencyContainer.ComposeParts(this); _dispatcher = Dispatcher.CurrentDispatcher; ChartTimeframeOptions.Add(Timeframe.D1); ChartTimeframeOptions.Add(Timeframe.H4); ChartTimeframeOptions.Add(Timeframe.H2); ChartTimeframeOptions.Add(Timeframe.H1); ChartTimeframeOptions.Add(Timeframe.M30); ChartTimeframeOptions.Add(Timeframe.M15); ChartTimeframeOptions.Add(Timeframe.M5); ChartTimeframeOptions.Add(Timeframe.M1); ChartTimeframe = Timeframe.H2; XVisibleRange = new DateRange(); }
public MainWindowsViewModel() { DependencyContainer.ComposeParts(this); _dispatcher = Dispatcher.CurrentDispatcher; UpdateFXCandlesCommand = new DelegateCommand(UpdateFXCandles); var brokers = new IBroker[] { new FxcmBroker(), new BinanceBroker("TODO", "TODO"), }; // Setup brokers and load accounts _brokersService.AddBrokers(brokers); EventManager.RegisterClassHandler(typeof(Window), Keyboard.KeyDownEvent, new KeyEventHandler(UIElement_OnPreviewKeyDown), true); LoginOutViewModel = new LoginOutViewModel(); }
public TradeDetailsViewModel(Trade trade, Action closeWindow) { _closeWindow = closeWindow; DependencyContainer.ComposeParts(this); Trade = trade; Date = Trade.StartDateTimeLocal != null ? Trade.StartDateTimeLocal.Value.ToString("dd/MM/yy HH:mm") : DateTime.Now.ToString("dd/MM/yy HH:mm"); RefreshDetails(); _broker = _brokersService.GetBroker(trade.Broker); _brokerAccount = _brokersService.AccountsLookup[_broker]; AddLimitCommand = new DelegateCommand(AddLimit); AddStopCommand = new DelegateCommand(AddStop); RemoveLimitCommand = new DelegateCommand(RemoveLimit); RemoveStopCommand = new DelegateCommand(RemoveStop); SetOrderDateTimePriceCommand = new DelegateCommand(SetOrderDateTimePrice); DoneCommand = new DelegateCommand(o => Done()); }
public static BrokerAccount LoadAccount(IBroker broker, string mainDirectoryWithApplicationName) { var accountPath = Path.Combine(mainDirectoryWithApplicationName, "BrokerAccounts", $"{broker.Name}_Account.json"); if (!File.Exists(accountPath)) { return(null); } var account = JsonConvert.DeserializeObject <BrokerAccount>(File.ReadAllText(accountPath)); DependencyContainer.ComposeParts(account); foreach (var trade in account.Trades) { if (trade.DataVersion == 0) { trade.DataVersion = Trade.CurrentDataVersion; } } return(account); }
public StrategyRunResultsViewModel() { _dispatcher = Dispatcher.CurrentDispatcher; ChartViewModel = new ChartViewModel(); ((INotifyPropertyChanged)ChartViewModel).PropertyChanged += ChartViewModelPropertyChanged; TradesViewModel = new TradeListViewModel(); ChartViewModel.ChartTimeframe = Timeframe.H4; DependencyContainer.ComposeParts(this); _uiService.ViewTradeObservable.Subscribe(o => { if (TradesViewModel.SelectedTrade == null) { return; } if (TradesViewModel.SelectedTrade.Timeframe != null) { ChartViewModel.ChartTimeframe = TradesViewModel.SelectedTrade.Timeframe.Value; } ChartViewModel.ShowTrade(TradesViewModel.SelectedTrade, ChartViewModel.ChartTimeframeOptions[ChartViewModel.SelectedChartTimeframeIndex], false, s => { }, new List <(IIndicator Indicator, Color Color, bool ShowInLegend)>() { (new ExponentialMovingAverage(8), Colors.DarkBlue, true), (new ExponentialMovingAverage(25), Colors.Blue, true), (new ExponentialMovingAverage(50), Colors.Blue, true), (new BollingerBand(1.5F, 20), Colors.Green, true), (new BollingerBand(-1.5F, 20), Colors.Green, false) }, _uiService.UseHeikenAshi); }); ResultsViewModel = new TradesResultsViewModel(() => { lock (_results.Results) { return(_results.Results.ToList()); } }); _testResultsStartedObserver = _results.TestRunStarted.Subscribe(newResults => { UpdateTrades(); ResultsViewModel.UpdateResults(); }); _testResultsUpdatedObserver = _results.TestRunCompleted.Subscribe(newResults => { UpdateTrades(); ResultsViewModel.UpdateResults(); }); Task.Run(() => { Log.Info("Updating strategy run results"); UpdateTrades(); ResultsViewModel.UpdateResults(); Log.Info("Updated strategy run results"); }); TradesViewModel.ShowClosedTrades = true; TradesViewModel.ShowOpenTrades = true; TradesViewModel.ShowOrders = true; }
public AddLinesModifier() { DependencyContainer.ComposeParts(this); }
public MainWindowViewModel( Func <string> getTradeCommentsFunc, Action <string> showMessageAction, Action <Cursor> setCursorAction, Func <IDisposable> suspendChartUpdatesAction, Action updateWindowAction) { DependencyContainer.ComposeParts(this); _directory = _dataDirectoryService.MainDirectoryWithApplicationName; if (!Directory.Exists(_directory)) { Directory.CreateDirectory(_directory); } _candlesService = new CandlesService(); /* // Create candles * Task.Run(() => * { * Log.Info("Creating candles"); * _candlesService.ConvertCandles(_brokerCandlesService, _fxcm, _marketsService.GetAllMarketDetails().Select(m => m.Name).ToList()); * Log.Info("Candles created"); * }); * return;*/ TimeFrameItems = new List <Timeframe> { Timeframe.D1, Timeframe.H4, Timeframe.H2, Timeframe.H1, Timeframe.M1 }; LargeChartTimeframeOptions.Clear(); LargeChartTimeframeOptions.Add(Timeframe.H4); LargeChartTimeframeOptions.Add(Timeframe.H2); // Setup available indicators AddAvailableIndicator(new ExponentialMovingAverage(8), Colors.DarkBlue, false, true); AddAvailableIndicator(new ExponentialMovingAverage(20), Colors.Blue, false, false); AddAvailableIndicator(new ExponentialMovingAverage(25), Colors.Blue, false, true); AddAvailableIndicator(new ExponentialMovingAverage(50), Colors.LightBlue, false, true); AddAvailableIndicator(new SimpleMovingAverage(50), Colors.Green, false, false); AddAvailableIndicator(new SimpleMovingAverage(200), Colors.LightGreen, false, false); AddAvailableIndicator(new AverageTrueRange(), Colors.Red, true, false); AddAvailableIndicator(new CommodityChannelIndex(), Colors.Red, true, false); AddAvailableIndicator(new T3CommodityChannelIndex(), Colors.Red, true, false); NewChartCommand = new DelegateCommand(o => NewChartMarket(), o => !Running); NextCandleCommand = new DelegateCommand(o => ProgressTime()); ClearTradesCommand = new DelegateCommand(o => ClearTrades()); CloseTradeCommand = new DelegateCommand(o => CloseTrade()); DeleteTradeCommand = new DelegateCommand(o => DeleteTrade()); StartLongTradeCommand = new DelegateCommand(o => StartTrade(TradeDirection.Long)); StartShortTradeCommand = new DelegateCommand(o => StartTrade(TradeDirection.Short)); _getTradeCommentsFunc = getTradeCommentsFunc; _showMessageAction = showMessageAction; _setCursorAction = setCursorAction; _suspendChartUpdatesAction = suspendChartUpdatesAction; _updateWindowAction = updateWindowAction; DependencyContainer.ComposeParts(this); _dispatcher = Dispatcher.CurrentDispatcher; _chartModeDisposable = ChartingService.ChartModeObservable.Subscribe(ChartModeChanged); TradeListDisplayOptions = TradeListDisplayOptionsFlag.ClosePrice | TradeListDisplayOptionsFlag.Comments | TradeListDisplayOptionsFlag.OrderPrice | TradeListDisplayOptionsFlag.Limit | TradeListDisplayOptionsFlag.OrderDate | TradeListDisplayOptionsFlag.ResultR | TradeListDisplayOptionsFlag.Status | TradeListDisplayOptionsFlag.Stop | TradeListDisplayOptionsFlag.Strategies; _markets = new List <string>(); foreach (var m in _marketsService.GetAllMarketDetails().Select(m => m.Name)) { if (File.Exists(_candlesService.GetCandlesPath(m, Timeframe.M5)) && File.Exists(_candlesService.GetCandlesPath(m, Timeframe.H2)) && File.Exists(_candlesService.GetCandlesPath(m, Timeframe.H4)) && File.Exists(_candlesService.GetCandlesPath(m, Timeframe.D1))) { _markets.Add(m); } } IsTradeEnabled = false; var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "TraderSimulator"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } _orderExpiryCandlesIndex = 0; ResultsViewModel = new TradesResultsViewModel(() => Trades.ToList()) { ShowOptions = true, ShowSubOptions = false, AdvStrategyNaming = true }; ResultsViewModel.ResultOptions.Remove("Timeframe"); ResultsViewModel.ShowOptions = false; ResultsViewModel.ShowIncludeOpenClosedTradesOptions = false; LoadTrades(); RemoveIncompleteTrades(); NewChartMarket(); _chartClickedDisposable = ChartingService.ChartClickObservable.Subscribe(ChartClicked); }
public BrokerAccount() { DependencyContainer.ComposeParts(this); }
public DoubleChartViewModel() { DependencyContainer.ComposeParts(this); RemoveSelectedLineCommand = new DelegateCommand(t => RemoveSelectedLine()); }
public RubberBandXyZoomModifierEnhanced() { DependencyContainer.ComposeParts(this); }
public MouseModifier() { DependencyContainer.ComposeParts(this); }