Coder Social home page Coder Social logo

kucoin-node-api's People

Contributors

darkgl avatar dependabot[bot] avatar escwdev avatar fahadalbukhari avatar hishamudeen avatar jaggedsoft avatar mohaiminuleraj avatar pradyumnad avatar reiniervanderhoeven avatar rhinodavid avatar shadowstep33 avatar transakliquidity avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

kucoin-node-api's Issues

borrowing & lending data?

Hi, is there any plans to add the borrowing and lending information from kucoin API into this wrapper? thanks!

[WS] Invalid URL: undefined on sandbox

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' }

July 13, 2020 KuCoin Update

image
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

  1. connect to websocket
  2. put all messages from websocket into a queue
  3. download the full orderbook snapshot (uses a lot of weight, can only do one market per 3 seconds or so)
  4. process the queue backlog, but only items with a higher sequence id than what you just downloaded
  5. process realtime websockets as they come

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

  1. Add Private Channel Messages
    2. Full MatchEngine Data (revision) (Level 3)
    3. Level2 - 5 best ask/bid orders
    4. Level2 - 50 best ask/bid orders
  2. Add Get Full Order Book(atomic)(revision)

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

code

hello good day where did you code this program? in what editor? thank you i hope u can help me

^ TypeError: Cannot read properties of undefined (reading 'init')

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 )

What am I doing wrong? (spot limit order)

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!

Problem with "PRIVATE" endpoint

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 !

New REST and Websocket Endpoints

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.

Closing ws stream

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?

Typescript Interfaces

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

Websocket 'orders'

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.

Websocket enotfound

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 "Place Bulk Orders"

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)

Error 400005

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?

having issue with Margin Trading

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:

  1. the end point in trade.js file should change from '/api/v1/orders' to '/api/v1/margin/order'
  2. im getting 'You must enable Margin Trading.' with status 100000 and i know its about permissions. the point is i already gave this permission to api from kucoin dashboard api managment.

and i need help for sending a request with this details

  1. margin mode enabled with type 'market' so i give it the amount of USDT and api buy the coin (in my case XRP) with bestBid price that i'm getting from 'getTicker' method
  2. set the stopLoss and takeProfit by percent (price is ok. i will calculate it my self)
  3. defining SHORT or LONG for the order (i didn't figure it out. is it the side param? (BUY or SELL) )
    thanks in advance...
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))
        })
    }

0 dealFunds/dealSize after successful trade

image

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.

Websockets for Public topics not providing sign fails.

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

How to configure proxy?

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.

getSymbols API not working with market parameter

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.

example bots?

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.