static int set_AddingNew(IntPtr L) { try { Newtonsoft.Json.Linq.JContainer obj = (Newtonsoft.Json.Linq.JContainer)ToLua.CheckObject(L, 1, typeof(Newtonsoft.Json.Linq.JContainer)); EventObject arg0 = null; if (LuaDLL.lua_isuserdata(L, 2) != 0) { arg0 = (EventObject)ToLua.ToObject(L, 2); } else { return(LuaDLL.luaL_throw(L, "The event 'Newtonsoft.Json.Linq.JContainer.AddingNew' can only appear on the left hand side of += or -= when used outside of the type 'Newtonsoft.Json.Linq.JContainer'")); } if (arg0.op == EventOp.Add) { Newtonsoft.Json.ObservableSupport.AddingNewEventHandler ev = (Newtonsoft.Json.ObservableSupport.AddingNewEventHandler)arg0.func; obj.AddingNew += ev; } else if (arg0.op == EventOp.Sub) { Newtonsoft.Json.ObservableSupport.AddingNewEventHandler ev = (Newtonsoft.Json.ObservableSupport.AddingNewEventHandler)arg0.func; obj.AddingNew -= ev; } return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
private string[] getRawDataBase() { String json = HttpGet("https://api.cryptowat.ch/markets/kraken/btceur/ohlc?periods=1800&after=1564617600"); System.Text.StringBuilder sb = new System.Text.StringBuilder(); Newtonsoft.Json.Linq.JContainer jResult = (Newtonsoft.Json.Linq.JContainer)JsonConvert.DeserializeObject(json); int x = 0; foreach (var item in jResult["result"]["1800"]) { x++; } string[] array = new string[x]; x = 0; foreach (var item in jResult["result"]["1800"]) { array[x] = UnixTimeStampToDateTime(double.Parse(item[0].ToString())).ToString("yyyy-MM-dd HH:mm:ss"); x++; } return(array); }
static int set_ListChanged(IntPtr L) { try { Newtonsoft.Json.Linq.JContainer obj = (Newtonsoft.Json.Linq.JContainer)ToLua.CheckObject(L, 1, typeof(Newtonsoft.Json.Linq.JContainer)); EventObject arg0 = null; if (LuaDLL.lua_isuserdata(L, 2) != 0) { arg0 = (EventObject)ToLua.ToObject(L, 2); } else { return(LuaDLL.luaL_throw(L, "The event 'Newtonsoft.Json.Linq.JContainer.ListChanged' can only appear on the left hand side of += or -= when used outside of the type 'Newtonsoft.Json.Linq.JContainer'")); } if (arg0.op == EventOp.Add) { System.ComponentModel.ListChangedEventHandler ev = (System.ComponentModel.ListChangedEventHandler)arg0.func; obj.ListChanged += ev; } else if (arg0.op == EventOp.Sub) { System.ComponentModel.ListChangedEventHandler ev = (System.ComponentModel.ListChangedEventHandler)arg0.func; obj.ListChanged -= ev; } return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public static string GetClientRequestIdString(Method method) { if (method == null) { throw new ArgumentNullException("method"); } string clientRequestIdName = "x-ms-client-request-id"; foreach (Parameter parameter in method.Parameters) { if (parameter.Extensions.ContainsKey(ClientRequestIdExtension)) { Newtonsoft.Json.Linq.JContainer extensionObject = parameter.Extensions[ClientRequestIdExtension] as Newtonsoft.Json.Linq.JContainer; if (extensionObject != null) { bool useParamAsClientRequestId = (bool)extensionObject["value"]; if (useParamAsClientRequestId) { //TODO: Need to do something if they specify two ClientRequestIdExtensions for the same method...? clientRequestIdName = parameter.SerializedName; break; } } } } return(clientRequestIdName); }
public static ReturnDataArray getDataArray(string coin, string timeGraph, string limit = "1000") { System.Threading.Thread.Sleep(6000); ReturnDataArray returnDataArray = new ReturnDataArray(); String jsonAsString = Http.get("https://api.binance.com/api/v1/klines?symbol=" + coin + "&interval=" + timeGraph + "&limit=" + limit); Newtonsoft.Json.Linq.JContainer json = (Newtonsoft.Json.Linq.JContainer)JsonConvert.DeserializeObject(jsonAsString); returnDataArray.arrayPriceClose = new double[json.Count]; returnDataArray.arrayPriceHigh = new double[json.Count]; returnDataArray.arrayPriceLow = new double[json.Count]; returnDataArray.arrayPriceOpen = new double[json.Count]; returnDataArray.arrayVolume = new double[json.Count]; returnDataArray.arrayDate = new double[json.Count]; returnDataArray.arrayQuoteVolume = new double[json.Count]; int i = 0; foreach (JContainer element in json.Children()) { returnDataArray.arrayPriceClose[i] = double.Parse(element[4].ToString()); returnDataArray.arrayPriceHigh[i] = double.Parse(element[2].ToString()); returnDataArray.arrayPriceLow[i] = double.Parse(element[3].ToString()); returnDataArray.arrayPriceOpen[i] = double.Parse(element[1].ToString()); returnDataArray.arrayVolume[i] = double.Parse(element[5].ToString()); returnDataArray.arrayQuoteVolume[i] = double.Parse(element[7].ToString()); returnDataArray.arrayDate[i] = double.Parse(element[6].ToString()); i++; } return(returnDataArray); }
/// <summary> /// Delete default dashboard since new dasboard will be create with the same name /// </summary> /// <param name="project"></param> /// <param name="dashBoardId"></param> /// <returns></returns> public bool DeleteDefaultDashboard(string project, string dashBoardId) { try { if (dashBoardId != "") { using (var client = GetHttpClient()) { var method = new HttpMethod("DELETE"); var request = new HttpRequestMessage(method, project + "/" + project + "%20Team/_apis/dashboard/dashboards/" + dashBoardId + "?api-version=" + _configuration.VersionNumber); var response = client.SendAsync(request).Result; if (response.IsSuccessStatusCode) { return(true); } else { dynamic responseForInvalidStatusCode = response.Content.ReadAsAsync <dynamic>(); Newtonsoft.Json.Linq.JContainer msg = responseForInvalidStatusCode.Result; return(false); } } } } catch (Exception ex) { logger.Info(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") + "\t" + ex.Message + "\n" + ex.StackTrace + "\n"); } return(false); }
/// <summary> /// NEEDS PROPER REFACTORING /// </summary> /// <param name="urlToGet"></param> /// <param name="trackToGetId"></param> /// <param name="userId"></param> /// <param name="trackTitle"></param> /// <param name="resolveURLJson"></param> private static void DownloadSet(string urlToGet, ref string trackToGetId, ref string userId, ref string trackTitle, ref dynamic resolveURLJson) { resolveURLJson = SendAPIRequest(_api.MakeCallResolveURL(urlToGet)); trackToGetId = resolveURLJson["id"]; string setName = resolveURLJson["user"]["username"] + " - " + resolveURLJson["title"]; userId = resolveURLJson["user_id"]; //trackTitle = resolveURLJson["title"]; Newtonsoft.Json.Linq.JContainer tracklist = resolveURLJson["tracks"]; List <Track> tracks = new List <Track>(); foreach (var t in tracklist.Children()) { if (t["kind"].ToString() != "track") { ops.Log(String.Format("{0} : \n", "Found something other than a track!"), ConsoleColor.Red); ops.Log(String.Format("{0}", t.ToString()), ConsoleColor.Magenta); continue; } Track newTrack = JsonPopulatorService.GetTrackFromJToken(t); tracks.Add(newTrack); } PreviewSet(urlToGet); string theResult = ""; foreach (Track t in tracks) { try { theResult += GrabTrackById(t.Id, setName) + "\n\n"; } catch (Exception ex) { ExceptionThrown(ex, new EventArgs()); } } Console.WriteLine(theResult); //try //{ //} //catch (Exception ex) //{ // Console.WriteLine(trackToGetId.ToString() + " " + ex.Message); //} //finally //{ // Console.WriteLine(trackToGetId.ToString() + " finished."); //} }
static void config() { String configJson = System.IO.File.ReadAllText(@"C:\bot\config.json"); Newtonsoft.Json.Linq.JContainer jContainer = (Newtonsoft.Json.Linq.JContainer)JsonConvert.DeserializeObject(configJson); Key.key = jContainer["key"].ToString(); Key.secret = jContainer["secret"].ToString(); initialValue = decimal.Parse(jContainer["initialValue"].ToString(), System.Globalization.NumberStyles.Float); percValue = decimal.Parse(jContainer["percValue"].ToString(), System.Globalization.NumberStyles.Float); }
//https://api.cryptowat.ch/markets/coinbase-pro/btcusd/ohlc?periods=1800&after=1564617600 //https://api.exchangeratesapi.io/history?start_at=2019-08-01&end_at=2021-09-01&base=USD private decimal searchUSDValue(String json, DateTime date, String fiat) { try { Newtonsoft.Json.Linq.JContainer jsonFiat = (Newtonsoft.Json.Linq.JContainer)JsonConvert.DeserializeObject(json); return(decimal.Parse(jsonFiat["rates"][date.ToString("yyyy-MM-dd")][fiat].ToString())); } catch { Newtonsoft.Json.Linq.JContainer jsonFiat = (Newtonsoft.Json.Linq.JContainer)JsonConvert.DeserializeObject(json); return(decimal.Parse(jsonFiat["rates"][DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")][fiat].ToString())); } }
static int RemoveAll(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); Newtonsoft.Json.Linq.JContainer obj = (Newtonsoft.Json.Linq.JContainer)ToLua.CheckObject <Newtonsoft.Json.Linq.JContainer>(L, 1); obj.RemoveAll(); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int CreateWriter(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); Newtonsoft.Json.Linq.JContainer obj = (Newtonsoft.Json.Linq.JContainer)ToLua.CheckObject <Newtonsoft.Json.Linq.JContainer>(L, 1); Newtonsoft.Json.JsonWriter o = obj.CreateWriter(); ToLua.PushObject(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int Descendants(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); Newtonsoft.Json.Linq.JContainer obj = (Newtonsoft.Json.Linq.JContainer)ToLua.CheckObject <Newtonsoft.Json.Linq.JContainer>(L, 1); System.Collections.Generic.IEnumerable <Newtonsoft.Json.Linq.JToken> o = obj.Descendants(); ToLua.PushObject(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int AddFirst(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); Newtonsoft.Json.Linq.JContainer obj = (Newtonsoft.Json.Linq.JContainer)ToLua.CheckObject <Newtonsoft.Json.Linq.JContainer>(L, 1); object arg0 = ToLua.ToVarObject(L, 2); obj.AddFirst(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int Children(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); Newtonsoft.Json.Linq.JContainer obj = (Newtonsoft.Json.Linq.JContainer)ToLua.CheckObject <Newtonsoft.Json.Linq.JContainer>(L, 1); Newtonsoft.Json.Linq.JEnumerable <Newtonsoft.Json.Linq.JToken> o = obj.Children(); ToLua.PushValue(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int ReplaceAll(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); Newtonsoft.Json.Linq.JContainer obj = (Newtonsoft.Json.Linq.JContainer)ToLua.CheckObject(L, 1, typeof(Newtonsoft.Json.Linq.JContainer)); object arg0 = ToLua.ToVarObject(L, 2); obj.ReplaceAll(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public static ReturnDataArray getDataArrayCW(string coin, string timeGraph) { ReturnDataArray returnDataArray = new ReturnDataArray(); String jsonAsStringRSI = Http.get("https://api.cryptowat.ch/markets/binance/" + coin + "/ohlc?periods=" + (int.Parse(timeGraph.Replace("m", "")) * 60) + "&after=1514764800", false); Newtonsoft.Json.Linq.JContainer jsonRSI = (Newtonsoft.Json.Linq.JContainer)JsonConvert.DeserializeObject(jsonAsStringRSI); string auxarray = "300"; if (timeGraph == "5m") { auxarray = "300"; } if (timeGraph == "15m") { auxarray = "900"; } int count = 0; foreach (JContainer element in jsonRSI["result"][auxarray]) { count++; } returnDataArray.arrayPriceClose = new double[count]; returnDataArray.arrayPriceHigh = new double[count]; returnDataArray.arrayPriceLow = new double[count]; returnDataArray.arrayPriceOpen = new double[count]; returnDataArray.arrayVolume = new double[count]; returnDataArray.arrayDate = new double[count]; returnDataArray.arrayQuoteVolume = new double[count]; int i = 0; foreach (JContainer element in jsonRSI["result"][auxarray]) { returnDataArray.arrayPriceClose[i] = double.Parse(element[4].ToString().Replace(".", ",")); returnDataArray.arrayPriceHigh[i] = double.Parse(element[2].ToString().Replace(".", ",")); returnDataArray.arrayPriceLow[i] = double.Parse(element[3].ToString().Replace(".", ",")); returnDataArray.arrayPriceOpen[i] = double.Parse(element[1].ToString().Replace(".", ",")); returnDataArray.arrayVolume[i] = double.Parse(element[5].ToString().Replace(".", ",")); //returnDataArray.arrayQuoteVolume[i] = double.Parse(element[7].ToString().Replace(".", ",")); returnDataArray.arrayDate[i] = double.Parse(element[0].ToString().Replace(".", ",")); i++; } return(returnDataArray); }
static int get_Parent(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); Newtonsoft.Json.Linq.JToken obj = (Newtonsoft.Json.Linq.JToken)o; Newtonsoft.Json.Linq.JContainer ret = obj.Parent; ToLua.PushObject(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index Parent on a nil value" : e.Message)); } }
static int get_Count(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); Newtonsoft.Json.Linq.JContainer obj = (Newtonsoft.Json.Linq.JContainer)o; int ret = obj.Count; LuaDLL.lua_pushinteger(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index Count on a nil value")); } }
static int get_Last(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); Newtonsoft.Json.Linq.JContainer obj = (Newtonsoft.Json.Linq.JContainer)o; Newtonsoft.Json.Linq.JToken ret = obj.Last; ToLua.PushObject(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index Last on a nil value")); } }
static int get_HasValues(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); Newtonsoft.Json.Linq.JContainer obj = (Newtonsoft.Json.Linq.JContainer)o; bool ret = obj.HasValues; LuaDLL.lua_pushboolean(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index HasValues on a nil value")); } }
public static string GetRequestIdString(Method method) { if (method == null) { throw new ArgumentNullException("method"); } string requestIdName = "x-ms-request-id"; if (method.Extensions.ContainsKey(RequestIdExtension)) { Newtonsoft.Json.Linq.JContainer extensionObject = method.Extensions[RequestIdExtension] as Newtonsoft.Json.Linq.JContainer; if (extensionObject != null) { requestIdName = extensionObject["value"].ToString(); } } return(requestIdName); }
static OHCL[] loadData(DateTime max) { if (max == null) { DateTime.Now.AddDays(1); } String jsonAsText = System.IO.File.ReadAllText(@"Z:\temp\BTCUSDT.txt"); Newtonsoft.Json.Linq.JContainer json = (Newtonsoft.Json.Linq.JContainer)JsonConvert.DeserializeObject(jsonAsText); List <OHCL> array = new List <OHCL>(); foreach (var item in json) { try { OHCL ohcl = new OHCL(); ohcl.CurrentDate = UnixTimeStampToDateTime(float.Parse(item[0].ToString().Replace(".", ",").Substring(0, 10))); if (ohcl.CurrentDate > max) { break; } ohcl.PreviousOpen = float.Parse(item.Previous[1].ToString().Replace(".", ",")); ohcl.PreviousHigh = float.Parse(item.Previous[2].ToString().Replace(".", ",")); ohcl.PreviousLow = float.Parse(item.Previous[3].ToString().Replace(".", ",")); ohcl.NextClose = float.Parse(item[4].ToString().Replace(".", ",")); ohcl.PreviousClose = float.Parse(item.Previous[4].ToString().Replace(".", ",")); ohcl.PreviousVolume = float.Parse(item.Previous[5].ToString().Replace(".", ",")); ohcl.PreviousQuoeteAssetVolume = float.Parse(item.Previous[7].ToString().Replace(".", ",")); ohcl.PreviousTrades = int.Parse(item.Previous[8].ToString().Replace(".", ",")); array.Add(ohcl); } catch { } } return(array.ToArray()); }
public ActionResult Buscar(string RA) { try { string Url = string.Format(@"https://www.googleapis.com/mapsengine/v1/tables/16301484656389751053-01619059540675406410/features?where=RA_Aluno={0}&version=published&key=AIzaSyAsrcj7OColofVBkQHQOJDL0_dIQxGjyjY", RA); HttpClient client = null; client = new HttpClient(); client.BaseAddress = new Uri(Url); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); System.Net.Http.HttpResponseMessage response = client.GetAsync("").Result; if (response.IsSuccessStatusCode) { if (HttpRuntime.AppDomainAppPath != "") { using (FileStream f = new FileStream(HttpRuntime.AppDomainAppPath + "\\lista.txt", FileMode.Append, FileAccess.Write)) using (StreamWriter s = new StreamWriter(f)) s.WriteLine(RA); } Newtonsoft.Json.Linq.JContainer registros = response.Content.ReadAsAsync <dynamic>().Result; JValue Jlat = (JValue)registros["features"][0]["properties"]["lat"]; JValue Jlng = (JValue)registros["features"][0]["properties"]["lng"]; return(Json(new { lat = Jlat.Value, lng = Jlng.Value }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { message = ex.Message })); } return(Json(new { message = "Aluno não encontrado!" })); }
/// <summary> /// NEEDS PROPER REFACTORING /// returns the list of track URIs /// </summary> /// <param name="urlToGet"></param> /// <param name="trackToGetId"></param> /// <param name="userId"></param> /// <param name="trackTitle"></param> /// <param name="resolveURLJson"></param> private static List <string> PreviewSet(string urlToGet) { dynamic resolveURLJson = SendAPIRequest(_api.MakeCallResolveURL(urlToGet)); string trackToGetId = resolveURLJson["id"]; string setName = resolveURLJson["user"]["username"] + " - " + resolveURLJson["title"]; string userId = resolveURLJson["user_id"]; //trackTitle = resolveURLJson["title"]; Newtonsoft.Json.Linq.JContainer tracklist = resolveURLJson["tracks"]; List <Track> tracks = new List <Track>(); double playlistSize = 0; foreach (var t in tracklist.Children()) { if (t["kind"].ToString() != "track") { ops.Log(String.Format("{0} : \n", "Found something other than a track!"), ConsoleColor.Red); ops.Log(String.Format("{0}", t.ToString()), ConsoleColor.Magenta); continue; } Track newTrack = JsonPopulatorService.GetTrackFromJToken(t); tracks.Add(newTrack); } playlistSize = tracks.Sum(x => x.GetSizeInMegabytes()); ops.Log(String.Format("{0} ", setName), ConsoleColor.Green); ops.Log(String.Format("In this set listing there are {0} track(s):", tracks.Count), ConsoleColor.White); ops.Log(String.Format("Est. Total playlist size: "), ConsoleColor.White); ops.Log(String.Format("{0:N1}MB", playlistSize), ConsoleColor.Cyan); ops.LogLines(tracks.Select(t => t.ToString()).ToArray()); //tracks.ForEach(x => GetSongInfo(x.Uri)); return(tracks.Select(x => x.Uri).ToList()); }
private string[] getRawData(String url, String jsonFiat, String fiat) { String json = HttpGet(url); Newtonsoft.Json.Linq.JContainer jResult = (Newtonsoft.Json.Linq.JContainer)JsonConvert.DeserializeObject(json); int x = 0; foreach (var item in jResult["result"]["1800"]) { x++; } string[] array = new string[x]; x = 0; foreach (var item in jResult["result"]["1800"]) { if (fiat == "USD") { array[x] = Math.Round(decimal.Parse(item[1].ToString()), 2).ToString().Replace(",", "."); } else { array[x] = Math.Round((decimal.Parse(item[1].ToString()) / searchUSDValue(jsonFiat, UnixTimeStampToDateTime(double.Parse(item[0].ToString())), fiat)), 2).ToString().Replace(",", "."); } x++; } return(array); }
/// <summary> /// Delete default dashboard /// </summary> /// <param name="project"></param> /// <param name="dashBoardId"></param> /// <returns></returns> public bool DeleteDefaultDashboard(string project, string dashBoardId) { using (var client = new HttpClient()) { client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _credentials); var method = new HttpMethod("DELETE"); var request = new HttpRequestMessage(method, _configuration.UriString + project + "/" + project + "%20Team/_apis/dashboard/dashboards/" + dashBoardId + "?api-version=" + _configuration.VersionNumber + "-preview.2"); var response = client.SendAsync(request).Result; if (response.IsSuccessStatusCode) { return(true); } else { dynamic responseForInvalidStatusCode = response.Content.ReadAsAsync <dynamic>(); Newtonsoft.Json.Linq.JContainer msg = responseForInvalidStatusCode.Result; return(false); } } }
public static ReturnDataArray getDataArray(string coin, string timeGraph) { int i = 0; try { ReturnDataArray returnDataArray = new ReturnDataArray(); String jsonAsStringRSI = ""; if (source == "CACHE") { DateTime begin = DateTime.Parse("2018-01-01"); if (!System.IO.File.Exists(Program.location + @"\cache\" + coin + timeGraph + ".txt")) { System.IO.StreamWriter w = new System.IO.StreamWriter(Program.location + @"\cache\" + coin + timeGraph + ".txt", true); while (begin != DateTime.Parse("2018-12-29")) { jsonAsStringRSI = Http.get("https://api.binance.com/api/v1/klines?symbol=" + coin + "&interval=" + timeGraph + "&startTime=" + DatetimeToUnix(DateTime.Parse(begin.ToString("yyyy-MM-dd") + " 00:00:00")) + "&endTime=" + DatetimeToUnix(DateTime.Parse(begin.ToString("yyyy-MM-dd") + " 12:59:59")), false).Replace("[[", "[").Replace("]]", "]") + ","; jsonAsStringRSI += Http.get("https://api.binance.com/api/v1/klines?symbol=" + coin + "&interval=" + timeGraph + "&startTime=" + DatetimeToUnix(DateTime.Parse(begin.ToString("yyyy-MM-dd") + " 13:00:00")) + "&endTime=" + DatetimeToUnix(DateTime.Parse(begin.ToString("yyyy-MM-dd") + " 23:59:59")), false).Replace("[[", "[").Replace("]]", "]") + ","; w.Write(jsonAsStringRSI); begin = begin.AddDays(1); System.Threading.Thread.Sleep(1000); } w.Close(); w.Dispose(); jsonAsStringRSI = "[" + System.IO.File.ReadAllText(Program.location + @"\cache\" + coin + timeGraph + ".txt") + "]"; jsonAsStringRSI = jsonAsStringRSI.Substring(0, jsonAsStringRSI.Length - 1); System.IO.File.Delete(Program.location + @"\cache\" + coin + timeGraph + ".txt"); w = new System.IO.StreamWriter(Program.location + @"\cache\" + coin + timeGraph + ".txt", true); w.Write(jsonAsStringRSI); w.Close(); w.Dispose(); } jsonAsStringRSI = System.IO.File.ReadAllText(Program.location + @"\cache\" + coin + timeGraph + ".txt"); } else { jsonAsStringRSI = Http.get("https://api.binance.com/api/v1/klines?symbol=" + coin + "&interval=" + timeGraph + "&limit=1000", true); } Newtonsoft.Json.Linq.JContainer jsonRSI = (Newtonsoft.Json.Linq.JContainer)JsonConvert.DeserializeObject(jsonAsStringRSI); i = 0; foreach (JContainer element in jsonRSI.Children()) { i++; } returnDataArray.arrayPriceClose = new double[i]; returnDataArray.arrayPriceHigh = new double[i]; returnDataArray.arrayPriceLow = new double[i]; returnDataArray.arrayPriceOpen = new double[i]; returnDataArray.arrayVolume = new double[i]; returnDataArray.arrayDate = new double[i]; returnDataArray.arrayQuoteVolume = new double[i]; i = 0; foreach (JContainer element in jsonRSI.Children()) { returnDataArray.arrayPriceClose[i] = double.Parse(element[4].ToString().Replace(".", ",")); returnDataArray.arrayPriceHigh[i] = double.Parse(element[2].ToString().Replace(".", ",")); returnDataArray.arrayPriceLow[i] = double.Parse(element[3].ToString().Replace(".", ",")); returnDataArray.arrayPriceOpen[i] = double.Parse(element[1].ToString().Replace(".", ",")); returnDataArray.arrayVolume[i] = double.Parse(element[5].ToString().Replace(".", ",")); returnDataArray.arrayQuoteVolume[i] = double.Parse(element[7].ToString().Replace(".", ",")); returnDataArray.arrayDate[i] = double.Parse(element[6].ToString().Replace(".", ",")); i++; } return(returnDataArray); } catch (Exception ex) { return(null); } }
/// <summary> /// Adds the parameter groups to operation parameters. /// </summary> /// <param name="serviceClient"></param> public static void AddParameterGroups(ServiceClient serviceClient) { if (serviceClient == null) { throw new ArgumentNullException("serviceClient"); } HashSet <CompositeType> generatedParameterGroups = new HashSet <CompositeType>(); foreach (Method method in serviceClient.Methods) { //This group name is normalized by each languages code generator later, so it need not happen here. Dictionary <string, Dictionary <Property, Parameter> > parameterGroups = new Dictionary <string, Dictionary <Property, Parameter> >(); foreach (Parameter parameter in method.Parameters) { if (parameter.Extensions.ContainsKey(ParameterGroupExtension)) { Newtonsoft.Json.Linq.JContainer extensionObject = parameter.Extensions[ParameterGroupExtension] as Newtonsoft.Json.Linq.JContainer; if (extensionObject != null) { string specifiedGroupName = extensionObject.Value <string>("name"); string parameterGroupName; if (specifiedGroupName == null) { string postfix = extensionObject.Value <string>("postfix") ?? "Parameters"; parameterGroupName = method.Group + "-" + method.Name + "-" + postfix; } else { parameterGroupName = specifiedGroupName; } if (!parameterGroups.ContainsKey(parameterGroupName)) { parameterGroups.Add(parameterGroupName, new Dictionary <Property, Parameter>()); } Property groupProperty = new Property() { IsReadOnly = false, //Since these properties are used as parameters they are never read only Name = parameter.Name, IsRequired = parameter.IsRequired, DefaultValue = parameter.DefaultValue, //Constraints = parameter.Constraints, Omit these since we don't want to perform parameter validation Documentation = parameter.Documentation, Type = parameter.Type, SerializedName = null //Parameter is never serialized directly }; parameterGroups[parameterGroupName].Add(groupProperty, parameter); } } } foreach (string parameterGroupName in parameterGroups.Keys) { CompositeType parameterGroupType = generatedParameterGroups.FirstOrDefault(item => item.Name == parameterGroupName); bool createdNewCompositeType = false; if (parameterGroupType == null) { parameterGroupType = new CompositeType() { Name = parameterGroupName, Documentation = "Additional parameters for the " + method.Name + " operation." }; generatedParameterGroups.Add(parameterGroupType); //Populate the parameter group type with properties. //Add to the service client serviceClient.ModelTypes.Add(parameterGroupType); createdNewCompositeType = true; } foreach (Property property in parameterGroups[parameterGroupName].Keys) { //Either the paramter group is "empty" since it is new, or it is "full" and we don't allow different schemas if (createdNewCompositeType) { parameterGroupType.Properties.Add(property); } else { Property matchingProperty = parameterGroupType.Properties.FirstOrDefault( item => item.Name == property.Name && item.IsReadOnly == property.IsReadOnly && item.DefaultValue == property.DefaultValue && item.SerializedName == property.SerializedName); if (matchingProperty == null) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Property {0} was specified on group {1} but it is not on shared parameter group object {2}", property.Name, method.Name, parameterGroupType.Name)); } } } bool isGroupParameterRequired = parameterGroupType.Properties.Any(p => p.IsRequired); //Create the new parameter object based on the parameter group type Parameter parameterGroup = new Parameter() { Name = parameterGroupName, IsRequired = isGroupParameterRequired, Location = ClientModel.ParameterLocation.None, SerializedName = string.Empty, Type = parameterGroupType, Documentation = "Additional parameters for the operation" }; method.Parameters.Add(parameterGroup); //Link the grouped parameters to their parent, and remove them from the method parameters foreach (Property property in parameterGroups[parameterGroupName].Keys) { Parameter p = parameterGroups[parameterGroupName][property]; var parameterTransformation = new ParameterTransformation { OutputParameter = p }; parameterTransformation.ParameterMappings.Add(new ParameterMapping { InputParameter = parameterGroup, InputParameterProperty = property.Name }); method.InputParameterTransformation.Add(parameterTransformation); method.Parameters.Remove(p); } } } }
internal void ReadContentFrom(JsonReader r, JsonLoadSettings settings) { ValidationUtils.ArgumentNotNull(r, nameof(r)); IJsonLineInfo lineInfo = r as IJsonLineInfo; JContainer parent = this; do { if ((parent as JProperty)?.Value != null) { if (parent == this) { return; } parent = parent.Parent; } switch (r.TokenType) { case JsonToken.None: // new reader. move to actual content break; case JsonToken.StartArray: JArray a = new JArray(); a.SetLineInfo(lineInfo, settings); parent.Add(a); parent = a; break; case JsonToken.EndArray: if (parent == this) { return; } parent = parent.Parent; break; case JsonToken.StartObject: JObject o = new JObject(); o.SetLineInfo(lineInfo, settings); parent.Add(o); parent = o; break; case JsonToken.EndObject: if (parent == this) { return; } parent = parent.Parent; break; case JsonToken.StartConstructor: JConstructor constructor = new JConstructor(r.Value.ToString()); constructor.SetLineInfo(lineInfo, settings); parent.Add(constructor); parent = constructor; break; case JsonToken.EndConstructor: if (parent == this) { return; } parent = parent.Parent; break; case JsonToken.String: case JsonToken.Integer: case JsonToken.Float: case JsonToken.Date: case JsonToken.Boolean: case JsonToken.Bytes: JValue v = new JValue(r.Value); v.SetLineInfo(lineInfo, settings); parent.Add(v); break; case JsonToken.Comment: if (settings != null && settings.CommentHandling == CommentHandling.Load) { v = JValue.CreateComment(r.Value.ToString()); v.SetLineInfo(lineInfo, settings); parent.Add(v); } break; case JsonToken.Null: v = JValue.CreateNull(); v.SetLineInfo(lineInfo, settings); parent.Add(v); break; case JsonToken.Undefined: v = JValue.CreateUndefined(); v.SetLineInfo(lineInfo, settings); parent.Add(v); break; case JsonToken.PropertyName: string propertyName = r.Value.ToString(); JProperty property = new JProperty(propertyName); property.SetLineInfo(lineInfo, settings); JObject parentObject = (JObject)parent; // handle multiple properties with the same name in JSON JProperty existingPropertyWithName = parentObject.Property(propertyName); if (existingPropertyWithName == null) { parent.Add(property); } else { existingPropertyWithName.Replace(property); } parent = property; break; default: throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(CultureInfo.InvariantCulture, r.TokenType)); } } while (r.Read()); }