mscheetz / kucoinapi.net Goto Github PK
View Code? Open in Web Editor NEWKuCoin api access built in .Net Standard
License: MIT License
KuCoin api access built in .Net Standard
License: MIT License
Hi. I have troubles with lib. Pls help) I think i made a stupid mistake. Whats wrong here?
public static string apiKey = "xxx";
public static string apiSecret = "yyy";
public static string apiPassword = "zzz";
static void Main(string[] args) {
var clientOid = Guid.NewGuid().ToString().Replace("-", "");
var body = new SortedDictionary <string, object>();
body.Add("clientOid", clientOid);
body.Add("symbol", "BTC-LTC");
body.Add("price", 0.1);
body.Add("side", "BUY");
body.Add("size", 0.6);
body.Add("type", "LIMIT");
var timestamp0 = Convert.ToInt64(Regex.Match(new WebClient().DownloadString("https://openapi-v2.kucoin.com/api/v1/timestamp"), "(?<=data\":).+(?=})").Value);
var headers = GetRequestHeaders(HttpMethod.Post, "https://openapi-v2.kucoin.com/api/v1/orders",
Convert.ToInt64(timestamp0), body);
var request = (HttpWebRequest) WebRequest.Create("https://openapi-v2.kucoin.com/api/v1/orders");
request.ContentType = "application/json";
request.Method = "POST";
foreach(KeyValuePair <string, string> entry in headers) {
request.Headers.Add(entry.Key, entry.Value);
}
using(var streamWriter = new StreamWriter(request.GetRequestStream())) {
string json = JsonConvert.SerializeObject(headers);
streamWriter.Write(json);
}
var response = (HttpWebResponse) request.GetResponse();
using(var streamReader = new StreamReader(response.GetResponseStream())) {
var result = streamReader.ReadToEnd();
}
}
private static Dictionary <string, string> GetRequestHeaders(HttpMethod httpMethod, string endpoint, long timestamp, SortedDictionary <string, object> body = null) {
var headers = new Dictionary <string, string>();
headers.Add("KC-API-KEY", apiKey);
headers.Add("KC-API-SIGN", new Security().GetSignature(httpMethod.ToString(), endpoint, timestamp, apiSecret, body));
headers.Add("KC-API-TIMESTAMP", timestamp.ToString());
headers.Add("KC-API-PASSPHRASE", apiPassword);
return headers;
}
Dear developer,
I need function "List dealt orders(merged)" from kucoin api documentation, but your Lib hasn't it (May be I mistake?). Can you add it? It is important, that symbol field can be empty, in this case all user history returned by server. Hope you will have time to add this functionality to your library. Thx.
Dear Developer,
I tried to use private (trade) Kucoin API, and have trouble.
When I try to get Balances, I got exception in GetApiStream in OnGetBalances:
Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'KuCoinApi.NetCore.Entities.Balance[]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path 'data.total', line 1, position 99.
Hope you can help. Thx.
Dear developers,
I found that request "https://api.kucoin.com/v1/order/active-map?symbol=" returns all open user's orders. Can you add this feature to your sdk?
Thanks :)
I tried to get list fills with request parameters:
The reponse content is a message "Get List Fills doesn't support get fills in a large timespan (> 24 hours)" with code "400100"
Dear developer,
today I download from nuget KuCoinApi.Net (0.3.0) and error occurs during debug my app:
MissingMethodException: Method not found: "System.Threading.Tasks.Task1<!!0> RESTApiAccess.Interface.IRESTRepository.GetApiStream(System.String, System.Collections.Generic.Dictionary
2<System.String,System.String>)".
I downgraded verison of RESTApiAccess from 1.3.0 to 1.2.1 and app works now. Please, fix this issue.
According to the API this should work and it does. The test explorer fails until this edit is made.
///
return await Get<TradingPairStats>(endpoint, false);
}
Hi, i have an issue. I am trying to run the following code on a command promt/console but i keep getting this error
Severity Code Description Project File Line Suppression State
Error CS5001 Program does not contain a static 'Main' method suitable for an entry point KCSBOTBROS C:\Users\ribei\OneDrive\Ambiente de Trabalho\KCSBOTBROS\CSC 1 Active
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
using System.Threading;
using KuCoinApi.Net;
namespace KCSBOTBROS
{
public class Program
{
static async void Main(string[] args)
{
Console.Title = "KCSBotBros";
IKuCoinDotNet kucoin = new KuCoinDotNet("1", "1", "1");
Console.ForegroundColor = ConsoleColor.White;
Console.Write("Input the asset you want to invest with:");
string asset = Console.ReadLine();
Console.Write("Input the amount you want to invest:");
string amount = Console.ReadLine();
Console.Write("Input the desired profit(%):");
string profit = Console.ReadLine();
Console.Write("Input symbol:");
string symbol = Console.ReadLine();
string pair = symbol + "-" + asset;
decimal price;
var market_order = await kucoin.PlaceMarketOrder(pair, KuCoinApi.Net.Entities.Side.BUY, 1);
var orderdetails = await kucoin.GetOrder(market_order);
price = orderdetails.DealFunds / orderdetails.DealSize;
Console.WriteLine("Deal Funds:" + orderdetails.DealFunds + "\n" + "Deal Size:" + orderdetails.DealSize + "\n" + "Deal Price:" + price);
}
}
}
Dear developer,
please, add GetAllTickers function (GET /api/v1/market/allTickers) for v2 branch.
Thank you.
I am currently trying to retrieve both historical orders and the newer fills after the 2.0 update. I am running into a bit of trouble with the newer GetFills() method.
On my account, I have trade history data from prior to the update and after. The Historical orders endpoint works fine, but I don't get any data back when calling GetFills(). Here are the trades on my account I am trying to retrieve:
Both uses of this endpoint return no data when called:
Is it possible that I am missing something when using this endpoint?
Thanks!
Hi, i was wondering if am i able to use this code in a Windows Form Application(.NET Framework)?I am trying to build an application where the user can do everything he would do in the kucoin website/app! I am finding a hard time using the code.
Helper.CreateDashedPair uses substring of 3's, except not all coins have a length of 3
I haven't run the program nor tests, but I don't think this is correct.
e.g. TOMO-BTC
would make https://api.kucoin.com/v1/open/chart/history?symbol=TOM-BTC
and throw SYMBOL NOT FOUND
instead of https://api.kucoin.com/v1/open/chart/history?symbol=TOMO-BTC
Suggest you lazy load coins in some dictionary to map them symbol <-> kuPair
Dear developer,
please, add request to obtain the server list and authorized token for Private channels of websockets (POST /api/v1/bullet-private).
Thank you :)
Dear developer,
kucoin API updated to v2. Old API didn't work. Can you update your library?
Hi,
thx for effort, but I always need to figure out the correct endpoints, because almost none of them works, i.e. /timestamp instead of v1/time, and then fails on getbalance. Has kucoin changed these during their new API development?
Dear developer,
today I tested new feature of version 0.3.0 - GetPrivateChannels. It doesn't work:
Exception: {"code":"400005","msg":"Invalid KC-API-SIGN"}
Other functions like GetBalances work good. Please, fix this issue :)
public int IntervalToKuCoinInterval(Interval interval)
{
switch (interval)
{
case Interval.OneM:
return 0;
case Interval.ThreeM:
return 1;
case Interval.FiveM:
return 2;
case Interval.FifteenM:
return 3;
case Interval.ThirtyM:
return 4;
case Interval.OneH:
return 5;
case Interval.TwoH:
return 6;
case Interval.FourH:
return 7;
case Interval.SixH:
return 8;
case Interval.EightH:
return 9;
case Interval.TwelveH:
return 10;
case Interval.OneD:
return 11;
case Interval.OneW:
return 12;
default:
return 0;
}
}
hi dear
I can not find api credential time out
we must to send apiKey, secret in every request
or
kuCoin has expireTime ?
thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.