public ReporterPokeUnit Clone() {
			ReporterPokeUnit ret = new ReporterPokeUnit(this.QuoteGeneratedThisUnit);
			ret.AlertsNew = new List<Alert>(this.AlertsNew);
			ret.PositionsOpened = new List<Position>(this.PositionsOpened);
			ret.PositionsClosed = new List<Position>(this.PositionsClosed);
			return ret;
		}
		public void BuildStatsOnBacktestFinished(List<Position> positionsMaster) {
			//// Dictionary<U,V> has no .AsReadonly() (List<T> has it)
			//var positionsMasterByEntryBarSafeCopy = this.Executor.ExecutionDataSnapshot.PositionsMasterByEntryBar;
			//var positionsMasterByExitBarSafeCopy = this.Executor.ExecutionDataSnapshot.PositionsMasterByExitBar;

			//this.DEBUGGING_PositionsMaster = positionsMaster;
			//this.DEBUGGING_PositionsMasterByEntryBarSafeCopy = positionsMasterByEntryBarSafeCopy;
			//this.DEBUGGING_PositionsMasterByExitBarSafeCopy = positionsMasterByExitBarSafeCopy; 
			
			//this.SliceLong.BuildStatsOnBacktestFinished(positionsMasterByEntryBarSafeCopy, positionsMasterByExitBarSafeCopy);
			//this.SliceShort.BuildStatsOnBacktestFinished(positionsMasterByEntryBarSafeCopy, positionsMasterByExitBarSafeCopy);
			//this.SlicesShortAndLong.BuildStatsOnBacktestFinished(positionsMasterByEntryBarSafeCopy, positionsMasterByExitBarSafeCopy);
			//this.SliceBuyHold.BuildStatsOnBacktestFinished(positionsMasterByEntryBarSafeCopy, positionsMasterByExitBarSafeCopy);

			ReporterPokeUnit pokeUnit = new ReporterPokeUnit(null);

			List<Position> positionsClosed = new List<Position>(this.Executor.ExecutionDataSnapshot.PositionsMaster);
			foreach (Position posOpen in this.Executor.ExecutionDataSnapshot.PositionsOpenNow) {
				if (positionsClosed.Contains(posOpen) == false) {
#if DEBUG
					Debugger.Break();
#endif
					continue;
				}
				positionsClosed.Remove(posOpen);
			}
			pokeUnit.PositionsOpened = this.Executor.ExecutionDataSnapshot.PositionsOpenNow;
			pokeUnit.PositionsClosed = positionsClosed;
			this.BuildStatsIncrementallyOnEachBarExecFinished(pokeUnit);
		}
		public int InvokeOnceHooksForOrderStateAndDelete(Order order, ReporterPokeUnit pokeUnit) {
			int hooksInvoked = 0;
			lock (this.hooksLock) {
				foreach (OrderPostProcessorStateHook hook in this.hooks) {
					string msg = "processing hook [" + hook + "] ";
					if (hook.InvokedThusCanBeDeleted) continue;
					if (hook.Order != order) continue;
					if (hook.OrderState != order.State) continue;

					hook.CurrentlyExecuting = true;
					hook.Delegate(order, pokeUnit);
					hook.CurrentlyExecuting = false;
					hook.InvokedThusCanBeDeleted = true;
					msg += " ... done";

					hooksInvoked++;
				}
				int hooksRemoved = this.RemoveAllInvoked();
				if (hooksRemoved != hooksInvoked) {
					string msg = "hooksRemoved[" + hooksRemoved + "] != hooksInvoked[" + hooksInvoked + "]; I don't wanna be stuck on threading issues...";
					throw new Exception(msg);
				}
			}
			return hooksInvoked;
		}
		public void BuildStatsIncrementallyOnEachBarExecFinished(ReporterPokeUnit pokeUnit) {
			Dictionary<int, List<Position>> posByEntry = pokeUnit.PositionsOpenedByBarFilled;
			Dictionary<int, List<Position>> posByExit = pokeUnit.PositionsClosedByBarFilled;
			int absorbedLong	= this.SliceLong.BuildStatsIncrementallyOnEachBarExecFinished(posByEntry, posByExit);
			int absorbedShort	= this.SliceShort.BuildStatsIncrementallyOnEachBarExecFinished(posByEntry, posByExit);
			int absorbedBoth	= this.SlicesShortAndLong.BuildStatsIncrementallyOnEachBarExecFinished(posByEntry, posByExit);
			int absorbedBH	= this.SliceBuyHold.BuildStatsIncrementallyOnEachBarExecFinished(posByEntry, posByExit);
		}
