static void Main(string[] args) { var url = "http://localhost:18080/kabusapi/wallet/cash"; string token = GenerateToken.GetToken(); try { var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, url); request.Headers.Add("X-API-KEY", token); HttpResponseMessage response = client.SendAsync(request).Result; Console.WriteLine("{0} \n {1}", JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result), response.Headers); } catch (HttpRequestException e) { Console.WriteLine("{0} {1}", e, e.Message); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine("{0} {1}", ex, ex.Message); Console.ReadKey(); } Console.ReadKey(); }
static void Main(string[] args) { var obj = new { OrderId = "20200709A02N04712032", Password = "******" }; var url = "http://localhost:18080/kabusapi/cancelorder"; string token = GenerateToken.GetToken(); try { var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Put, url); request.Headers.Add("ContentType", "application/json"); request.Headers.Add("X-API-KEY", token); request.Content = new StringContent(JsonConvert.SerializeObject(obj), Encoding.UTF8, "application/json"); HttpResponseMessage response = client.SendAsync(request).Result; Console.WriteLine("{0} \n {1}", JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result), response.Headers); } catch (HttpRequestException e) { Console.WriteLine("{0} {1}", e, e.Message); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine("{0} {1}", ex, ex.Message); Console.ReadKey(); } Console.ReadKey(); }
static void Main(string[] args) { var obj = new { Password = "******", Symbol = "9433", Exchange = 1, SecurityType = 1, FrontOrderType = 30, Side = "1", CashMargin = 3, MarginTradeType = 2, DelivType = 0, AccountType = 2, Qty = 100, ClosePositionOrder = 1, Price = 2762.5, ExpireDay = 0, ReverseLimitOrder = new { TriggerSec = 2, TriggerPrice = 30000, UnderOver = 2, AfterHitOrderType = 2, AfterHitPrice = 8435 } }; var url = "http://localhost:18080/kabusapi/sendorder"; string token = GenerateToken.GetToken(); try { var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, url); request.Headers.Add("ContentType", "application/json"); request.Headers.Add("X-API-KEY", token); request.Content = new StringContent(JsonConvert.SerializeObject(obj), Encoding.UTF8, "application/json"); HttpResponseMessage response = client.SendAsync(request).Result; Console.WriteLine("{0} \n {1}", JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result), response.Headers); } catch (HttpRequestException e) { Console.WriteLine("{0} {1}", e, e.Message); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine("{0} {1}", ex, ex.Message); Console.ReadKey(); } Console.ReadKey(); }
static void Main(string[] args) { string product = "4"; string symbol = ""; string token = GenerateToken.GetToken(); var builder = new UriBuilder("http://localhost:18080/kabusapi/positions"); var param = System.Web.HttpUtility.ParseQueryString(builder.Query); if (!string.IsNullOrEmpty(product)) { param["Product"] = product; } if (!string.IsNullOrEmpty(symbol)) { param["symbol"] = symbol; } builder.Query = param.ToString(); string url = builder.ToString(); try { var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, url); request.Headers.Add("X-API-KEY", token); HttpResponseMessage response = client.SendAsync(request).Result; Console.WriteLine("{0} \n {1}", JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result), response.Headers); } catch (HttpRequestException e) { Console.WriteLine("{0} {1}", e, e.Message); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine("{0} {1}", ex, ex.Message); Console.ReadKey(); } Console.ReadKey(); }
static void Main(string[] args) { string PutOrCall = "C"; int DerivMonth = 0; int StrikePrice = 24000; string token = GenerateToken.GetToken(); var builder = new UriBuilder("http://localhost:18080/kabusapi/symbolname/option"); var param = HttpUtility.ParseQueryString(builder.Query); param["DerivMonth"] = DerivMonth.ToString(); param["PutOrCall"] = PutOrCall; param["StrikePrice"] = StrikePrice.ToString(); builder.Query = param.ToString(); string url = builder.ToString(); try { var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, url); request.Headers.Add("X-API-KEY", token); HttpResponseMessage response = client.SendAsync(request).Result; Console.WriteLine("{0} \n {1}", JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result), response.Headers); } catch (HttpRequestException e) { Console.WriteLine("{0} {1}", e, e.Message); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine("{0} {1}", ex, ex.Message); Console.ReadKey(); } Console.ReadKey(); }
static void Main(string[] args) { var obj = new { Symbols = new[] { new { Symbol = "8001", Exchange = 1 }, new { Symbol = "101", Exchange = 1 }, new { Symbol = "8316", Exchange = 1 }, new { Symbol = "5020", Exchange = 1 }, new { Symbol = "6727", Exchange = 1 } } }; var url = "http://localhost:18080/kabusapi/register"; string token = GenerateToken.GetToken(); try { var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Put, url); request.Headers.Add("ContentType", "application/json"); request.Headers.Add("X-API-KEY", token); request.Content = new StringContent(JsonConvert.SerializeObject(obj), Encoding.UTF8, "application/json"); HttpResponseMessage response = client.SendAsync(request).Result; Console.WriteLine("{0} \n {1}", JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result), response.Headers); } catch (HttpRequestException e) { Console.WriteLine("{0} {1}", e, e.Message); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine("{0} {1}", ex, ex.Message); Console.ReadKey(); } Console.ReadKey(); }
static void Main(string[] args) { string FutureCode = "NK225"; int DerivMonth = 202109; var builder = new UriBuilder("http://localhost:18080/kabusapi/symbolname/future"); var param = HttpUtility.ParseQueryString(builder.Query); string token = GenerateToken.GetToken(); if (!string.IsNullOrEmpty(FutureCode)) { param["FutureCode"] = FutureCode; } param["DerivMonth"] = DerivMonth.ToString(); builder.Query = param.ToString(); string url = builder.ToString(); try { var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, url); request.Headers.Add("X-API-KEY", token); HttpResponseMessage response = client.SendAsync(request).Result; Console.WriteLine("{0} \n {1}", JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result), response.Headers); } catch (HttpRequestException e) { Console.WriteLine("{0} {1}", e, e.Message); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine("{0} {1}", ex, ex.Message); Console.ReadKey(); } Console.ReadKey(); }
static void Main(string[] args) { string Type = "1"; string ExchangeDivision = "ALL"; string token = GenerateToken.GetToken(); var builder = new UriBuilder("http://localhost:18080/kabusapi/ranking"); var param = System.Web.HttpUtility.ParseQueryString(builder.Query); param["type"] = Type; param["exchange"] = ExchangeDivision; builder.Query = param.ToString(); string url = builder.ToString(); try { var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, url); request.Headers.Add("X-API-KEY", token); HttpResponseMessage response = client.SendAsync(request).Result; Console.WriteLine("{0} \n {1}", JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result), response.Headers); } catch (HttpRequestException e) { Console.WriteLine("{0} {1}", e, e.Message); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine("{0} {1}", ex, ex.Message); Console.ReadKey(); } Console.ReadKey(); }
static void Main(string[] args) { var obj = new { Password = "******", Symbol = "165120018", Exchange = 23, TradeType = 2, TimeInForce = 1, Side = "2", Qty = 3, ClosePositions = new[] { new { HoldID = "E20200924*****", Qty = 2 }, new { HoldID = "E20200924*****", Qty = 1 } }, FrontOrderType = 30, Price = 22000, ExpireDay = 0, ReverseLimitOrder = new { TriggerPrice = 26010, UnderOver = 2, AfterHitOrderType = 1, AfterHitPrice = 0 } }; var url = "http://localhost:18080/kabusapi/sendorder/future"; string token = GenerateToken.GetToken(); try { var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, url); request.Headers.Add("ContentType", "application/json"); request.Headers.Add("X-API-KEY", token); request.Content = new StringContent(JsonConvert.SerializeObject(obj), Encoding.UTF8, "application/json"); HttpResponseMessage response = client.SendAsync(request).Result; Console.WriteLine("{0} \n {1}", JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result), response.Headers); } catch (HttpRequestException e) { Console.WriteLine("{0} {1}", e, e.Message); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine("{0} {1}", ex, ex.Message); Console.ReadKey(); } Console.ReadKey(); }