Coder Social home page Coder Social logo

3commas-api-node's People

Contributors

amantel avatar argon007 avatar dependabot[bot] avatar hscomp2002 avatar mamash avatar papegaill avatar rentorm avatar richjenks 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

Watchers

 avatar  avatar  avatar

3commas-api-node's Issues

Path params and hitting URL length limit (Unexpected end of JSON input)

Good Evening,

I have been seeing errors in my logs for the last week or so that cropped up from no code change. I use kucoin as my exchange and I update the bot settings when new pairs are added. Over the last few weeks I have seen the coins go from 790 to over 830 and sometime from 820ish I started seeing the exception
FetchError: invalid json response body at https://api.3commas.io/public/api/ver1/bots/** reason: Unexpected end of JSON input

I was still able to use the same endpoint with a smaller list, but I am unable to update the list with all current kucoin USDT pairs.

I propose for POST/PUT calls we use the body instead of a query string within
async makeRequest(method, path, params) { on line 24 in threeCommasAPI class.

From 3Commas documentation:

  • For GET endpoints, parameters must be sent as a query string.
  • For POST, PUT, and DELETE endpoints, the parameters may be sent as a query string or in the request body with content type application/x-www-form-urlencoded or application/json. You may mix parameters between both the query string and request body if you wish to do so.
  • Parameters may be sent in any order.
  • If a parameter sent in both the query string and request body, the query string parameter will be used.

Grid bots?

I'd love to see this package add support for 3c's grid bots!

Invalid signature

With the updated version, 3commas says the signature is not valid anymore for me? Did they also change something about that process?

Object {error: "signature_invalid", error_description: "Provided signature is invalid"}

R version

Hi rentorm,
Do you think it would be possible to create this for R?
As I struggle to use 3commas' API in R, this would be very helpful in fetching my data from 3commas using R scripts.
Best,
Rhydderch

botUpdate Function bug passing arrays

i used below example but it always update the pairs "with last pair in the array", below is an example

const botUpdate = async () => {
let data = await api.botUpdate(
{
name: 'ABC',
pairs: [ 'USDT_BTC', 'USDT_ADA', 'USDT_XRP' ],
base_order_volume: '10.0',
take_profit: '0.2',
safety_order_volume: '10.0',
martingale_volume_coefficient: '0.5',
martingale_step_coefficient: '0.25',
max_safety_orders: 2,
active_safety_orders_count: 2,
safety_order_step_percentage: '1.0',
take_profit_type: 'total',
strategy_list: [
{ options: {time: "1m", type: 'buy_or_strong_buy'}, strategy: 'trading_view' }
],
bot_id: XXXXXXXXX
}
)
}
botUpdate()

1st Issue: the trading pairs is only updated to the single last pair
2nd Issue: strategy_list is not updated in the bot at all

Sell steps are not being passed onto the API

Sell steps (e.g. in a Smart Trade) are not being passed on the 3C API properly. Given a JSON object that contains e.g.

{ ...
  take_profit_type: 'step_sell',
  take_profit_step_orders:
   [ { percent: 40, price: 0.000062, price_method: 'bid' },
     { percent: 30, price: 0.000069, price_method: 'bid' },
     { percent: 20, price: 0.000074, price_method: 'bid' },
     { percent: 10, price: 0.000080, price_method: 'bid' } ],
... }

The API will return an error, because querystring.stringify() will render the JSON array as an empty property (...&take_profit_step_orders=&...).

{ error: 'record_invalid',
  error_description: 'Invalid parameters',
  error_attributes:
   { 'take_profit_step_orders[percent]': [ 'is missing' ],
     'take_profit_step_orders[price_method]': [ 'is missing' ] } }

Error: invalid json response body, if there is rate limits problem

I get FetchError: invalid json response body at https://api.3commas.io/public/api/ver1/deals?account_id=*** reason: Unexpected token R in JSON at position 0
If I hit it to many times.

Code to replicate:

const run = async function run() {
  const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

  const results = await Promise.all(arr.map(async () => client.makeRequest('GET',
    '/public/api/ver1/deals?',
    { account_id: *** })));

  console.log(results);
};

run().catch((err) => { console.log('Caught error', err); });

api.botUpdate - Multi-Pairs Not Working

Hi There,

I am trying to update a bot automatically, I have been able to do this successfully with a single pair bot but now I am trying with a multi-pair bot it will only accept the last value in the list of pairs.

Please see snippet below:

botUpdate

In this instance, the values for the bot update, but the pairs become only "USDT_ADA".

I have seen mentions about using JSON instead of these arrays, but not sure how I would need to modify the index.js files to make this work?

Any help would be greatly appreciated!

Cheers,

Nested params not working with querystring.stringify

{ "account_id": 1, "pair": "USDT_BTC", "instant": "true", "position": { "type": "buy", "units": { "value": "0.01" }, "order_type": "market" } }
querystring.stringify does not give correct params to send out in URL. I had to use qs to make it work.

v2 proposal

Make this library simple and as pure wrapper (which it basically is), so it can support any current 3commas API methods.

This is already possible in v1.*, using following example:

const api = require('3commas-api-node')

const apiCall = new api({
  apiKey: '',
  apiSecret: ''
})

// get last 20 active deals
const showActiveDeals = async () => {
  let data = await apiCall.makeRequest(
  // method
  'GET',
  // path
  '/public/api/ver1/deals?'
  // params
  {
    limit: 20,
    scope: 'active',
  })
  console.log(data)
}

showActiveDeals()

Proposal is to remove all other functions, just leave makeRequest function and release it as v2. Update README with example usage and noting deprecated functions included in v1.*

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.