Beispiel #1
0
        // replaced to AlertsMasterNewPendingAddEnriched:AlertsPendingHistoryByBarAddNoDupe()
        // but still used in ExecuteOnNewBarOrNewQuote() to dump old pending Stops/Limits
        // if the stop/limit wasn't filled on the prev bar and stays in pending,
        // I want a DOT on the chart for every bar while this alert was still pending/valid/onMarket
        public int DumpPendingAlertsIntoPendingHistoryByBar()
        {
            int alertsDumpedForStreamingBar = 0;

            //lock (this.AlertsPendingLock) {
            if (this.AlertsPending.Count == 2)
            {
                string msg = "LOOKS_LIKE_TP_AND_SL; CATCHING WHY SL ISNT SHOWN ON THE CHART - IS IT DUMPED?";
            }
            foreach (Alert alert in this.AlertsPending)
            {
                ByBarDumpStatus dumped = this.AlertsPendingHistoryByBarAddNoDupe(alert);
                switch (dumped)
                {
                case ByBarDumpStatus.BarAlreadyContainedTheAlertToAdd:
                    string msg1 = "ALERT_PREVIOUSLY_DUMPED_TO_HISTORY; DUPE while adding JUST CREATED alert[" + alert + "]";
                    //Debugger.Break();
                    //throw new Exception(msg1);
                    break;

                case ByBarDumpStatus.OneNewAlertAddedForNewBarInHistory:
                    alertsDumpedForStreamingBar++;
                    break;

                case ByBarDumpStatus.SequentialAlertAddedForExistingBarInHistory:
                    alertsDumpedForStreamingBar++;
                    string msg2 = "Here is the case when PrototypeActivator changed alert[" + alert + "]";
                    break;
                }
            }
            //}
            return(alertsDumpedForStreamingBar);
        }
Beispiel #2
0
        public void AlertEnrichedRegister(Alert alert, bool registerInNewAfterExec = false)
        {
            if (alert.Qty == 0.0)
            {
                string msg = "alert[" + alert + "].Qty==0; hopefully will be displayed but not executed...";
                throw new Exception(msg);
                //log.Warn(msg);
            }
            if (alert.Strategy.Script == null)
            {
                int a = 1;                      //ok if submitted from mni
            }
            lock (alertsMasterLock) {
                if (this.AlertsMasterContainsIdentical(alert))
                {
                    string msg = "AlertsMasterContainsIdentical=>won't add NewPending;"
                                 + " 1) broker's order status dupe? 2) are you using CoverAtStop() in your strategy?"
                                 + " //" + alert;
                    this.executor.PopupException(msg);
                    return;
                }
                this.AlertsMaster.Add(alert);
                if (registerInNewAfterExec == true)
                {
                    this.AlertsNewAfterExec.Add(alert);
                }
                this.AlertsPendingAdd(alert);

                ByBarDumpStatus dumped = this.AlertsPendingHistoryByBarAddNoDupe(alert);
                switch (dumped)
                {
                case ByBarDumpStatus.BarAlreadyContainedTheAlertToAdd:
                    string msg1 = "DUPE while adding JUST CREATED??? alert[" + alert + "]";
                    throw new Exception(msg1);
                    break;

                case ByBarDumpStatus.SequentialAlertAddedForExistingBarInHistory:
                    string msg2 = "Here is the case when PrototypeActivator changed alert[" + alert + "]";
                    break;
                }
            }
        }