escwdev / kucoin-node-api Goto Github PK
View Code? Open in Web Editor NEWNode.js KuCoin Cryptocurrency Exchange v2 API Wrapper/SDK
Node.js KuCoin Cryptocurrency Exchange v2 API Wrapper/SDK
Hi, is there any plans to add the borrowing and lending information from kucoin API into this wrapper? thanks!
Hi. Thanks for awesome library !
I experienced a bug when trying to api.initSocket (topic: orders) when connecting to sandbox.
Error:
TypeError [ERR_INVALID_URL]: Invalid URL: undefined at new NodeError (node:internal/errors:329:5) at onParseError (node:internal/url:282:9) at new URL (node:internal/url:358:5) at initAsClient (/xxx/node_modules/kucoin-node-api/node_modules/ws/lib/websocket.js:484:27) at new WebSocket (/xxx/node_modules/kucoin-node-api/node_modules/ws/lib/websocket.js:70:7) at Object.Sockets.initSocket (/xxx/node_modules/kucoin-node-api/lib/websockets.js:58:14) at processTicksAndRejections (node:internal/process/task_queues:94:5) { input: 'undefined', code: 'ERR_INVALID_URL' }
Hi,
how to get Callback when websocket is closed?
kucoin pushes the whole entire orderbook to you over websocket now
no other exchange does that as far as i know
normally you've gotta do a whole bunch of BS first
now you could get ALL orders from all markets at once if your machine can handle it
I'm gonna push an update that allows people to specify their own websocket endpoints, and add a shortcut for the 50 best bid/ask depth
if anyone else wants to tackle the rest of the list be my guest otherwise i'll probably get around to it eventually
Want to join a cool crypto discord? there are some really talented folks in here and you would probably feel right at home
https://discord.gg/a8m7pCQ
hello good day where did you code this program? in what editor? thank you i hope u can help me
Dependencies shouldn't be committed in the project.
i get the error after to init
api.init(initConfig) ^ TypeError: Cannot read properties of undefined (reading 'init')
cannot read api after import.
import api from 'kucoin-node-api';
const config = {
apiKey: kucoinApiKey,
secretKey: kucoinApiSecret,
passphrase: kucoinApiPassphrase,
environment: productionEnv() ? "live" : 'sandbox'
};
api.init(config )
Hi,
Fairly new to this and it seems i'm doing something wrong...
I try to set a Limit order in BTC-USDT as a test but I get a "undefined" back as response.
This is the code i'm using:
api.placeOrder({clientOid: "test", side: "buy", symbol: "BTC-USDT", type: "limit", price: "49500", size: "60"}).then((r) => { console.log(r.data) }).catch((e) => { console.log(e) })
The only response I get is:
undefined
Can you give me a clue what i'm doing wrong?
Thanks!
Detailed Error description:
Error: getaddrinfo ENOTFOUND openapi-v2.kucoin.comapi openapi-v2.kucoin.comapi:443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
errno: 'ENOTFOUND',
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'openapi-v2.kucoin.comapi',
host: 'openapi-v2.kucoin.comapi',
port: 443,
Hello !
I just created an API Key on my sub account in order to do some test with their API.
The problem is when I want to do :
await api.getAccounts()
I have this error :
TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
I checked all parameters, my connection, API credentials... Nothing work.
Thanks in advance !
There are a bunch of new endpoints related to Kucoin margin trading that need to be added. Putting here for visibility. I may get around to it but will also review and accept any contributions that are solid.
Hello, I already commented this in another issue but figured it'd be appropriate to create an issue of my own.
I'm opening a websocket with:
const ws = api.initSocket( { topic: 'ticker', symbols: [BTC-USDT] }, (msg) => { let data = JSON.parse(msg); console.log(data); }
Then calling:
ws();
to close the stream I receive the error
TypeError: ws is not a function
Any idea why I'm getting this? Is this the correct way to close the ws?
Would it be possible to add typescript interfaces to your package? I'm using it and love it. If you don't have the time or bandwidth, I have a fork and may do it, too, but if you can, that would make my life so much easier.
I really appreciate it!
-JI
i have problem with private metods
{ code: '400001',
msg: 'Please check the header of your request for KC-API-KEY, KC-API-SIGN, KC-API-TIMESTAMP, KC-API-PASSPHRASE' } } }
Hey I think I found a bug,
when using the ws topic 'orders' I get an invalid topic error.
I could fix it by replacing '/market/level3:' with '/spotMarket/tradeOrders' in line 140 of the lib/websockets.js
file.
Hope this helps.
Hi, i'm getting this error when I try to init a websocket:
{ Error: getaddrinfo ENOTFOUND push1-v2.kucoin.com push1-v2.kucoin.com:80
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
errno: 'ENOTFOUND',
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'push1-v2.kucoin.com',
host: 'push1-v2.kucoin.com',
port: 80 }
Add support for "Place Bulk Orders"
https://docs.kucoin.com/#place-bulk-orders
Like that:
/*
Place Bulk Orders
POST /api/v1/orders/multi
Details for params see https://docs.kucoin.com/#place-bulk-orders
General params
params = {
symbol: string,
orderList: [
{
clientOid: string
side: string ['buy' || 'sell]
type: string [optional, default: limit] - limit or market
remark: string [optional]
stop: string [optional] - either loss or entry and needs stopPrice
stopPrice: string [optional] - needed for stop
stp: string [optional] (self trade prevention)
tradeType: string [optional, default: TRADE] - TRADE (Spot Trade), MARGIN_TRADE (Margin Trade)
price: string,
size: string,
timeInForce: string [optional, default is GTC]
cancelAfter: long (unix time) [optional]
postOnly: boolean [optional] - Post only flag, invalid when timeInForce is IOC or FOK
hidden: boolean [optional]
Iceberg: boolean [optional]
visibleSize: string [optional]
}
]
}
*/
api.placeBulkOrders(params)
Current latest version is 7.4.4
Getting this error when trying api.placeOrder, not sure where it comes from, all the other endpoints work just fine (can get accounts, balances etc)
data: { code: '400005', msg: 'Invalid KC-API-SIGN' }
Anyone having the same problem? any solution?
i never done crypto bot projects before so i may have some glitches here...
public methods are working just fine...
in private methods, placeOrder methods to be specific there is 2 error:
and i need help for sending a request with this details
placeOrder(side) {
return new Promise(async (resolve, reject) => {
let latestData = {}
await api.getTicker(process.env.CRYPTO_PAIR + '-USDT').then(r => latestData = r.data).then(r => console.log(r)).catch(err => reject(err))
let fund = 3
let params = {
clientOid: latestData.time,
side: side,
symbol: process.env.CRYPTO_PAIR + '-USDT',
tradeType: 'MARGIN_TRADE',
type: 'market',
stop: 'loss',
stopPrice: latestData.bestBid - (latestData.bestBid / 100 * process.env.STOP_LOSS_PERCENT),
timestamp: latestData.time,
fund,
size: fund / latestData.bestBid
}
await api.placeOrder(params).then(r => resolve(r)).catch(err => reject(err))
})
}
On occasion after performing a trade, I sometimes log the output of the trade data. Sometimes I am seeing that the keys dealFunds and dealSize are 0, when they should not be. This is important if I want to do a trade in sequence to know those values; in other words, the base currency I receive can also be repurposed as the quote currency.
Is there any way we can get a function to get the current and next funding rate?
This should be fixable by doing this.
--- a/lib/websockets.js
+++ b/lib/websockets.js
@@ -53,7 +53,10 @@ Sockets.initSocket = async function(params, eventHandler) {
if ( !params.sign ) params.sign = false;
if ( !params.endpoint ) params.endpoint = false;
let [topic, endpoint, type] = Sockets.topics( params.topic, params.symbols, params.endpoint, params.sign )
- let sign = this.sign('/api/v1/bullet-private', {}, 'POST')
+ var sign = null;
+ if (params.sign) {
+ sign = this.sign('/api/v1/bullet-private', {}, 'POST')
+ }
let websocket = await getSocketEndpoint(type, this.baseURL, this.environment, sign)
let ws = new WebSocket(websocket)
Sockets.ws[topic] = ws
I'm trying to start websocket with a proxy. But its not working as expected. Is there any config changes we have to do to enable proxy?
In axios http adaptor, I found a set proxy config but not sure how to use it.
The query parameter is missing in the query string.
market.js line number 11 replace
From:
let endpoint = '/api/v1/symbols'
To:
let endpoint = `/api/v1/symbols?market=${market}`
I hope this will help.
Thank you very much for developing this library.
I think there is a bug. The getFullOrderBook method is not available.
The getFullOrderBook method is not available. Instead there are two methods getFullOrderBookAtomic. I guess the first of the two (/api/v2/market/orderbook/level2?Symbol = $ {symbol}
) should be called getFullOrderBook.
https://github.com/escwdev/kucoin-node-api/blob/master/lib/market.js#L96
Thank you.
I'm looking to create a bot that buys at 5% dip and sells at 10% gain. Just do this over and over.
Before I started I wanted to know if anyone knows of any example bots before I recreate the wheel.
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.