Ejemplo n.º 5
0
        public ReporterPokeUnit Clone()
        {
            ReporterPokeUnit ret = new ReporterPokeUnit(this.QuoteGeneratedThisUnit);

            ret.AlertsNew       = new List <Alert>(this.AlertsNew);
            ret.PositionsOpened = new List <Position>(this.PositionsOpened);
            ret.PositionsClosed = new List <Position>(this.PositionsClosed);
            return(ret);
        }
		public void PositionArrowsRealtimeAdd(ReporterPokeUnit pokeUnit) {
			this.PositionArrowsBacktestAdd(pokeUnit.PositionsOpened);
			this.PositionArrowsBacktestAdd(pokeUnit.PositionsClosed);
//		NO_NEED_TO_CACHE_OPENING_ALERT_BITMAP_FOR_JUST_CLOSED_POSITIONS AlertArrow.Bitmap is dynamic for EntryAlerts until the position is closed;
//			foreach (AlertArrow eachNewClosed in pokeUnit.PositionsClosed) {
//				if (this.AlertArrowsListByBar.ContainsKey[eachNewClosed.EntryBarIndex] == false) {
//					
//				}
//				List<AlertArrow> alertArrowsSameBarEntry = this.AlertArrowsListByBar[eachNewClosed.EntryBarIndex];
//				foreach (AlertArrow eachArrowToResetBitmap in alertArrowsSameBarEntry) {
//					if (eachArrowToResetBitmap.AlertArrow != eachNewClosed) return;
//					eachArrowToResetBitmap.BitmapResetDueToPositionClose;
//				}
//			}
		}
		public void PositionsRealtimeAdd(ReporterPokeUnit pokeUnit) {
			if (pokeUnit.PositionsOpened != null && pokeUnit.PositionsOpened.Count > 0) {
				lock (lockPositionsOpened) {
					if (this.PositionsOpenedCloneCanBeZeriofiedAfterPickup == null) this.PositionsOpenedCloneCanBeZeriofiedAfterPickup = new List<Position>();
					foreach (Position eachNewOpened in pokeUnit.PositionsOpened) {
						if (this.PositionsOpenedCloneCanBeZeriofiedAfterPickup.Contains(eachNewOpened)) continue;
						this.PositionsOpenedCloneCanBeZeriofiedAfterPickup.Add(eachNewOpened);
					}
				}
			}
			if (pokeUnit.PositionsClosed != null && pokeUnit.PositionsClosed.Count > 0) {
				lock (lockPositionsClosed) {
					if (this.PositionsClosedCloneCanBeZeriofiedAfterPickup == null) this.PositionsClosedCloneCanBeZeriofiedAfterPickup = new List<Position>();
					foreach (Position eachNewClosed in pokeUnit.PositionsClosed) {
						if (this.PositionsClosedCloneCanBeZeriofiedAfterPickup.Contains(eachNewClosed)) continue;
						this.PositionsClosedCloneCanBeZeriofiedAfterPickup.Add(eachNewClosed);
					}
				}
			}
		}
		public override void PendingRealtimeAdd(ReporterPokeUnit pokeUnit) {
			this.ScriptExecutorObjects.PendingRealtimeAdd(pokeUnit);
		}
		public override void PositionsRealtimeAdd(ReporterPokeUnit pokeUnit) {
			this.ScriptExecutorObjects.PositionArrowsRealtimeAdd(pokeUnit);
		}
		public void InvokeHooksAndSubmitNewAlertsBackToBrokerProvider(Order orderWithNewState) {
			ScriptExecutor executor = orderWithNewState.Alert.Strategy.Script.Executor;
			ReporterPokeUnit afterHooksInvokedPokeUnit = new ReporterPokeUnit(null);
			int hooksInvoked = this.OPPstatusCallbacks.InvokeOnceHooksForOrderStateAndDelete(orderWithNewState, afterHooksInvokedPokeUnit);
			if (executor.Backtester.IsBacktestingNow) return;

			List<Alert> alertsCreatedByHooks = afterHooksInvokedPokeUnit.AlertsNew;
			if (alertsCreatedByHooks.Count == 0) {
				string msg = "NOT_AN_ERROR: ZERO alerts from [" + hooksInvoked + "] hooks invoked; order[" + orderWithNewState + "]";
				//this.PopupException(new Exception(msg));
				return;
			}
			bool setStatusSubmitting = executor.IsStreaming && executor.IsAutoSubmitting;
			this.CreateOrdersSubmitToBrokerProviderInNewThreadGroups(alertsCreatedByHooks, setStatusSubmitting, true);
			orderWithNewState.Alert.Strategy.Script.Executor.PushPositionsOpenedClosedToReportersAsyncUnsafe(afterHooksInvokedPokeUnit);
		}
		public void OnTakeProfitKilledCreateNewTakeProfitAndAddToPokeUnit(Order killedTakeProfit, double newTakeProfitPositiveOffset, ReporterPokeUnit pokeUnit) {
			string msig = "OnTakeProfitKilledCreateNewTakeProfitAndAddToPokeUnit(): ";
			ScriptExecutor executor = killedTakeProfit.Alert.Strategy.Script.Executor;
			Position position = killedTakeProfit.Alert.PositionAffected;
			// resetting proto.SL to NULL is a legal permission to set new TakeProfitAlert for SellOrCoverRegisterAlerts()
			position.Prototype.TakeProfitAlertForAnnihilation = null;
			// resetting position.ExitAlert is a legal permission to for SimulateRealtimeOrderFill() to not to throw "I refuse to tryFill an ExitOrder"
			position.ExitAlert = null;
			// set new SL+SLa as new targets for Activator
			string msg = position.Prototype.ToString();
			position.Prototype.SetNewTakeProfitOffset(newTakeProfitPositiveOffset);
			msg += " => " + position.Prototype.ToString();
			Alert replacement = executor.PositionPrototypeActivator.CreateTakeProfitFromPositionPrototype(position);
			// dont CreateAndSubmit, pokeUnit will be submitted with oneNewAlertPerState in InvokeHooksAndSubmitNewAlertsBackToBrokerProvider();
			//this.CreateOrdersSubmitToBrokerProviderInNewThreadGroups(new List<Alert>() { replacement }, true, true);
			pokeUnit.AlertsNew.Add(replacement);
			msg += " newAlert[" + replacement + "]";
			killedTakeProfit.AppendMessage(msig + msg);
		}
