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); }
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; } }
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(); }
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)); }
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); }
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); }
public Response GetFreshResponseInstance() { var freshResponse = ResponseLoader.FromDLL(ResponseName, ResponsePath); PlottingUtilities.CopyParameters(SelectedResponse, freshResponse); return(freshResponse); }
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; }
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(); }
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 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; }