Skip to content

having issue with Margin Trading #57

@sinavali

Description

@sinavali

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions