void IAdvisorProxy.SetParameter(int token, string key, string value) { RemoteAdvisor rmAdvisor = rmAdvisors[token]; if (rmAdvisor != null) { rmAdvisor.SetParameter(key, value); } }
void IAdvisorProxy.SetCmdResult(int token, object result) { RemoteAdvisor rmAdvisor = rmAdvisors[token]; if (rmAdvisor != null) { rmAdvisor.SetCommandResult(result); } }
void IAdvisorProxy.SetInit(int token) { RemoteAdvisor rmAdvisor = rmAdvisors[token]; if (rmAdvisor != null) { ThreadPool.QueueUserWorkItem(new WaitCallback(rmAdvisor.AsyncInit)); } }
int IAdvisorProxy.GetNextCommand(int token) { RemoteAdvisor rmAdvisor = rmAdvisors[token]; if (rmAdvisor != null && rmAdvisor.Command != null) { return((int)rmAdvisor.Command.Name); } return(-2); }
int IAdvisorProxy.GetCommandParamCount(int token) { RemoteAdvisor rmAdvisor = rmAdvisors[token]; if (rmAdvisor != null && rmAdvisor.Command != null) { return((int)rmAdvisor.Command.ParamCount); } return(-2); }
private object GetCommandParam(int token) { RemoteAdvisor rmAdvisor = rmAdvisors[token]; if (rmAdvisor == null || rmAdvisor.Command == null) { return(null); } return(rmAdvisor.Command.getNextParam()); }
void IAdvisorProxy.OnTick(int token, double bid, double ask, int dateTime) { RemoteAdvisor rmAdvisor = rmAdvisors[token]; if (rmAdvisor != null) { rmAdvisor.Ask = ask; rmAdvisor.Bid = bid; rmAdvisor.LastTickDateTime = Convertor.SecondsToDateTime(dateTime); ThreadPool.QueueUserWorkItem(new WaitCallback(rmAdvisor.AsyncStart)); } }
void IAdvisorProxy.EndSession(int token) { lock (_syncAdvisorCollection) { RemoteAdvisor rmAdvisor = rmAdvisors[token]; if (rmAdvisor != null) { ThreadPool.QueueUserWorkItem(new WaitCallback(rmAdvisor.AsyncDeinit)); rmAdvisors.Remove(token); } } }
internal override void OnRemmoteAdvisorInit(RemoteAdvisor rmAdviser) { try { Meta = rmAdviser; ForexAPI fAPI = new ForexAPI(Meta, rmAdviser.MagicNumber); OrderOperation = fAPI; Account = fAPI; History = fAPI; this.Symbol = rmAdviser.Symbol(); if (this.param != null) { throw new ApplicationException("Param was initalized"); } this.param = new StrategyParameter(); foreach (string paramKey in rmAdviser.Parameters.Keys) { if (paramKey == "NewsFilePath") { this.param.NewsFilePath = rmAdviser.Parameters[paramKey]; continue; } if (paramKey.EndsWith("String")) { this.param.Add(paramKey, rmAdviser.Parameters[paramKey]); continue; } if (paramKey == "InvertedMetaStrategy") { rmAdviser.IsInverted = rmAdviser.Parameters[paramKey] == "1" || rmAdviser.Parameters[paramKey] == "true"; continue; } this.param[paramKey] = Int32.Parse(rmAdviser.Parameters[paramKey]); } this.logger = new MetaStrategyLogger(Meta); onStart(0); this.Meta.Print("onStart finidshed successfully"); } catch (Exception exc) { string excString = "Start up exception: " + exc.ToString(); Meta.Comment(excString); Meta.Print(excString); } }
int IAdvisorProxy.StartSession(string markeId) { //todo update for external advisor lock (_syncAdvisorCollection) { int id = idSeed++; RemoteAdvisor rmAdvisor = CreateRemoteAdvisor(); rmAdvisor.MarketId = markeId; id = rmAdvisor.Init(this); rmAdvisors[id] = rmAdvisor; return(id); } }
internal override void OnRemoteAdvisorStart(RemoteAdvisor rmAdviser) { try { Tick <int> newTick = new Tick <int>(); newTick.Ask = Convertor.TranslateToPipPrice(rmAdviser.Symbol(), rmAdviser.Ask); newTick.Bid = Convertor.TranslateToPipPrice(rmAdviser.Symbol(), rmAdviser.Bid); newTick.DateTime = rmAdviser.LastTickDateTime; UpdateProperties(); onTick(newTick); _currentTicks++; } catch (Exception exc) { string excString = "Exception: " + exc.ToString(); Meta.Comment(excString); //Meta.Print("excString"); } }
internal override void OnRemmoteAdvisorDeinit(RemoteAdvisor rmAdviser) { onEnd(); }
internal abstract void OnRemoteAdvisorStart(RemoteAdvisor rmAdviser);
internal abstract void OnRemmoteAdvisorDeinit(RemoteAdvisor rmAdviser);