diff --git a/README.md b/README.md index 1252516..fbf7d01 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,11 @@ This example will open a market position, place a limit buy order, and set a sto | **stop_market_sell** | x | x | | | | | **close_position** | | | | | | +### Debug + +``` +curl -X POST -H "Content-Type: application/json" -d '{ "account": "first_account", "instrument": "BTC-PERPETUAL", "orders": [{ "t": "debug", "a": 10, "p": 10 }] }' http://localhost:3000/trade +``` ### Endpoints @@ -67,3 +72,11 @@ This example will open a market position, place a limit buy order, and set a sto * `GET /exchanges` to list supported exhanges, useful to find a `ccxt id` * `GET /exchanges/:exchange` to list available instruments (symbols) for a specific exchange +### FAQ + +#### Amount unit is in Fiat or Asset? +It depends on the exchange. Example: +* deribit: it's fiat on `BTC-PERPETUAL` +* bitfinex: it's asset on `BTC/USD` + +Refere to exchange or ccxt documentation. \ No newline at end of file diff --git a/class_config.js b/class_config.js index b70a0a2..83d8b93 100644 --- a/class_config.js +++ b/class_config.js @@ -21,6 +21,9 @@ class Config { getAccountParams(account) { let exchange = this.exchanges.find(e => e.account === account) + if (!exchange) { + throw new Error(`No account named '${account}'`); + } let params = exchange.hasOwnProperty('params') ? exchange.params : {} return params } diff --git a/class_order.js b/class_order.js index 8f21597..f58b758 100644 --- a/class_order.js +++ b/class_order.js @@ -92,7 +92,7 @@ class Order { } console.log("-> Processing", this.order) if (this.order.t == 'debug') { - console.log("<- Debug mode, no order placed.") + console.log("-x Debug mode, no order placed.") return "executed debug order" } else { switch (this.order.t) { diff --git a/tests/config.test.js b/tests/config.test.js index 413a784..65130ec 100644 --- a/tests/config.test.js +++ b/tests/config.test.js @@ -14,5 +14,6 @@ test('getAccountParams() returns correct data', () => { expect(global.config.getAccountParams("first_account")).toStrictEqual({ "currency": "BTC" }); expect(global.config.getAccountParams("second_account")).toStrictEqual({ "currency": "ETH" }); expect(global.config.getAccountParams("third_account")).toStrictEqual({}); + expect(() => global.config.getAccountParams("unknown_account")).toThrow("No account named 'unknown_account'"); });