Пример #1
0
        public void ScriptContextRename(ContextScript scriptContextToRename, string scriptContextNewName)
        {
            if (scriptContextToRename.Name == scriptContextNewName)
            {
                string msg = "WONT_RENAME_TO_SAME_NAME scriptContextNewName[" + scriptContextNewName + "]=scriptContextToRename.Name[" + scriptContextToRename.Name + "], type another name";
                Assembler.InstanceInitialized.StatusReporter.DisplayStatus(msg);
                return;
                //e.Cancel = true;
            }
            if (this.ScriptContextsByName.ContainsKey(scriptContextNewName))
            {
                string msg = "CANT_RENAME_NAME_ALREADY_EXISTS scriptContextNewName[" + scriptContextNewName + "] already exists for strategy[" + this + "]";
                Assembler.InstanceInitialized.StatusReporter.DisplayStatus(msg);
                return;
                //e.Cancel = true;
            }
            string oldName = scriptContextToRename.Name;

            this.ScriptContextsByName.Remove(oldName);
            scriptContextToRename.Name = scriptContextNewName;
            this.ScriptContextsByName.Add(scriptContextNewName, scriptContextToRename);
            if (this.ScriptContextCurrentName == oldName)
            {
                this.ScriptContextCurrentName = scriptContextNewName;
            }

            Assembler.InstanceInitialized.RepositoryDllJsonStrategy.StrategySave(this);
            string msg2 = "scriptContextName[" + oldName + "]=>[" + scriptContextNewName + "] for strategy[" + this + "]";

            Assembler.InstanceInitialized.StatusReporter.DisplayStatus(msg2);
        }
Пример #2
0
        public void AbsorbFrom(ContextScript found, bool absorbParams = false)
        {
            if (found == null)
            {
                return;
            }
            //KEEP_CLONE_UNDEFINED this.Name = found.Name;
//			this.Symbol = found.Symbol;
//			this.DataSourceName = found.DataSourceName;
//			this.ScaleInterval = found.ScaleInterval.Clone();
//			this.DataRange = found.DataRange.Clone();
//			this.ChartStreaming = found.ChartStreaming;
//			this.ShowRangeBar = found.ShowRangeBar;
            base.AbsorbFrom(found);

            this.PositionSize = found.PositionSize.Clone();
            if (absorbParams)
            {
                this.ParameterValuesById = new Dictionary <int, double>(found.ParameterValuesById);
            }
            //this.ChartBarSpacing = found.ChartBarSpacing;
            this.ChartAutoSubmitting       = found.ChartAutoSubmitting;
            this.BacktestOnRestart         = found.BacktestOnRestart;
            this.BacktestOnSelectorsChange = found.BacktestOnSelectorsChange;
            this.ReporterShortNamesUserInvokedJSONcheck = new List <string>(found.ReporterShortNamesUserInvokedJSONcheck);
        }
Пример #3
0
        public void ContextSwitchCurrentToNamedAndSerialize(string scriptContextName)
        {
            this.checkThrowContextNameShouldExist(scriptContextName);
            ContextScript found = this.ScriptContextsByName[scriptContextName];

            this.ScriptContextCurrentName = found.Name;
            Assembler.InstanceInitialized.RepositoryDllJsonStrategy.StrategySave(this);
            this.ContextMarkCurrentInListByName(scriptContextName);
        }
Пример #4
0
        public ContextScript ContextAppendHardcopyFromCurrentToNamed(string scriptContextNameNew)
        {
            this.checkThrowContextNameShouldNotExist(scriptContextNameNew);
            ContextScript clone = this.ScriptContextCurrent.MemberwiseCloneMadePublic();

            clone.Name = scriptContextNameNew;
            this.ScriptContextsByName.Add(clone.Name, clone);
            this.ContextMarkCurrentInListByName(scriptContextNameNew);
            return(clone);
        }
		public void AbsorbFrom(ContextScript found, bool absorbParams = false) {
			if (found == null) return;
			//KEEP_CLONE_UNDEFINED this.Name = found.Name;
//			this.Symbol = found.Symbol;
//			this.DataSourceName = found.DataSourceName;
//			this.ScaleInterval = found.ScaleInterval.Clone();
//			this.DataRange = found.DataRange.Clone();
//			this.ChartStreaming = found.ChartStreaming;
//			this.ShowRangeBar = found.ShowRangeBar;
			base.AbsorbFrom(found);
			
			this.PositionSize = found.PositionSize.Clone();
			if (absorbParams) this.ParameterValuesById = new Dictionary<int, double>(found.ParameterValuesById);
			//this.ChartBarSpacing = found.ChartBarSpacing;
			this.ChartAutoSubmitting = found.ChartAutoSubmitting;
			this.BacktestOnRestart = found.BacktestOnRestart;
			this.BacktestOnSelectorsChange = found.BacktestOnSelectorsChange;
			this.ReporterShortNamesUserInvokedJSONcheck = new List<string>(found.ReporterShortNamesUserInvokedJSONcheck);
		}
