Ejemplo n.º 1
0
        public TradeConsole()
        {
            InitializeComponent();

            _alertManager = new AlertManager();
            _alertManager.ThrowEvent += (sender, args) => OnAlertEvent(args);

            var repo = new Store();

            AllInstruments.SetInstruments(repo.GetInstruments());

            var alerts = repo.GetOpenAlerts();

            foreach (var alert in alerts)
            {
                var instrument = AllInstruments.GetInstrument(alert.Instrument.Market, alert.Instrument.Symbol);

                if (instrument == null)
                    continue;

                Alert a = new Alert
                {
                    AlertID = alert.AlertID,
                    Instrument = instrument,
                    Finished = alert.DateClosed != null,
                    OpeningDate = alert.DateOpened,
                    PriceTarget = alert.PriceTarget,
                    TargetDirection = alert.TargetDirection
                };

                _alertManager.AddAlert(a);
            }

            EnumeratePlans();

            _tickPunker = new TickPunker();
            _tickPunker.ReceivedTick += new ReceivedTickEventHandler(GotTick);
            _tickPunker.StartWatcher();

            AddTextOutput("Started");
        }
Ejemplo n.º 2
0
        private void AddToStore(Alert alert)
        {
            var repo = new Store();

            repo.AddAlert(alert);
        }
Ejemplo n.º 3
0
        private void Persist()
        {
            if (DateTime.UtcNow < _nextPersist)
                return;

            AddTextOutput("Persist");

            // Put 1 minute between persists
            _nextPersist = DateTime.UtcNow.AddMinutes(1);

            var repo = new Store();

            foreach (var alert in _alertManager.Alerts())
                repo.UpdateAlert(alert);

            repo.SaveChanges();
        }