public void AddTradeSignal(int barNo, SortedDictionary <int, List <TradeSignal> > listSignals, TradeSignalType tdSigType, TradeSignalSource tdSigSrc, OrderAction ordAct, OrderType ordType) { TradeSignal isig = new TradeSignal(); isig.BarNo = barNo; isig.SignalType = tdSigType; isig.SignalSource = tdSigSrc; isig.Action = ordAct; isig.Order_Type = ordType; AddTradeSignal(barNo, listSignals, isig); }
/// <summary> /// Get the last signal before barNo by signal_name /// </summary> /// <param name="barNo"></param> /// <param name="signal_name"></param> /// <returns></returns> public TradeSignal GetLastTradeSignalByName(int barNo, SortedDictionary <int, List <TradeSignal> > listSignals, string signal_name) { int k = barNo; foreach (int kk in listSignals.Keys.Reverse()) { if (kk < k) { TradeSignal sig = GetTradeSignalByName(k, listSignals, signal_name); if (sig != null) { return(sig); } k = kk; } } return(null); }
/// <summary> /// Get the last signal before barNo by OrderType /// </summary> /// <param name="barNo"></param> /// <param name="signalActionType"></param> /// <returns></returns> public TradeSignal GetLastTradeSignalByOrderType(int barNo, SortedDictionary <int, List <TradeSignal> > listSignals, OrderType ord_type) { int k = barNo; foreach (int kk in listSignals.Keys.Reverse()) { if (kk < k) { Print(CurrentBar + ": kk,k=" + kk + "," + k); TradeSignal sig = GetTradeSignalByOrderType(k, listSignals, ord_type); if (sig != null) { return(sig); } k = kk; } } return(null); }
/// <summary> /// Add the signal to the list of the bar with barNo /// </summary> /// <param name="barNo"></param> /// <param name="signal"></param> public void AddTradeSignal(int barNo, SortedDictionary <int, List <TradeSignal> > listSignals, TradeSignal signal) { List <TradeSignal> list_signal; if (!listSignals.TryGetValue(barNo, out list_signal)) { list_signal = new List <TradeSignal>(); } // else // listSignals.Remove(barNo); list_signal.Add(signal); //listSignals.Add(barNo, list_signal); listSignals[barNo] = list_signal; IndicatorProxy.PrintLog(true, IsLiveTrading(), String.Format("{0}: AddTradeSignal list_signal.Count={1}, listSignals.Count={2}", CurrentBar, list_signal.Count, listSignals.Count)); if (listSignals.Count < 5) { foreach (KeyValuePair <int, List <TradeSignal> > m in listSignals) { List <TradeSignal> mm = m.Value as List <TradeSignal>; foreach (TradeSignal ts in mm) { IndicatorProxy.PrintLog(true, IsLiveTrading(), String.Format("{0}: AddTradeSignal SortedDictionary key={1}, SignalType={2}", CurrentBar, m.Key, ts.SignalType.ToString())); } } } }
// public string GetCmdDir() { // List<string> names = new List<string>(){"CmdPathRoot"}; // Dictionary<string,object> dic = GConfig.GetConfigItems(GConfig.MainConfigFile, names); // object dir = null; // dic.TryGetValue("CmdPathRoot", out dir); // return GConfig.GetTemplatesDir() + dir.ToString() + Path.DirectorySeparatorChar; // } // public string GetCTXFilePath() { // List<string> names = new List<string>(){"CTXFileName","MenuFileName"}; // Dictionary<string,object> dic = GConfig.GetConfigItems(GConfig.MainConfigFile, names); // object name = null; // //dic.TryGetValue("CmdPathRoot", out dir); // dic.TryGetValue("CTXFileName", out name); // string path = GetCmdDir() + name.ToString(); // Print("GetCTXFilePath=" + path); // return path; // } /* * public void ReadRestfulJson() { * HttpClient http = new HttpClient(); * http.DefaultRequestHeaders.Add(RequestConstants.UserAgent, RequestConstants.UserAgentValue); * string baseUrl = "https://restcountries.eu/rest/v2/name/"; * * string queryFilter = "?fields=name;capital;currencies"; * * //Console.WriteLine("Enter your country name:"); * * //string searchTerm = Console.ReadLine(); * * //string url = baseUrl + searchTerm + queryFilter; * string url = "https://api.github.com/repos/restsharp/restsharp/releases"; * HttpResponseMessage response = http.GetAsync(new Uri(url)).Result; * * string responseBody = response.Content.ReadAsStringAsync().Result; * * List<GitHubRelease> paraDict = GConfig.LoadJsonStr2Obj<List<GitHubRelease>>(responseBody); * Print(String.Format("ele.Key={0}, ele.Value.ToString()={1}", paraDict.GetType().ToString(), paraDict.Count)); * foreach(GitHubRelease tctx in paraDict) { * Print(String.Format("name={0}, pub_at={1}", * tctx.Name, tctx.Published_At)); * } * Print(String.Format("ReadRestfulJson={0}", responseBody)); * * //var countries = JsonConvert.DeserializeObject>(responseBody); * } */ #endregion #region Interfaces public virtual void AlertTradeSignal(TradeSignal tsig, string caption) { }