/// <summary> /// CapRatio: ES:RTY=1.7:1, NQ:RTY=2.1:1, NQ:ES=1.25:1 /// </summary> // public override int GetTradeQuantity(int idx, double ratio) { // switch(idx) { // case 0: return base.GetTradeQuantity(idx, CapRatio1); // ratio>0? (int)ratio*5 : 5; // case 1: return base.GetTradeQuantity(idx, CapRatio2); //ratio>0? (int)ratio*4 :4; // default: return -1; // } // } /// <summary> /// Load ctx from Json file /// </summary> /// <returns></returns> public override void ReadCtxParaObj() { //ReadRestfulJson(); ctxPairSpdDaily.DictCtxPairSpd = GConfig.LoadJson2Obj <Dictionary <string, List <CtxPairSpd> > >(GConfig.GetCTXFilePath()); //Dictionary<string, object> paraDict = GConfig.LoadJson2Dictionary(GetCTXFilePath()); //Dictionary<string, object> paraDict = GConfig.LoadJson2Obj<Dictionary<string, object>>(GetCTXFilePath()); Print(String.Format("ReadCtxPairSpd paraDict={0}, paraDict.Count={1}", ctxPairSpdDaily.DictCtxPairSpd, ctxPairSpdDaily.DictCtxPairSpd.Count)); //if(paraDict != null && paraDict.Count > 0) { //this.ctxPairSpd = paraDict[0]; //GUtils.DisplayProperties<JsonStgPairSpd>(ctxPairSpd, IndicatorProxy); //} // foreach(var ele in ctxPairSpdDaily.DictCtxPairSpd) // { //Print(string.Format("DateCtx.ele.Key={0}, ele.Value.ToString()={1}", ele.Key, ele.Value)); // foreach(CtxPairSpd ctxPS in ele.Value) { // Print(string.Format("ctxPS.Symbol={0}, ctxPS.TimeClose={1}", ctxPS.Symbol, ctxPS.TimeClose)); // } // } //foreach(JsonStgPairSpd ele in ctxPairSpd) { //GUtils.DisplayProperties<JsonStgPairSpd>(ele, IndicatorProxy); //Print(string.Format("DateCtx.ele.Key={0}, ele.Value.ToString()={1}", ele.Date, ele.CtxDaily)); // if(ele != null && ele.Date != null && ele.TimeCtxs != null) { // Print(String.Format("DateCtx.ele.Key={0}, ele.Value.ToString()={1}", ele.Date, ele.TimeCtxs)); // foreach(TimeCtx tctx in ele.TimeCtxs) { // Print(String.Format("ele.Date={0}, TimeCtx.tctx.Time={1}, tctx.ChannelType={2}, tctx.MinUp={3}, tctx.Support={4}", // ele.Date, tctx.Time, tctx.ChannelType, tctx.MinUp, tctx.Support)); // } // } //} // foreach(KeyValuePair<string, List<TimeCTX>> ele in paraDict.cmdMarketContext.ctx_daily.ctx) { // //paraMap.Add(ele.Key, ele.Value.ToString()); // Print(String.Format("ele.Key={0}, ele.Value.ToString()=", ele.Key)); // } }
/// <summary> /// Write ctx to Json file /// </summary> /// <returns></returns> public void WriteCtxParaObj() { //Print(String.Format("ReadCtxPairSpd paraDict={0}, paraDict.Count={1}", ctxPairSpd, ctxPairSpd.Count)); // foreach(var ele in ctxPairSpd) // { // Print(string.Format("DateCtx.ele.Key={0}, ele.Value.ToString()={1}", ele.Key, ele.Value)); // foreach(CtxPairSpd ctxPS in ele.Value) { // Print(string.Format("ctxPS.Symbol={0}, ctxPS.TimeClose={1}", ctxPS.Symbol, ctxPS.TimeClose)); // } // } //if(IsInStrategyAnalyzer) //return; try{ string output = GConfig.Dictionary2JsonFile(this.CtxPairSpreadDaily.DictCtxPairSpd, GConfig.GetCTXOutputFilePath()); Print(string.Format("WriteCtxParaObj={0}", CtxPairSpreadDaily.DictCtxPairSpd.Count)); foreach (string key in CtxPairSpreadDaily.DictCtxPairSpd.Keys) { List <CtxPairSpd> cps = CtxPairSpreadDaily.DictCtxPairSpd[key]; if (cps != null && cps.Count > 0) { CtxPairSpd ctx = cps[0]; Print(string.Format("{0}\t{1}\t{2}", key, ctx.TimeSpdHigh, ctx.TimeSpdLow)); } } } catch (Exception ex) { Print(string.Format("{0}: WriteCtxParaObj exception {1}", CurrentBars[0], ex.Message)); } }
//=============================================== public void run_CHOICE(string[] args) { string lLast = GConfig.Instance().getData("G_CSHARP_ID"); Console.Write("CSHARP_ADMIN ({0}) ? : ", lLast); string lAnswer = Console.ReadLine(); if (lAnswer == "") { lAnswer = lLast; } if (lAnswer == "-q") { G_STATE = "S_END"; } // else if (lAnswer == "1") { G_STATE = "S_SQLITE"; GConfig.Instance().setData("G_CSHARP_ID", lAnswer); } else if (lAnswer == "2") { G_STATE = "S_OPENCV"; GConfig.Instance().setData("G_CSHARP_ID", lAnswer); } // else if (lAnswer == "10") { G_STATE = "S_STRING"; GConfig.Instance().setData("G_CSHARP_ID", lAnswer); } // }
//=============================================== public void run_TO_LOWER_STRING_DATA(string[] args) { string lLast = GConfig.Instance().getData("G_STRING_DATA"); Console.Write("G_STRING_DATA ({0}) ? : ", lLast); string lAnswer = Console.ReadLine(); if (lAnswer == "") { lAnswer = lLast; } if (lAnswer == "-q") { G_STATE = "S_END"; } else if (lAnswer == "-i") { G_STATE = "S_INIT"; } else if (lAnswer == "-a") { G_STATE = "S_ADMIN"; } else if (lAnswer == "-v") { G_STATE = "S_TO_LOWER"; } else if (lAnswer != "") { G_STATE = "S_TO_LOWER"; GConfig.Instance().setData("G_STRING_DATA", lAnswer); } }
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); }
protected override void OnStartup(StartupEventArgs e) { var culture = CultureInfo.CreateSpecificCulture("en-US"); Thread.CurrentThread.CurrentCulture = culture; Thread.CurrentThread.CurrentUICulture = culture; if (BaseAppUI.Properties.Settings.Default.DatabaseLocation != "C:") { AppDomain.CurrentDomain.SetData("DataDirectory", BaseAppUI.Properties.Settings.Default.DatabaseLocation); } base.OnStartup(e); try { GConfig.Initialize(); var vm = new ViewModel.MainVM(); var win = new MainWindow { DataContext = vm }; win.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } EventManager.RegisterClassHandler(typeof(TextBox), UIElement.GotFocusEvent, new RoutedEventHandler(GotFocus_Event), true); EventManager.RegisterClassHandler(typeof(TextBox), UIElement.LostFocusEvent, new RoutedEventHandler(LostFocus_Event), true); }
public static void ShowPopup(string title, string message) { GConfig conf = new GConfig(); conf.title = title; conf.message = message; showPopup(ref conf); }
//=============================================== public void run_TO_LOWER(string[] args) { Console.Write("\n"); string lData = GConfig.Instance().getData("G_STRING_DATA"); lData = GString.Instance().toLower(lData); Console.Write("{0}\n", lData); G_STATE = "S_SAVE"; }
//=============================================== public static GConfig Instance() { lock (padlock) { if (m_instance == null) { m_instance = new GConfig(); } return(m_instance); } }
public static IHostBuilder CreateHostBuilder(string[] args) { GConfig.Init(PConfig.AppSettingPath + "/appsettings.json"); new ConfigurationBuilder().AddJsonFile(PConfig.AppSettingPath + "/appsettings.json").AddEnvironmentVariables().Build(); return(Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseUrls(GConfig.UrlConfig.AutoApiPort); webBuilder.UseStartup <Startup>(); })); }
public string GetCmdFilePath() { List <string> names = new List <string>() { "CmdFileName", "CTXFileName" }; Dictionary <string, object> dic = GConfig.GetConfigItems(GConfig.MainConfigFile, names); object name = null; // dic.TryGetValue("CmdPathRoot", out dir); dic.TryGetValue("CmdFileName", out name); string path = GConfig.GetCmdDir() + name.ToString(); Print("GetCmdFilePath=" + path); return(path); }
//=============================================== public void run_CHOICE(string[] args) { string lLast = GConfig.Instance().getData("G_SQLITE_ID"); Console.Write("SQLITE_ADMIN ({0}) ? : ", lLast); string lAnswer = Console.ReadLine(); if (lAnswer == "") { lAnswer = lLast; } if (lAnswer == "-q") { G_STATE = "S_END"; } else if (lAnswer == "-i") { G_STATE = "S_INIT"; } else if (lAnswer == "-a") { G_STATE = "S_ADMIN"; } // else if (lAnswer == "1") { G_STATE = "S_SHOW_TABLES"; GConfig.Instance().setData("G_SQLITE_ID", lAnswer); } else if (lAnswer == "2") { G_STATE = "S_CONFIG_SHARP_SHOW_DATA"; GConfig.Instance().setData("G_SQLITE_ID", lAnswer); } else if (lAnswer == "3") { G_STATE = "S_CONFIG_SHARP_SHOW_SCHEMA"; GConfig.Instance().setData("G_SQLITE_ID", lAnswer); } else if (lAnswer == "4") { G_STATE = "S_CONFIG_SHARP_DELETE"; GConfig.Instance().setData("G_SQLITE_ID", lAnswer); } // }
public static void Main() { Console.WriteLine("[{0:hh:mm:ss}] Start program. ", DateTime.Now); Console.WriteLine("[{0:hh:mm:ss}] Searching for valid ARSO Urls...", DateTime.Now); switch (GConfig.TYPE_OF_EXEC) { case TypeOfExecution.Range2D: DesiredChunks = GConfig.GetRange2D(); break; case TypeOfExecution.CherryPick: DesiredChunks = GConfig.CherryPicked_CHUNKS(); break; case TypeOfExecution.Single: DesiredChunks = GConfig.SINGLE_CHUNK_VAL(); break; } Execute(); Console.WriteLine("[{0:hh:mm:ss}] End program.", DateTime.Now); }
/// <summary> /// Read Cmd parameters from json cmd file; /// Inidcator section set for Custom Strategy /// MM, TM, TG sections set for general Strategy /// Strategy embedded properties only set at State.SetDefaults from OnStateChange /// CurrentTrade only retrieved values from the custom/general Strategies; /// </summary> /// <returns></returns> public Dictionary <string, object> ReadCmdPara() { Dictionary <string, object> paraDict = GConfig.LoadJson2Dictionary(GetCmdFilePath()); foreach (KeyValuePair <string, object> ele in paraDict) { //paraMap.Add(ele.Key, ele.Value.ToString()); Print(String.Format("ele.Key={0}, ele.Value.ToString()={1}", ele.Key, ele.Value.ToString())); } //List<Dictionary<string, object>> mkt_ctx = paraDict["MarketContextCmd"] as List<Dictionary<string, object>>; ArrayList mkt_ctx = paraDict["MarketContextCmd"] as ArrayList; Print(String.Format("mkt_ctx={0}, mkt_ctx.count={1}", mkt_ctx.GetType().ToString(), mkt_ctx.Count)); Dictionary <string, object> ctx_dict = mkt_ctx[0] as Dictionary <string, object>; //["CTX_Daily"] foreach (KeyValuePair <string, object> ele2 in ctx_dict) { //paraMap.Add(ele.Key, ele.Value.ToString()); Print(String.Format("ele2.Key={0}, ele2.Value.ToString()={1}", ele2.Key, ele2.Value.ToString())); } //Print(String.Format("ctx_dict={0}, ctx_dict.count={1}", ctx_dict.GetType().ToString(), ctx_dict.Count)); GConfig.ParseCTXJson(ctx_dict, IndicatorProxy); return(paraDict); }
/// <summary> /// Read command from Json file /// </summary> /// <returns></returns> public T ReadCmdParaObj <T>() { ReadRestfulJson(); T paraDict = GConfig.LoadJson2Obj <T>(GConfig.GetCTXFilePath()); Print(String.Format("ele.Key={0}, ele.Value.ToString()={1}", paraDict, paraDict.GetType().Name)); GUtils.DisplayProperties <T>(paraDict, IndicatorProxy); // foreach(DateCtx ele in paraDict.MktCtxDaily) { // Print(String.Format("DateCtx.ele.Key={0}, ele.Value.ToString()={1}", ele.Date, ele.TimeCtxs)); // if(ele != null && ele.Date != null && ele.TimeCtxs != null) { // Print(String.Format("DateCtx.ele.Key={0}, ele.Value.ToString()={1}", ele.Date, ele.TimeCtxs)); // foreach(TimeCtx tctx in ele.TimeCtxs) { // Print(String.Format("ele.Date={0}, TimeCtx.tctx.Time={1}, tctx.ChannelType={2}, tctx.MinUp={3}, tctx.Support={4}", // ele.Date, tctx.Time, tctx.ChannelType, tctx.MinUp, tctx.Support)); // } // } // } // foreach(KeyValuePair<string, List<TimeCTX>> ele in paraDict.cmdMarketContext.ctx_daily.ctx) { // //paraMap.Add(ele.Key, ele.Value.ToString()); // Print(String.Format("ele.Key={0}, ele.Value.ToString()=", ele.Key)); // } return(paraDict); }
[DllImport("__Internal")] private static extern void showPopup(ref GConfig conf);
private void CreateOrder(OrderVM e) { try { var _orderHeader = e._orderHeader; //lines var lines = e.OrderLines.Select(n => n._line).ToList(); _orderHeader.POS_OrderDetails = lines; _orderHeader.vOrderStatus = e.OrderStatus; _orderHeader.dOrderAmount = e.AllTotal; _orderHeader.dOrderTax = e.TaxSubtotal; //order number _orderHeader.vOrderNumber = GConfig.GenerateLocalOrderNumber(); //time var processdate = DateTime.Now; _orderHeader.dModifiedDate = processdate; _orderHeader.dCreatedDate = processdate; foreach (var n in _orderHeader.POS_OrderDetails) { n.dModifiedDate = processdate; n.dCreatedDate = processdate; } //customer if (_orderHeader.CustomerId == 0) { var custo = GConfig.POS_Setup.Customers.FirstOrDefault((n) => n.vCustContactNme == "Guest Customer"); _orderHeader.CustomerId = custo.Id; } _orderHeader.POS_SetupId = GConfig.POS_Setup.Id; GConfig.POS_Setup.OrderHeaders.Add(_orderHeader); GConfig.DAL.SaveChanges(); if (e.OrderStatus != Model.OrderStatuses.Completed) { if (IsKitchenClicked == false) { SwitchToView(Orders); } } IsKitchenClicked = false; //SwitchToView(Orders); if (Orders.SelectedOrderType == Orders.AllTypes[0]) { Orders.Orders.Insert(0, e); Orders.SelectOrderCommand.Execute(e); } else { Orders.SelectedOrder = e; Orders.SelectOrderTypesCommand.Execute(Orders.AllTypes[0]); } // IsKitchenClicked = true; ///5/8/2016 order refersh if (IsKitchenClicked == false) { Register.RemoveSelection(); Register.Order = null; } IsKitchenClicked = false; } catch (Exception ex) { new Notifies.TransactionFailedNotify("100", ex.Message.ToString()).Show(); } }
static void Main(string[] args) { List <List <int> > chunks = GConfig.GET_PICKED_CHUNKS(); List <List <int> > list = new List <List <int> >(); string[] augs = Directory.GetFiles(Path.Combine(GConfig.WORKSPACE_DIR, GConfig.AUGMENTATION_SUBDIR)); foreach (string s in augs) { if (File.Exists(s)) { Regex rx = new Regex(@"[0-9]{3}[_]{1}[0-9]{2,3}", RegexOptions.Compiled | RegexOptions.IgnoreCase); Match matches = rx.Match(s); string chunk = matches.Value; string[] parts = chunk.Split("_"); List <int> element = new List <int>(); element.Add(int.Parse(parts[0])); element.Add(int.Parse(parts[1])); list.Add(element); } } List <List <int> > filteredChunks = new List <List <int> >(); foreach (List <int> chunk in chunks) { bool kurac = true; for (int i = 0; i < list.Count; i++) { if (list[i][0] == chunk[0] && list[i][1] == chunk[1]) { kurac = false; break; } } if (!kurac) { continue; } filteredChunks.Add(chunk); } chunks = filteredChunks; List <Task> tasks = new List <Task>(); Console.WriteLine($"Processing {chunks.Count} chunks."); foreach (List <int> chunk in chunks) { Program prg = new Program(); prg.TxtDatasetFileName = chunk[0] + "_" + chunk[1] + ".txt"; prg.DmrFileName = $"pcd{chunk[0]}_{chunk[1]}"; prg.SamplesFileName = $"{chunk[0]}_{chunk[1]}augmentation_result.txt"; Task t = new Task((exec_env) => { try { Program exec_env_prg = (Program)exec_env; Tools.Time(exec_env_prg.UnfilteredSampleObjects); Tools.Time(exec_env_prg.FilterOverlappingObjects); Tools.Time(exec_env_prg.FilterUndergroundPoints); exec_env_prg.samples = exec_env_prg.samples.Take(GConfig.ObjectsToAdd).ToList(); Tools.Time(exec_env_prg.ComputeRbnnMinVals); Tools.Time(exec_env_prg.SaveResults); } catch (Exception ex) { Console.WriteLine("Failed executing " + ((Program)exec_env).TxtDatasetFileName + ex.StackTrace + ex.Message); } }, prg); tasks.Add(t); } List <List <Task> > batches = MyCollections.Partition <Task>(tasks.ToArray(), 5).ToList(); foreach (var batch in batches) { foreach (Task t in batch) { t.Start(); } foreach (Task t in batch) { t.Wait(); } } Console.WriteLine("Program finished. Press the ANY key to continue..."); Console.ReadLine(); }
//=============================================== public void run_LOAD(string[] args) { GConfig.Instance().loadData("G_CSHARP_ID"); G_STATE = "S_METHOD"; }
//=============================================== public void run_SAVE(string[] args) { GConfig.Instance().saveData("G_CSHARP_ID"); G_STATE = "S_END"; }
public ObjectSampler() { AugmentableObjects = GConfig.GetAugmentableObjectPallette(); }
//=============================================== public void run_SAVE(string[] args) { GConfig.Instance().saveData("G_STRING_ID"); GConfig.Instance().saveData("G_STRING_DATA"); G_STATE = "S_QUIT"; }