Exemplo n.º 1
0
 public LoginViewModel(MainWindowModel mainWindowModel, StockAgent stockAgent, IDialogService dialogService, IFrameNavigationService frameNavigationService)
 {
     _mainWindowModel        = mainWindowModel;
     _stockAgent             = stockAgent;
     _dialogService          = dialogService;
     _frameNavigationService = frameNavigationService;
 }
Exemplo n.º 2
0
 public TradeGridViewModel(StockInfoViewModel stockInfoViewModel, IDialogService dialogService, StockAgent stockAgent, UserStockInfoViewModel userStockInfoViewModel, UserMoneyInfo userMoneyInfo)
 {
     _stockInfoViewModel     = stockInfoViewModel;
     _dialogService          = dialogService;
     _stockAgent             = stockAgent;
     _userStockInfoViewModel = userStockInfoViewModel;
     _userMoneyInfo          = userMoneyInfo;
     Messenger.Default.Register <GenericMessage <double?> >(this, UpdateSingleText, d =>
     {
         if (d.Content == null)
         {
             BuyCbbSelectedIndex  = -1;
             SellCbbSelectedIndex = -1;
         }
         else
         {
             if (BuyCbbSelectedIndex == 0)
             {
                 BuySingleText = ((double)d.Content).ToString("F2");
             }
             if (SellCbbSelectedIndex == 0)
             {
                 SellSingleText = ((double)d.Content).ToString("F2");
             }
         }
     });
 }
 public StockInfoViewModel(StockAgent stockAgent, IDialogService dialogService)
 {
     _stockAgent      = stockAgent;
     _dialogService   = dialogService;
     _updateStockInfo = Update();
     Messenger.Default.Register <GenericMessage <int> >(this, UpdateCurrentStockInfoToken, i => UpdateCurrentStockInfo(i.Content));
 }
 public StockDepthInfoViewModel(StockAgent stockAgent, IDialogService dialogService, StockInfoViewModel stockInfoViewModel)
 {
     _stockAgent         = stockAgent;
     _dialogService      = dialogService;
     _stockInfoViewModel = stockInfoViewModel;
     Messenger.Default.Register <GenericMessage <bool> >(this, UpdateStockDepthInfo, b =>
     {
         lock (this)
         {
             if (b.Content && (_updateBuyStockDepthInfo == null || _updateSellStockDepthInfo == null))
             {
                 _cts = new CancellationTokenSource();
                 _updateBuyStockDepthInfo  = UpdateBuy(_cts.Token);
                 _updateSellStockDepthInfo = UpdateSell(_cts.Token);
             }
             else if (!b.Content && _cts != null && (_updateBuyStockDepthInfo != null || _updateSellStockDepthInfo != null))
             {
                 _cts.Cancel();
                 _updateBuyStockDepthInfo  = null;
                 _updateSellStockDepthInfo = null;
                 BuyStockDepthInfoList.Clear();
                 SellStockDepthInfoList.Clear();
             }
         }
     });
 }
Exemplo n.º 5
0
 public AccountViewModel(UserStockInfoViewModel userStockInfoViewModel, StockAgent stockAgent, IDialogService dialogService)
 {
     _userStockInfoViewModel = userStockInfoViewModel;
     _stockAgent             = stockAgent;
     _dialogService          = dialogService;
     Messenger.Default.Register <GenericMessage <int?> >(this, UpdateCurrentUserStockInfoToken, i => UpdateCurrentUserStockInfo(i.Content));
 }
 public SettingsViewModel(StockAgent stockAgent, IDialogService dialogService, MainWindowModel mainWindowModel)
 {
     _stockAgent      = stockAgent;
     _dialogService   = dialogService;
     _mainWindowModel = mainWindowModel;
     RValue           = Convert.ToDouble(_mainWindowModel.ThemeBrush.Color.R);
     GValue           = Convert.ToDouble(_mainWindowModel.ThemeBrush.Color.G);
     BValue           = Convert.ToDouble(_mainWindowModel.ThemeBrush.Color.B);
 }
 public UserStockInfoViewModel(StockAgent stockAgent, IDialogService dialogService, StockInfoViewModel stockInfoViewModel)
 {
     _stockAgent         = stockAgent;
     _dialogService      = dialogService;
     _stockInfoViewModel = stockInfoViewModel;
     Messenger.Default.Register <GenericMessage <bool> >(this, UpdateUserStockInfo, b =>
     {
         lock (this)
         {
             if (b.Content && _updateUserStockInfo == null)
             {
                 _cts = new CancellationTokenSource();
                 _updateUserStockInfo = Update(_cts.Token);
             }
             else if (!b.Content && _cts != null && _updateUserStockInfo != null)
             {
                 _cts.Cancel();
                 _updateUserStockInfo = null;
             }
         }
     });
 }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            TradingBotContext ctx = new TradingBotContext();

            Console.WriteLine(string.Format("Trading bot started at {0}", DateTime.Now));

            //check cash status, if first time loaded give us 1000
            var cashman = new CashManager(ctx);

            //get today's top movers
            var topmovers = new TopMovers(ctx);

            //buy what we can from the top movers.
            var stockAgent      = new StockAgent(ctx);
            var ownedstockAgent = new OwnedStockAgent(ctx);


            //Sell any left over stocks. - recalc to ensure we don't sell any false stock numbers
            ownedstockAgent.BuildPortfolioFromTransactions();
            stockAgent.SellOldStocks();

            stockAgent.PurchaseNewMovers(cashman.AvailableBalanace());
        }
 public AccountButtonViewModel(MainWindowModel mainWindowModel, StockAgent stockAgent, IDialogService dialogService, UserMoneyInfo userMoneyInfo, IFrameNavigationService frameNavigationService)
 {
     _mainWindowModel        = mainWindowModel;
     _stockAgent             = stockAgent;
     _dialogService          = dialogService;
     _userMoneyInfo          = userMoneyInfo;
     _frameNavigationService = frameNavigationService;
     Messenger.Default.Register <GenericMessage <bool> >(this, UpdateUserMoneyInfo, b =>
     {
         lock (this)
         {
             if (b.Content && _updateUserMoneyInfo == null)
             {
                 _cts = new CancellationTokenSource();
                 _updateUserMoneyInfo = Update(_cts.Token);
             }
             else if (!b.Content && _cts != null && _updateUserMoneyInfo != null)
             {
                 _cts.Cancel();
                 _updateUserMoneyInfo = null;
             }
         }
     });
 }
Exemplo n.º 10
0
 public RegisterViewModel(IDialogService dialogService, StockAgent stockAgent, MainWindowModel mainWindowModel)
 {
     _dialogService   = dialogService;
     _stockAgent      = stockAgent;
     _mainWindowModel = mainWindowModel;
 }