Пример #6
0
        public void ScriptContextAdd(string newScriptContextName, ContextScript absorbParamsFrom = null)
        {
            if (this.ScriptContextsByName.ContainsKey(newScriptContextName))
            {
                string msg = "CANT_ADD_EXISTING scriptContextName[" + newScriptContextName + "] already exists for strategy[" + this + "]";
                Assembler.InstanceInitialized.StatusReporter.DisplayStatus(msg);
                return;
                //e.Cancel = true;
            }
            ContextScript newScriptContext = new ContextScript(newScriptContextName);

            if (absorbParamsFrom != null)
            {
                newScriptContext.AbsorbFrom(absorbParamsFrom, true);
            }
            //ABSORBS_TO_CURRENT_INSTEAD_OF_NEW var forceParametersFillScriptContext = this.ScriptParametersMergedWithCurrentContext;
            this.ScriptContextsByName.Add(newScriptContextName, newScriptContext);
            Assembler.InstanceInitialized.RepositoryDllJsonStrategy.StrategySave(this);
            string msg2 = "scriptContextName[" + newScriptContextName + "] added for strategy[" + this + "]";

            Assembler.InstanceInitialized.StatusReporter.DisplayStatus(msg2);
        }
Пример #7
0
		public void PropagateContextScriptToLTB(ContextScript ctxScript) {
			if (ctxScript.ScaleInterval.Scale == BarScale.Unknown) {
				string msg = "TODO: figure out why deserialized / userSelected strategyClicked[" + this.ChartFormManager.Executor.Strategy
					+ "].ScriptContextCurrent.ScaleInterval[" + ctxScript.ScaleInterval + "] has BarScale.Unknown #4";
				Assembler.PopupException(msg);
			} else {
				MenuItemLabeledTextBox mnitlbForScale = null;
				switch (ctxScript.ScaleInterval.Scale) {
					case BarScale.Minute:		mnitlbForScale = this.mnitlbMinutes; break; 
					case BarScale.Hour:			mnitlbForScale = this.mnitlbDaily; break; 
					case BarScale.Daily:		mnitlbForScale = this.mnitlbHourly; break; 
					case BarScale.Weekly:		mnitlbForScale = this.mnitlbWeekly; break; 
					case BarScale.Monthly:		mnitlbForScale = this.mnitlbMonthly; break; 
					//case BarScale.Quarterly		mnitlbForScale = this.mnitlbQuarterly; break; 
					case BarScale.Yearly:		mnitlbForScale = this.mnitlbYearly; break;
					default:
						string msg = "SCALE_UNHANDLED_NO_TEXTBOX_TO_POPULATE " + ctxScript.ScaleInterval.Scale;
						Assembler.PopupException(msg);
						break;
				}
				
				if (mnitlbForScale != null) {
					mnitlbForScale.InputFieldValue = ctxScript.ScaleInterval.Interval.ToString();
					mnitlbForScale.BackColor = Color.Gainsboro;
				}
			}

			this.mniShowBarRange.Checked = ctxScript.ShowRangeBar;
			switch (ctxScript.DataRange.Range) {
				case BarRange.AllData:
					this.mnitlbShowLastBars.InputFieldValue = "";
					this.mnitlbShowLastBars.BackColor = Color.White;
					break;
				case BarRange.DateRange:
					this.ChartControl.RangeBar.ValueMin = ctxScript.DataRange.StartDate; 
					this.ChartControl.RangeBar.ValueMax = ctxScript.DataRange.EndDate; 
					this.mnitlbShowLastBars.InputFieldValue = "";
					this.mnitlbShowLastBars.BackColor = Color.White;
					break;
				case BarRange.RecentBars:
					this.mnitlbShowLastBars.InputFieldValue = ctxScript.DataRange.RecentBars.ToString();
					this.mnitlbShowLastBars.BackColor = Color.Gainsboro;
					//this.mniShowBarRange.Checked = false;
					break;
				default:
					string msg = "DATE_RANGE_UNHANDLED_RECENT_TIMEUNITS_NYI " + ctxScript.DataRange;
					Assembler.PopupException(msg);
					break;
			}
			this.ChartControl.RangeBarCollapsed = !this.mniShowBarRange.Checked; 

			switch (ctxScript.PositionSize.Mode) {
				case PositionSizeMode.SharesConstantEachTrade:
					this.mnitlbPositionSizeSharesConstantEachTrade.InputFieldValue = ctxScript.PositionSize.SharesConstantEachTrade.ToString();
					this.mnitlbPositionSizeSharesConstantEachTrade.BackColor = Color.Gainsboro;
					this.mnitlbPositionSizeDollarsEachTradeConstant.BackColor = Color.White;
					break;
				case PositionSizeMode.DollarsConstantForEachTrade:
					this.mnitlbPositionSizeDollarsEachTradeConstant.InputFieldValue = ctxScript.PositionSize.DollarsConstantEachTrade.ToString();
					this.mnitlbPositionSizeDollarsEachTradeConstant.BackColor = Color.Gainsboro;
					this.mnitlbPositionSizeSharesConstantEachTrade.BackColor = Color.White;
					break;
				default:
					string msg = "POSITION_SIZE_UNHANDLED_NYI " + ctxScript.PositionSize.Mode;
					Assembler.PopupException(msg);
					break;
			}

			DataSourcesForm.Instance.DataSourcesTreeControl.SelectSymbol(ctxScript.DataSourceName, ctxScript.Symbol);
			StrategiesForm.Instance.StrategiesTreeControl.SelectStrategy(this.ChartFormManager.Executor.Strategy);
			this.PropagateSelectorsDisabledIfStreamingForCurrentChart();
		}
