private void Boxes_SelectedIndexChanged(object sender, EventArgs e) { // make sure something is selected if (_availresponses.SelectedIndex == -1) { return; } // get selected response string resname = (string)_availresponses.SelectedItem; // load it into working response _workingres = ResponseLoader.FromDLL(resname, Properties.Settings.Default.boxdll); // handle all the outgoing events from the response _workingres.SendOrder += new OrderDelegate(workingres_SendOrder); _workingres.SendDebug += new DebugFullDelegate(workingres_GotDebug); _workingres.SendCancel += new UIntDelegate(workingres_CancelOrderSource); // save the dll that contains the class for use with skins string dll = string.Empty; // if we don't have this class, add it if (!_class2dll.TryGetValue(resname, out dll)) { _class2dll.Add(resname, Properties.Settings.Default.boxdll); } else // otherwise replace current dll as providing this class { _class2dll[resname] = Properties.Settings.Default.boxdll; } }
public static decimal GetMinAdvance(string dll, string rn, string name) { // load repsonse var r = ResponseLoader.FromDLL(rn, dll); // ensure valid if (!r.isValid) { return(0); } // get all the public global properties foreach (var pi in r.GetType().GetProperties()) { if (pi.Name != name) { continue; } var pt = pi.PropertyType; if (pt == typeof(int)) { return(1); } else { return(.01m); } } return(0); }
public static List <string> GetOptimizeable(string dll, string rn) { List <string> op = new List <string>(); // load repsonse var r = ResponseLoader.FromDLL(rn, dll); // ensure valid if (!r.isValid) { return(op); } // get all the public global properties foreach (var pi in r.GetType().GetProperties()) { var pt = pi.PropertyType; if ((pt == typeof(int)) || (pt == typeof(decimal))) { if (pi.CanWrite && pi.GetAccessors(false)[0].IsPublic) { op.Add(pi.Name); } } } var tmp = op.ToArray(); Array.Sort(tmp); return(new List <string>(tmp)); }
bool SetResponse(string name) { // dll must exist, otherwise quit if (DllName == "") { return(false); } // response must exist in dll, otherwise quit if (!Util.GetResponseList(DllName).Contains(name)) { return(false); } _resp = name; _response = ResponseLoader.FromDLL(_resp, DllName); bool r = _response.isValid; if (r) { D("loaded response: " + name); } else { D("invalid response: " + name + " " + _response.FullName); } return(r); }
public static bool isNameInt(string dll, string rn, string name) { // load repsonse var r = ResponseLoader.FromDLL(rn, dll); // ensure valid if (!r.isValid) { return(false); } // get all the public global properties foreach (var pi in r.GetType().GetProperties()) { if (pi.Name != name) { continue; } var pt = pi.PropertyType; if (pt == typeof(int)) { return(true); } return(false); } return(false); }
public Response GetFreshResponseInstance() { var freshResponse = ResponseLoader.FromDLL(ResponseName, ResponsePath); PlottingUtilities.CopyParameters(SelectedResponse, freshResponse); return(freshResponse); }
private void boxlist_SelectedIndexChanged(object sender, EventArgs e) { string rname = string.Empty; try { args.Response = ResponseLoader.FromDLL(CurrentResponse, args.DllName); } catch (Exception ex) { status("Response failed to load, quitting... (" + ex.Message + (ex.InnerException != null ? ex.InnerException.Message.ToString() : "") + ")"); } if ((args == null) || (args.Response == null) || !args.Response.isValid) { status("Response did not load or loaded in a shutdown state. " + rname); return; } args.ResponseName = args.Response.FullName; _boundonce = false; bindresponseevents(); if (!resetonrun.Checked) { resetresponse(); } // update optimizeable params updateoptimize(); }
bool SetResponse(string name) { // dll must exist, otherwise quit if (DllName == "") { return(false); } // response must exist in dll, otherwise quit if (!ResponseLoader.GetResponseList(DllName).Contains(name)) { return(false); } _resp = name; try { _response = ResponseLoader.FromDLL(_resp, DllName); } catch (Exception ex) { D(ex.Message + ex.StackTrace); } bool r = _response.isValid; if (r) { D("loaded response: " + name); } else { D("invalid response: " + name + " " + _response.FullName); } return(r); }
void resetresponse(string click) { if (!isValid) { // should never happen return; } // confirm string extra = isResponseEnabled ? Environment.NewLine + "(Recommend turning off response first, currently ON)" : string.Empty; if (System.Windows.Forms.MessageBox.Show("Are you sure you want to reset: " + response.Name + "?" + extra, "Confirm " + response.Name + " Reset", System.Windows.Forms.MessageBoxButtons.YesNoCancel) != System.Windows.Forms.DialogResult.Yes) { status("User canceled " + response.Name + " reset."); return; } try { ResponseLoader.SendSimulationHints(ref response, Util.ToTLDate(), Util.ToTLTime(), getallsymbols().ToArray(), debug); response.Reset(); status(response.Name + " was reset by user."); debug(response.FullName + " was reset by user."); } catch (Exception ex) { status(response.Name + " error during Reset, see debugs."); debug(response.FullName + " got an error in user code on Reset, err: " + ex.Message + ex.StackTrace); } }
public static ResponseModelView LoadResponseView(string name, string dll, DebugDelegate d) { _d = d; var rmv = new ResponseModelView(); // verify file exists if (string.IsNullOrWhiteSpace(dll)) { sdebug("No dll provided, user can specifiy new dll in response view."); return(rmv); } if (string.IsNullOrWhiteSpace(name)) { sdebug("Responses not being used."); return(rmv); } if (!System.IO.File.Exists(dll)) { sdebug("Dll no longer exists at: " + dll + ", user can specifiy new dll in response view."); return(rmv); } // load response var r = ResponseLoader.FromDLL(name, dll, d); if ((r == null) || !r.isValid) { sdebug("Unable to load response: " + name + " from: " + dll); return(rmv); } var inds = ResponseLoader.GetIndicators(dll, name, d); rmv = new ResponseModelView(inds); rmv.response = r; // update it rmv._rdll = dll; // bind it rmv.bind(inds); // get any user settable values rmv.settablenames = ResponseLoader.GetSettableList(dll, name, d); if (rmv.isValid) { sdebug("Loaded response: " + name + " from: " + dll); } else { sdebug("Response missing sym/symbol indicator: " + name + " in: " + dll); rmv = new ResponseModelView(); } return(rmv); }
private void boxlist_SelectedIndexChanged(object sender, EventArgs e) { try { args.Response = ResponseLoader.FromDLL((string)reslist.SelectedItem, WinGauntlet.Properties.Settings.Default.boxdll); } catch (Exception ex) { status("Response failed to load, quitting... (" + ex.Message + (ex.InnerException != null ? ex.InnerException.Message.ToString() : "") + ")"); } if (!args.Response.isValid) { status("Response did not load or loaded in a shutdown state. " + args.Response.Name + " " + args.Response.FullName); return; } args.ResponseName = args.Response.FullName; _boundonce = false; bindresponseevents(); }
private void Boxes_SelectedIndexChanged(object sender, EventArgs e) { // make sure something is selected if (_availresponses.SelectedIndex == -1) { return; } // get selected response string resname = (string)_availresponses.SelectedItem; // load it into working response Response tmp = new InvalidResponse(); try { tmp = ResponseLoader.FromDLL(resname, Properties.Settings.Default.boxdll); } catch (Exception ex) { // log it bigexceptiondump(ex); // unselect response _availresponses.SelectedIndex = -1; return; } // add it int idx = addresponse(tmp); // make sure it worked if (idx == -1) { return; } // save the dll that contains the class for use with skins string dll = string.Empty; // if we don't have this class, add it if (!_class2dll.TryGetValue(resname, out dll)) { _class2dll.Add(resname, Properties.Settings.Default.boxdll); } else // otherwise replace current dll as providing this class { _class2dll[resname] = Properties.Settings.Default.boxdll; } // unselect response _availresponses.SelectedIndex = -1; }
private bool loadfile(string path) { string f = path; bool success = false; if (isResponse(f)) { responsedll = f; List <string> l = ResponseLoader.GetResponseList(responsedll); if (System.IO.File.Exists(f) && (l.Count > 0)) { if (!isRecentResLib(f)) { reslist.DropDownItems.Add(f); } } status("Found " + l.Count + " responses. "); _rl = new ResponseList(l); _rl.ResponseSelected += new DebugDelegate(loadboxname); if (_rl.ShowDialog() != DialogResult.OK) { status("no response was selected."); } success = true; } else if (isTIK(f)) { if (System.IO.File.Exists(f)) { if (!isRecentTickfile(f) && SecurityImpl.SecurityFromFileName(f).isValid) { recent.DropDownItems.Add(f); } } epffiles.Add(f); success = loadsim(); } else if (isSkin(f)) { loadskin(f); } hasprereq(); return(success); }
private void button2_Click(object sender, EventArgs e) { // response library selection OpenFileDialog of = new OpenFileDialog(); of.CheckPathExists = true; of.CheckFileExists = true; of.DefaultExt = ".dll"; of.Filter = "Response DLL|*.dll"; of.Multiselect = false; if (of.ShowDialog() == DialogResult.OK) { args.DllName = of.FileName; UpdateResponses(ResponseLoader.GetResponseList(of.FileName)); } }
void runopt() { isRunning = true; while (isNextAvail) { gauntletArgs ga = new gauntletArgs(DLL, RNAME, SIM); ga.value = NextParam; ga.id = id; Response r = ResponseLoader.FromDLL(ga.response, ga.dll); if (changeVars(ref r, ga.value)) { //GauntletEngine ge = new GauntletEngine(r, ga.hsim); //Thread.SpinWait(1000); //debugControl1.GotDebug("Starting a Gauntlet instance"); debug("Started Gauntlet Engine: " + ga.id); Go(); List <Trade> trades = SimBroker.GetTradeList(); Results results = Results.ResultsFromTradeList(trades, 0, .01m, new DebugDelegate(debug)); GauntletOptimizationResults gor = new GauntletOptimizationResults(); gor.parameter = ga.value; gor.results = results; gor.resultsCalculated = true; allResults.Add(gor); decimal rv = 0; getresult(results, out rv); debug("optimize " + ga.id + " finished. Used: " + gor.parameter + " -> " + OptimizeDecisionsName + ": " + rv + " trades: " + gor.results.Trades + " SimsRemaining: " + OptimizeRemain); progress(id, OptimizeCount); } else { debug("Unable to start gauntlet engine: " + ga.id + " with: " + ga.value); } } debug("All optimization runs complete, computing optimum..."); var sorted = calculateBest(allResults); // unbind UnbindEvents(); if (SendOptimizationCompleteEvent != null) { SendOptimizationCompleteEvent(sorted); } isRunning = false; }
private void BacktestingComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if (_initializationModelsUnbound || _reportModelsUnbound || _responseModelsUnbound) { return; } UnbindResponseModels(); _backtestingConfigurationModel.ResponseName = _backtestingResponseLibraryList.SelectedResponse; _backtestingConfigurationModel.ResponsePath = _backtestingResponseLibraryList.FileName; if (_backtestingConfigurationModel.ResponseName != ResponseLibraryList._header && _backtestingConfigurationModel.ResponseName != null) { _backtestingConfigurationModel.SelectedResponse = ResponseLoader.FromDLL(_backtestingConfigurationModel.ResponseName, _backtestingConfigurationModel.ResponsePath); } BindResponseModels(); }
public Gauntlet() { TrackEnabled = Util.TrackUsage(); Program = PROGRAM; InitializeComponent(); Text += " " + Util.TLVersion(); debug(Util.TLSIdentity()); args.GotDebug += new DebugDelegate(args_GotDebug); args.ParseArgs(Environment.GetCommandLineArgs()); FormClosing += new FormClosingEventHandler(Gauntlet_FormClosing); debug(RunTracker.CountNewGetPrettyRuns(PROGRAM, Util.PROGRAM)); bw.WorkerSupportsCancellation = true; bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted); bw.DoWork += new DoWorkEventHandler(bw_DoWork); getsymwork.WorkerSupportsCancellation = true; getsymwork.DoWork += new DoWorkEventHandler(getsymwork_DoWork); getsymwork.RunWorkerCompleted += new RunWorkerCompletedEventHandler(getsymwork_RunWorkerCompleted); getsymwork.RunWorkerAsync(); getsymwork.RunWorkerCompleted += new RunWorkerCompletedEventHandler(getsymwork_RunWorkerCompleted); if (args.isUnattended) { ordersincsv.Checked = true; if (args.HideWindow) { this.ShowInTaskbar = false; this.WindowState = FormWindowState.Minimized; } //ShowWindow(System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle, SW_MINIMIZE); bindresponseevents(); queuebut_Click(null, null); } else { status("wait while tickdata is loaded..."); UpdateResponses(ResponseLoader.GetResponseList(args.DllName)); } _optdecision.Items.Clear(); _optdecision.Items.AddRange(Optimize.GetDecideable().ToArray()); if (_optdecision.Items.Count > 0) { _optdecision.Text = "NetPL"; } }
void loadboxname(string name) { try { myres = ResponseLoader.FromDLL(name, responsedll); } catch (Exception ex) { debug(ex.Message + ex.StackTrace); status("Error loading response"); myres = null; return; } if ((myres != null) && (myres.FullName == name)) { resname = name; myres.SendTicketEvent += new TicketDelegate(myres_SendTicketEvent); myres.SendDebugEvent += new DebugFullDelegate(myres_GotDebug); myres.SendCancelEvent += new LongSourceDelegate(myres_CancelOrderSource); myres.SendOrderEvent += new OrderSourceDelegate(myres_SendOrder); myres.SendIndicatorsEvent += new ResponseStringDel(myres_SendIndicators); myres.SendMessageEvent += new MessageDelegate(myres_SendMessage); myres.SendBasketEvent += new BasketDelegate(myres_SendBasket); myres.SendChartLabelEvent += new ChartLabelDelegate(myres_SendChartLabel); status(resname + " is current response."); updatetitle(); igridinit(); myres.ID = 0; try { myres.Reset(); } catch (Exception ex) { debug("An error occured inside your response Reset method: "); debug(ex.Message + ex.StackTrace); } } else { status("Response did not load."); } hasprereq(); }
private void ResponseComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if (_initializationModelsUnbound || _responseModelsUnbound) { return; } UnbindResponseModels(); var responseName = _optimizationResponseLibraryList.SelectedResponse; var fileName = _optimizationResponseLibraryList.FileName; if (responseName != ResponseLibraryList._header) { _optimizationConfigurationModel.SelectedResponse = ResponseLoader.FromDLL(responseName, fileName); } _optimizationConfigurationModel.PopulateAdjustableProperties(); BindResponseModels(); }
private void boxlist_SelectedIndexChanged(object sender, EventArgs e) { string rname = string.Empty; try { rname = (string)reslist.SelectedItem; args.Response = ResponseLoader.FromDLL(rname, args.DllName); } catch (Exception ex) { status("Response failed to load, quitting... (" + ex.Message + (ex.InnerException != null ? ex.InnerException.Message.ToString() : "") + ")"); } if ((args == null) || (args.Response == null) || !args.Response.isValid) { status("Response did not load or loaded in a shutdown state. " + rname); return; } args.ResponseName = args.Response.FullName; _boundonce = false; bindresponseevents(); args.Response.Reset(); }
void loadboxname(string name) { if ((resname != string.Empty) && (name != resname)) { reset(false); } try { myres = ResponseLoader.FromDLL(name, responsedll); } catch (Exception ex) { debug(ex.Message + ex.StackTrace); status("Error loading response"); myres = null; return; } if ((myres != null) && (myres.FullName == name)) { resname = name; status(resname + " is current response."); bindresponseevents(); updatetitle(); myres.ID = 0; try { myres.Reset(); igridinit(); } catch (Exception ex) { debug("An error occured inside your response Reset method: "); debug(ex.Message + ex.StackTrace); } } else { status("Response did not load."); } hasprereq(); }
void resetresponse() { // test if response is valid if ((args.Response == null) || !args.Response.isValid) { return; } // notify debug("Resetting response: " + args.Response.FullName); // do work try { var r = args.Response; int date = 0; string[] syms = new string[0]; if (getsimhints(args.Folder, args.Filter, ref date, ref syms)) { ResponseLoader.SendSimulationHints(ref r, date, 0, syms, debug); } args.Response.Reset(); } catch (Exception ex) { debug("on reset, response threw exception: " + ex.Message); } }
void loadboxname(string name) { try { myres = ResponseLoader.FromDLL(name, responsedll); } catch (Exception ex) { debug(ex.Message); debug("Error, quitting..."); return; } if ((myres != null) && (myres.FullName == name)) { myres.SendDebug += new DebugFullDelegate(myres_GotDebug); myres.SendCancel += new UIntDelegate(myres_CancelOrderSource); myres.SendOrder += new OrderDelegate(myres_SendOrder); myres.SendIndicators += new StringParamDelegate(myres_SendIndicators); h.SimBroker.GotOrder += new OrderDelegate(myres.GotOrder); h.SimBroker.GotFill += new FillDelegate(myres.GotFill); h.GotTick += new TickDelegate(myres.GotTick); status(resname + " is current response."); updatetitle(); } else { status("Response did not load."); } }
public Optimize(string dll, string response, HistSim sim) : base(ResponseLoader.FromDLL(response, dll), sim) { Dll = dll; ResponseName = response; }