Ejemplo n.º 12
0
		public override void BuildIncrementalAfterPositionsChangedInRealTime(ReporterPokeUnit pokeUnit) {
		}
		public ReporterPokeUnit ExecuteOnNewBarOrNewQuote(Quote quote) {
			if (this.Strategy.Script == null) return null;
			ReporterPokeUnit pokeUnit = new ReporterPokeUnit(quote);
			this.ExecutionDataSnapshot.PreExecutionClear();
			int alertsDumpedForStreamingBar = -1;

			if (quote != null) {
				try {
					this.Strategy.Script.OnNewQuoteOfStreamingBarCallback(quote);
					//alertsDumpedForStreamingBar = this.ExecutionDataSnapshot.DumpPendingAlertsIntoPendingHistoryByBar();
					//if (alertsDumpedForStreamingBar > 0) {
					//	string msg = "ITS OK HERE since prev quote has created prototype-based alerts"
					//		+ "I WANT DUMP TO BE VALID ONLY IN onNewBar case only!!!"
					//		+ " " + alertsDumpedForStreamingBar + " alerts Dumped for " + quote;
					//}
				} catch (Exception ex) {
					string msig = " Script[" + this.Strategy.Script.GetType().Name + "].OnNewQuoteCallback(" + quote + "): ";
					this.PopupException(ex.Message + msig, ex);
				}
			} else {
				try {
					this.Strategy.Script.OnBarStaticLastFormedWhileStreamingBarWithOneQuoteAlreadyAppendedCallback(this.Bars.BarStaticLast);
				} catch (Exception ex) {
					string msig = " Script[" + this.Strategy.Script.GetType().Name + "].OnNewBarCallback(" + quote + "): ";
					this.PopupException(ex.Message + msig, ex);
				}
			}
			string msg = "DONT_REMOVE_ALERT_SHOULD_LEAVE_ITS_TRAIL_DURING_LIFETIME_TO_PUT_UNFILLED_DOTS_ON_CHART";
			alertsDumpedForStreamingBar = this.ExecutionDataSnapshot.DumpPendingAlertsIntoPendingHistoryByBar();
			if (alertsDumpedForStreamingBar > 0) {
				msg += " DUMPED_AFTER_SCRIPT_EXECUTION_ON_NEW_BAR_OR_QUOTE";
			}


			// what's updated after Exec: non-volatile, kept un-reset until executor.Initialize():
			//this.ExecutionDataSnapshot.PositionsMasterByEntryBar (unique)
			//this.ExecutionDataSnapshot.PositionsMaster
			//this.PositionsOnlyActive
			//this.AlertsMaster
			//this.AlertsNewAfterExec

			// what's new for this iteration: volatile, cleared before next Exec):
			//this.AlertsNewAfterExec
			//this.ExecutionDataSnapshot.PositionsOpenedAfterExec
			//this.ExecutionDataSnapshot.PositionsClosedAfterExec

			bool willPlace = this.Backtester.IsBacktestingNow == false && this.OrderProcessor != null && this.IsAutoSubmitting;
			bool setStatusSubmitting = this.IsStreaming && this.IsAutoSubmitting;

			List<Alert> alertsNewAfterExecCopy = this.ExecutionDataSnapshot.AlertsNewAfterExecSafeCopy;
			if (alertsNewAfterExecCopy.Count > 0) {
				this.enrichAlertsWithQuoteCreated(alertsNewAfterExecCopy, quote);
				if (willPlace) {
					this.OrderProcessor.CreateOrdersSubmitToBrokerProviderInNewThreadGroups(alertsNewAfterExecCopy, setStatusSubmitting, true);
				}
			}

			if (this.Backtester.IsBacktestingNow && this.Backtester.WasBacktestAborted) return null;

			pokeUnit.AlertsNew = alertsNewAfterExecCopy;
			pokeUnit.PositionsOpened = this.ExecutionDataSnapshot.PositionsOpenedAfterExecSafeCopy;
			pokeUnit.PositionsClosed = this.ExecutionDataSnapshot.PositionsClosedAfterExecSafeCopy;
			return pokeUnit;
		}
Ejemplo n.º 14
0
		public virtual void PendingRealtimeAdd(ReporterPokeUnit pokeUnit) {
			throw new NotImplementedException();
		}
Ejemplo n.º 15
0
		public virtual void BuildIncrementalAfterPositionsChangedInRealTime(ReporterPokeUnit pokeUnit) {
			string msg = "DERIVED_REPORTERS_MUST_IMPLEMENT BuildIncrementalAfterPositionsChangedInRealTime(ReporterPokeUnit)" + this.TabText + "/" + this.GetType();
			throw new NotImplementedException(msg);
		}
		void clonePositionsForChartPickupRealtime(ReporterPokeUnit pokeUnit) {
			this.registerAnyAlertForReporterClickedToChartSpotted(pokeUnit.PositionsOpenedClosedMergedTogether);
			this.ChartShadow.PositionsRealtimeAdd(pokeUnit.Clone());
		}
		public void CallbackAlertFilledMoveAroundInvokeScript(Alert alertFilled, Quote quote,
					 int barFillRelno, double priceFill, double qtyFill, double slippageFill, double commissionFill) {
			string msig = " CallbackAlertFilledMoveAroundInvokeScript(" + alertFilled + ", " + quote + ")";
			List<Alert> alertsNewAfterAlertFilled = new List<Alert>();
			List<Position> positionsOpenedAfterAlertFilled = new List<Position>();
			List<Position> positionsClosedAfterAlertFilled = new List<Position>();

			//"Excuse me, what bar is it now?" I'm just guessing! does BrokerProvider knows to pass Bar here?...
			Bar barFill = (this.IsStreaming) ? alertFilled.Bars.BarStreamingCloneReadonly : alertFilled.Bars.BarStaticLast;
			if (barFillRelno != barFill.ParentBarsIndex) {
				string msg = "barFillRelno[" + barFillRelno + "] != barFill.ParentBarsIndex["
					+ barFill.ParentBarsIndex + "]; barFill=[" + barFill + "]";
				Assembler.PopupException(msg);
			}
			if (priceFill == -1) {
				string msg = "won't set priceFill=-1 for alert [" + alertFilled + "]";
				throw new Exception(msg);
			}
			if (alertFilled.PositionAffected == null) {
				string msg = "CallbackAlertFilled can't do its job: alert.PositionAffected=null for alert [" + alertFilled + "]";
				throw new Exception(msg);
			}
			if (alertFilled.IsEntryAlert) {
				if (alertFilled.PositionAffected.EntryFilledBarIndex != -1) {
					string msg = "DUPE: CallbackAlertFilled can't do its job: alert.PositionAffected.EntryBar!=-1 for alert [" + alertFilled + "]";
					throw new Exception(msg);
				} else {
					string msg = "initializing EntryBar=[" + barFill + "] on AlertFilled";
				}
			} else {
				if (alertFilled.PositionAffected.ExitFilledBarIndex != -1) {
					string msg = "DUPE: CallbackAlertFilled can't do its job: alert.PositionAffected.ExitBar!=-1 for alert [" + alertFilled + "]";
					throw new Exception(msg);
					return;
				} else {
					string msg = "initializing ExitBar=[" + barFill + "] on AlertFilled";
				}
			}

			if (quote == null) {
				quote = this.DataSource.StreamingProvider.StreamingDataSnapshot.LastQuoteGetForSymbol(alertFilled.Symbol);
				// TODO: here quote will have NO_PARENT_BARS, since StreamingDataSnapshot contains anonymous quote;
				// I should keep per-timeframe / per-distributionChannel LastQuote to have ParentBar= different StreamingBar 's
				// bindStreamingBarForQuoteAndPushQuoteToConsumers(quoteSernoEnrichedWithUnboundStreamingBar.Clone());
			}
			alertFilled.QuoteLastWhenThisAlertFilled = quote;
			try {
				alertFilled.FillPositionAffectedEntryOrExitRespectively(barFill, barFillRelno, priceFill, qtyFill, slippageFill, commissionFill);
			} catch (Exception ex) {
				string msg = "REMOVE_FILLED_FROM_PENDING? DONT_USE_Bar.ContainsPrice()?";
				Assembler.PopupException(msg + msig, ex);
				//Debugger.Break();
			}
			bool removed = this.ExecutionDataSnapshot.AlertsPendingRemove(alertFilled);
			if (removed == false) {
				Debugger.Break();
			}
			if (alertFilled.IsEntryAlert) {
				// position has its parent alert in Position.ctor()
				//// REFACTORED_POSITION_HAS_AN_ALERT_AFTER_ALERTS_CONSTRUCTOR
				//alert.PositionAffected.EntryCopyFromAlert(alert);
				this.ExecutionDataSnapshot.PositionsMasterOpenNewAdd(alertFilled.PositionAffected);
				positionsOpenedAfterAlertFilled.Add(alertFilled.PositionAffected);
			} else {
				//// REFACTORED_POSITION_HAS_AN_ALERT_AFTER_ALERTS_CONSTRUCTOR we can exit by TP or SL - position doesn't have an ExitAlert assigned until Alert was filled!!!
				//alertFilled.PositionAffected.ExitAlertAttach(alertFilled);
				this.ExecutionDataSnapshot.MovePositionOpenToClosed(alertFilled.PositionAffected);
				positionsClosedAfterAlertFilled.Add(alertFilled.PositionAffected);
			}

			bool willPlace = this.Backtester.IsBacktestingNow == false && this.OrderProcessor != null && this.IsAutoSubmitting;
			bool setStatusSubmitting = this.IsStreaming && this.IsAutoSubmitting;

			PositionPrototype proto = alertFilled.PositionAffected.Prototype;
			if (proto != null) {
				// 0. once again, set ExitAlert to What was actually filled, because prototypeEntry created SL & TP, which were both written into ExitAlert;
				// so if we caught the Loss and SL was executed, position.ExitAlert will still contain TP if we don't set it here
				bool exitIsDifferent = alertFilled.PositionAffected.ExitAlert != null && alertFilled.PositionAffected.ExitAlert != alertFilled;
				if (alertFilled.IsExitAlert && exitIsDifferent) {
					alertFilled.PositionAffected.ExitAlertAttach(alertFilled);
				}
				// 1. alert.PositionAffected.Prototype.StopLossAlertForAnnihilation and TP will get assigned
				alertsNewAfterAlertFilled = this.PositionPrototypeActivator.AlertFilledCreateSlTpOrAnnihilateCounterparty(alertFilled);
				// quick check: there must be {SL+TP} OR Annihilator
				//this.BacktesterFacade.IsBacktestingNow == false &&
				if (alertFilled.IsEntryAlert) {
					if (proto.StopLossAlertForAnnihilation == null) {
						string msg = "NONSENSE@Entry: proto.StopLossAlert is NULL???..";
						throw new Exception(msg);
					}
					if (proto.TakeProfitAlertForAnnihilation == null) {
						string msg = "NONSENSE@Entry: proto.TakeProfitAlert is NULL???..";
						throw new Exception(msg);
					}
					if (alertsNewAfterAlertFilled.Count == 0) {
						string msg = "NONSENSE@Entry: alertsNewSlAndTp.Count=0"
							+ "; this.PositionPrototypeActivator.AlertFilledCreateSlTpOrAnnihilateCounterparty(alertFilled)"
							+ " should return 2 alerts; I don't want to create new list from {proto.SL, proto.TP}";
						throw new Exception(msg);
					}
				}
				if (alertFilled.IsExitAlert) {
					if (alertsNewAfterAlertFilled.Count > 0) {
						string msg = "NONSENSE@Exit: there must be no alerts (got " + alertsNewAfterAlertFilled.Count + "): killer works silently";
						throw new Exception(msg);
					}
				}

				if (alertsNewAfterAlertFilled.Count > 0 && willPlace) {
					this.OrderProcessor.CreateOrdersSubmitToBrokerProviderInNewThreadGroups(alertsNewAfterAlertFilled, setStatusSubmitting, true);

					// 3. Script using proto might move SL and TP which require ORDERS to be moved, not NULLs
					int twoMinutes = 120000;
					if (alertFilled.IsEntryAlert) {
						// there must be SL.OrderFollowed!=null and TP.OrderFollowed!=null
						if (proto.StopLossAlertForAnnihilation.OrderFollowed == null) {
							string msg = "StopLossAlert.OrderFollowed is NULL!!! engaging ManualResetEvent.WaitOne()";
							this.PopupException(msg);
							Stopwatch waitedForStopLossOrder = new Stopwatch();
							waitedForStopLossOrder.Start();
							proto.StopLossAlertForAnnihilation.MreOrderFollowedIsNotNull.WaitOne(twoMinutes);
							waitedForStopLossOrder.Stop();
							msg = "waited " + waitedForStopLossOrder.ElapsedMilliseconds + "ms for StopLossAlert.OrderFollowed";
							if (proto.StopLossAlertForAnnihilation.OrderFollowed == null) {
								msg += ": NO_SUCCESS still null!!!";
								this.PopupException(msg);
							} else {
								proto.StopLossAlertForAnnihilation.OrderFollowed.AppendMessage(msg);
								this.PopupException(msg);
							}
						} else {
							string msg = "you are definitely crazy, StopLossAlert.OrderFollowed is a single-threaded assignment";
							//this.ThrowPopup(new Exception(msg));
						}

						if (proto.TakeProfitAlertForAnnihilation.OrderFollowed == null) {
							string msg = "TakeProfitAlert.OrderFollowed is NULL!!! engaging ManualResetEvent.WaitOne()";
							this.PopupException(msg);
							Stopwatch waitedForTakeProfitOrder = new Stopwatch();
							waitedForTakeProfitOrder.Start();
							proto.TakeProfitAlertForAnnihilation.MreOrderFollowedIsNotNull.WaitOne();
							waitedForTakeProfitOrder.Stop();
							msg = "waited " + waitedForTakeProfitOrder.ElapsedMilliseconds + "ms for TakeProfitAlert.OrderFollowed";
							if (proto.TakeProfitAlertForAnnihilation.OrderFollowed == null) {
								msg += ": NO_SUCCESS still null!!!";
								this.PopupException(msg);
							} else {
								proto.TakeProfitAlertForAnnihilation.OrderFollowed.AppendMessage(msg);
								this.PopupException(msg);
							}
						} else {
							string msg = "you are definitely crazy, TakeProfitAlert.OrderFollowed is a single-threaded assignment";
							//this.ThrowPopup(new Exception(msg));
						}
					}
				}
			}

			if (this.Backtester.IsBacktestingNow == false) {
				ReporterPokeUnit pokeUnit = new ReporterPokeUnit(quote);
				pokeUnit.AlertsNew = alertsNewAfterAlertFilled;
				pokeUnit.PositionsOpened = positionsOpenedAfterAlertFilled;
				pokeUnit.PositionsClosed = positionsClosedAfterAlertFilled;
				this.PushPositionsOpenedClosedToReportersAsyncUnsafe(pokeUnit);
			}

			// 4. Script event will generate a StopLossMove PostponedHook
			this.invokeScriptEvents(alertFilled);

			// reasons for (alertsNewAfterExec.Count > 0) include:
			// 2.1. PrototypeActivator::AlertFilledPlaceSlTpOrAnnihilateCounterparty
			// 2.2. Script.OnAlertFilledCallback(alert)
			// 2.3. Script.OnPositionOpenedPrototypeSlTpPlacedCallback(alert.PositionAffected)
			// 2.4. Script.OnPositionClosedCallback(alert.PositionAffected)
		}
		//DateTime lastTimeReportersPoked = DateTime.MinValue;
		public void PushPositionsOpenedClosedToReportersAsyncUnsafe(ReporterPokeUnit pokeUnit) {
			// EMPTY_AFTEREXEC check#1
			if (pokeUnit.PositionsChanged == 0) return;

			this.clonePositionsForChartPickupRealtime(pokeUnit);
			this.Performance.BuildStatsIncrementallyOnEachBarExecFinished(pokeUnit);
		}