Пример #8
0
		public void ScriptContextRename(ContextScript scriptContextToRename, string scriptContextNewName) {
			if (scriptContextToRename.Name == scriptContextNewName) {
				string msg = "WONT_RENAME_TO_SAME_NAME scriptContextNewName[" + scriptContextNewName + "]=scriptContextToRename.Name[" + scriptContextToRename.Name + "], type another name";
				Assembler.InstanceInitialized.StatusReporter.DisplayStatus(msg);
				return;
				//e.Cancel = true;
			}
			if (this.ScriptContextsByName.ContainsKey(scriptContextNewName)) {
				string msg = "CANT_RENAME_NAME_ALREADY_EXISTS scriptContextNewName[" + scriptContextNewName + "] already exists for strategy[" + this + "]";
				Assembler.InstanceInitialized.StatusReporter.DisplayStatus(msg);
				return;
				//e.Cancel = true;
			}
			string oldName = scriptContextToRename.Name;
			this.ScriptContextsByName.Remove(oldName);
			scriptContextToRename.Name = scriptContextNewName;
			this.ScriptContextsByName.Add(scriptContextNewName, scriptContextToRename);
			if (this.ScriptContextCurrentName == oldName) this.ScriptContextCurrentName = scriptContextNewName;
			
			Assembler.InstanceInitialized.RepositoryDllJsonStrategy.StrategySave(this);
			string msg2 = "scriptContextName[" + oldName + "]=>[" + scriptContextNewName + "] for strategy[" + this + "]";
			Assembler.InstanceInitialized.StatusReporter.DisplayStatus(msg2);
		}
Пример #9
0
		public void ScriptContextAdd(string newScriptContextName, ContextScript absorbParamsFrom = null) {
			if (this.ScriptContextsByName.ContainsKey(newScriptContextName)) {
				string msg = "CANT_ADD_EXISTING scriptContextName[" + newScriptContextName + "] already exists for strategy[" + this + "]";
				Assembler.InstanceInitialized.StatusReporter.DisplayStatus(msg);
				return;
				//e.Cancel = true;
			}
			ContextScript newScriptContext = new ContextScript(newScriptContextName);
			if (absorbParamsFrom != null) {
				newScriptContext.AbsorbFrom(absorbParamsFrom, true);
			}
			//ABSORBS_TO_CURRENT_INSTEAD_OF_NEW var forceParametersFillScriptContext = this.ScriptParametersMergedWithCurrentContext;
			this.ScriptContextsByName.Add(newScriptContextName, newScriptContext);
			Assembler.InstanceInitialized.RepositoryDllJsonStrategy.StrategySave(this);
			string msg2 = "scriptContextName[" + newScriptContextName + "] added for strategy[" + this + "]";
			Assembler.InstanceInitialized.StatusReporter.DisplayStatus(msg2);
		}