Closed eyefate closed 4 years ago
I've placed a lot of orders through this library and generally don't have issues apart from the occasional failures due to 503 Unavailable Server or insuffient balance etc...
That said I use pretty much the same parameters apart from side/symbol/quantity. This makes me think the issue may be related to the parameters. If one isn't inputted correctly, the header signature would be invalid and may send back the error you're getting.
Can we have an example of your call?
api.placeOrder(side="buy",symbol="WXT-USDT",type="limit",price="0.007778",size="20").then((r) => { console.log(r.data) }).catch((e) => { console.log(e) })
Formating as api.placeOrder({"side":"buy","symbol":"WXT-USDT","type":"limit","price":"0.007778","size":"20"})
Returns undefined
clientOid
is a required parameter so that could be your issue. I use a uuid
for it but it can be any unique value (i.e. if you use 1 and try to use 1 again the 2nd trade will fail). For quick testing and no added dependencies, Date.now()
can work well since it should always be unique (unless you are sending a lot of orders at once in which case I recommend using uuid
).
Also, you don't need to stringify your requests, the library handles that for you so this should work.
api.placeOrder({
clientOid: Date.now(),
side: "buy",
symbol: "WXT-USDT",
type: "limit", // Note limit is default so this can be omitted
price: 0.007778,
size: 20
}).then(r => console.log(r.data)).catch(e => console.log(e));
Let me know if that works for you.
Working now, was my fault, i had to move funds to trade account apparently and error showed as undefined, have a good one!
;)
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?