diff --git a/Cache/PriceCache.cs b/Cache/PriceCache.cs deleted file mode 100644 index 2c443de..0000000 --- a/Cache/PriceCache.cs +++ /dev/null @@ -1,106 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using MarketData.MarketDataModel; -using MarketData.Helper; -using MarketData; -using MarketData.Utils; - -namespace TradeBlotter.Cache -{ - public class PriceCache : IDisposable - { - private Dictionary priceCache=new Dictionary(); - private Object thisLock=new Object(); - private Thread cacheMonitorThread=null; - private volatile bool threadRun=true; - private int cacheRefreshAfter=60000; - private static PriceCache priceCacheInstance=null; - - private PriceCache() - { - cacheMonitorThread=new Thread(new ThreadStart(ThreadProc)); - cacheMonitorThread.Start(); - } - public static PriceCache GetInstance() - { - lock(typeof(PriceCache)) - { - if(null==priceCacheInstance) priceCacheInstance=new PriceCache(); - return priceCacheInstance; - } - } - public void Clear() - { - lock(thisLock) - { - priceCache=new Dictionary(); - } - } - public void Dispose() - { - lock(thisLock) - { - if(null==priceCacheInstance || false==threadRun)return; - threadRun=false; - if(null!=cacheMonitorThread) - { - MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[PriceCache:Dispose]Thread state is {0}. Joining main thread...",Utility.ThreadStateToString(cacheMonitorThread))); - cacheMonitorThread.Join(5000); - cacheMonitorThread=null; - MDTrace.WriteLine(LogLevel.DEBUG,"[PriceCache:Dispose] End."); - } - priceCacheInstance=null; - } - } - public Price GetLatestPrice(String symbol) - { - lock(thisLock) - { - if(priceCache.ContainsKey(symbol)) - { - return priceCache[symbol]; - } - Price price=MarketDataHelper.GetLatestPrice(symbol); - if(null!=price) Add(price); - return price; - } - } - public bool Contains(String symbol) - { - lock(thisLock) - { - return priceCache.ContainsKey(symbol); - } - } - private void Add(Price price) - { - lock(thisLock) - { - if(priceCache.ContainsKey(price.Symbol)) return; - priceCache.Add(price.Symbol,price); - } - } - private void ThreadProc() - { - int quantums=0; - int quantumInterval=1000; - while(threadRun) - { - Thread.Sleep(quantumInterval); - if(!threadRun)break; - quantums+=quantumInterval; - if(quantums>cacheRefreshAfter) - { - quantums=0; - lock(thisLock) - { - priceCache.Clear(); - } - } - } - } - } -} diff --git a/MainWindowResources.xaml b/MainWindowResources.xaml index 8deafc8..8d360b7 100644 --- a/MainWindowResources.xaml +++ b/MainWindowResources.xaml @@ -45,10 +45,6 @@ This resource dictionary is used by the MainWindow. - - - - @@ -133,10 +129,6 @@ This resource dictionary is used by the MainWindow. - - - - diff --git a/TradeBlotter.csproj b/TradeBlotter.csproj index 4cce3ae..b71b4dd 100644 --- a/TradeBlotter.csproj +++ b/TradeBlotter.csproj @@ -106,7 +106,6 @@ MSBuild:Compile Designer - @@ -177,7 +176,6 @@ - @@ -200,7 +198,6 @@ - @@ -277,12 +274,6 @@ MovingAverageView.xaml - - OptionsView.xaml - - - OptionsWorksheetView.xaml - PricingView.xaml @@ -453,14 +444,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - Designer MSBuild:Compile diff --git a/ViewModels/FeedStatisticsViewModel.cs b/ViewModels/FeedStatisticsViewModel.cs index aa18ab5..c00c40b 100644 --- a/ViewModels/FeedStatisticsViewModel.cs +++ b/ViewModels/FeedStatisticsViewModel.cs @@ -148,7 +148,7 @@ namespace TradeBlotter.ViewModels { try{LocalPriceCache.GetInstance().Clear();}catch(Exception){;} try{GBPriceCache.GetInstance().Clear();}catch(Exception){;} - try{PriceCache.GetInstance().Clear();}catch(Exception){;} +// try{PriceCache.GetInstance().Clear();}catch(Exception){;} MessageBox.Show("All caches have been re-intiialized.",base.DisplayName); } private void Refresh() diff --git a/ViewModels/GainLossViewModel.cs b/ViewModels/GainLossViewModel.cs index 328b332..5c14386 100644 --- a/ViewModels/GainLossViewModel.cs +++ b/ViewModels/GainLossViewModel.cs @@ -921,7 +921,6 @@ namespace TradeBlotter.ViewModels { try{LocalPriceCache.GetInstance().Clear();}catch(Exception){;} try{GBPriceCache.GetInstance().Clear();}catch(Exception){;} - try{PriceCache.GetInstance().Clear();}catch(Exception){;} } // ************************************************************************************************************************************************************************************** // ******************************************************************************** C O M M A N D S ************************************************************************************* diff --git a/ViewModels/MainWindowViewModel.cs b/ViewModels/MainWindowViewModel.cs index d31cabf..5d79803 100644 --- a/ViewModels/MainWindowViewModel.cs +++ b/ViewModels/MainWindowViewModel.cs @@ -100,7 +100,6 @@ namespace TradeBlotter.ViewModels } try{LocalPriceCache.GetInstance().Dispose();}catch(Exception){;} try{GBPriceCache.GetInstance().Dispose();}catch(Exception){;} - try{PriceCache.GetInstance().Dispose();}catch(Exception){;} try{SymbolCache.GetInstance().Dispose();}catch(Exception){;} base.OnDispose(); } @@ -237,7 +236,6 @@ namespace TradeBlotter.ViewModels new CommandViewModel("MGSHMomentum Model",new RelayCommand(ParamArrayAttribute=>this.ViewMGSHMomentumGenerator())), new CommandViewModel("CMMomentum Model",new RelayCommand(ParamArrayAttribute=>this.ViewCMMomentumGenerator())), new CommandViewModel("CMTTrend Model",new RelayCommand(ParamArrayAttribute=>this.ViewCMTTrendGenerator())), - new CommandViewModel("Options",new RelayCommand(ParamArrayAttribute=>this.ViewOptions())), new CommandViewModel("Watch Lists",new RelayCommand(ParamArrayAttribute=>this.ViewWatchLists())), new CommandViewModel("Feed Statistics",new RelayCommand(ParamArrayAttribute=>this.ViewFeedStatistics())) }; @@ -432,18 +430,6 @@ namespace TradeBlotter.ViewModels } this.SetActiveWorkspace(workspace); } - private void ViewOptions() - { - OptionsViewModel workspace = this.Workspaces.FirstOrDefault(vm => vm is OptionsViewModel) as OptionsViewModel; - if (null == workspace) - { - workspace = new OptionsViewModel(); - workspace.WorkspaceInstantiator = InstantiateWorkspace; - AddMenuItem(workspace); - this.Workspaces.Add(workspace); - } - this.SetActiveWorkspace(workspace); - } private void ViewEarningsAnnouncements() { EarningsAnnouncementViewModel workspace = this.Workspaces.FirstOrDefault(vm => vm is EarningsAnnouncementViewModel) as EarningsAnnouncementViewModel; diff --git a/ViewModels/OptionsViewModel.cs b/ViewModels/OptionsViewModel.cs deleted file mode 100644 index ae79f6f..0000000 --- a/ViewModels/OptionsViewModel.cs +++ /dev/null @@ -1,910 +0,0 @@ -using System; -using System.ComponentModel; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Collections.Specialized; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Threading; -using System.Windows.Input; -using System.Windows.Forms; -using System.Xml.Serialization; -using System.Windows.Media; -using MarketData; -using MarketData.Utils; -using MarketData.MarketDataModel; -using MarketData.Generator; -using MarketData.DataAccess; -using MarketData.Helper; -using MarketData.Numerical; -using TradeBlotter.DataAccess; -using TradeBlotter.Command; -using TradeBlotter.Model; -using TradeBlotter.Cache; -using Microsoft.Research.DynamicDataDisplay.DataSources; -using System.IO; - -namespace TradeBlotter.ViewModels -{ - public class OptionsViewModel : WorkspaceViewModel - { - private enum Tasks{SelectedSymbol,SelectedItem,CheckBoxFullHistory,CheckBoxCallPutRatio,SelectedExpirationDate,SelectedOptionType,SelectedWatchList,SelectedRiskFreeRateType,SelectedVolatilityDays}; - private Dictionary semaphorePool=new Dictionary(); - private RelayCommand launchOptionsWorksheetCommand = null; - private BollingerBands bollingerBands; - private Prices prices; - private String symbol; - private double volatility; - private List symbols; - private List watchLists; - private String selectedWatchList; - private RelayCommand updateCommand; - private List optionTypes; - private String selectedOptionType; - private ObservableCollection