Ejemplo n.º 19
0
 public ReporterPokeUnitEventArgs(ReporterPokeUnit pokeUnit)
 {
     // TODO: Complete member initialization
     this.PokeUnit = pokeUnit;
 }
		public ReporterPokeUnitEventArgs(ReporterPokeUnit pokeUnit) {
			// TODO: Complete member initialization
			this.PokeUnit = pokeUnit;
		}
Ejemplo n.º 21
0
		public override void BuildIncrementalAfterPositionsChangedInRealTime(ReporterPokeUnit pokeUnit) {
			Debugger.Break();
			this.reversePositionsCalcCumulativesDumpToTitleAndOLV();
		}
		public void PendingRealtimeAdd(ReporterPokeUnit pokeUnit) {
			Debugger.Break();	//should I NOT assign this.AlertsPendingHistorySafeCopy=alertsPendingHistorySafeCopy;?
			if (null == pokeUnit.QuoteGeneratedThisUnit) {
				Debugger.Break();
				return;
			}
			if (null == pokeUnit.QuoteGeneratedThisUnit.ParentStreamingBar) {
				Debugger.Break();
				return;
			}
			int barIndex = pokeUnit.QuoteGeneratedThisUnit.ParentStreamingBar.ParentBarsIndex;
			this.AlertsPendingHistorySafeCopy.Add(barIndex, pokeUnit.AlertsNew);
		}