Skip to content

Commit dacfbcc

Browse files
committed
refactor(bots): merge gridPrice into Price section and document it
Consolidate the bot editor menu from 6 to 5 items: gridPrice is now prompted as part of section 3 (Price) alongside range and startPrice, displayed as the Grid: label. README updated with gridPrice field description under section 3.
1 parent 1e297b7 commit dacfbcc

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,13 @@ Below is a reference guide for each configuration option from `node dexbot bots`
132132
| **`dryRun`** | boolean | If `true`, simulates orders without broadcasting to the blockchain. |
133133
| **`preferredAccount`** | string | The BitShares account name to use for trading. |
134134

135-
#### 3. Price Range
135+
#### 3. Price
136136
| Parameter | Type | Description |
137137
| :--- | :--- | :--- |
138-
| **`startPrice`** | num \| str | Default start price from liquidiy pool (`"pool"`), `"market"` (order book) or a number `A/B` is also possible. |
138+
| **`startPrice`** | num \| str | Initial price for order alignment. `"pool"` (liquidity pool), `"market"` (order book), or a numeric `A/B` ratio. |
139139
| **`minPrice`** | number \| string | Lower bound. Use a number (e.g., `0.5`) or multiplier (e.g., `"2x"` = `startPrice / 2`). |
140140
| **`maxPrice`** | number \| string | Upper bound. Use a number (e.g., `1.5`) or multiplier (e.g., `"2x"` = `startPrice * 2`). |
141+
| **`gridPrice`** | num \| str \| null | Reference price for x-factor bound calculations, independent of `startPrice`. Options: `null` (default — uses `startPrice`), a numeric price, or an AMA keyword (`"ama"`, `"ama1"``"ama4"`). When set to an AMA keyword, the market adapter writes the current AMA center price to `profiles/orders/<botKey>.gridprice.json` and the grid reads it on each reset. |
141142

142143
#### 4. Grid Strategy
143144
| Parameter | Type | Description |

modules/account_bots.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -830,18 +830,17 @@ async function promptBotData(base = {}) {
830830
console.log('\n\x1b[1m--- Bot Editor: ' + (data.name || 'New Bot') + ' ---\x1b[0m');
831831
console.log(`\x1b[1;33m1) Pair:\x1b[0m \x1b[1;31m${data.assetA || '?'} / ${data.assetB || '?'} \x1b[0m`);
832832
console.log(`\x1b[1;33m2) Identity:\x1b[0m \x1b[38;5;208mName:\x1b[0m ${data.name || '?'} , \x1b[38;5;208mAccount:\x1b[0m ${data.preferredAccount || '?'} , \x1b[38;5;208mActive:\x1b[0m ${data.active}, \x1b[38;5;208mDryRun:\x1b[0m ${data.dryRun}`);
833-
console.log(`\x1b[1;33m3) Price:\x1b[0m \x1b[38;5;208mRange:\x1b[0m [${data.minPrice} - ${data.maxPrice}], \x1b[38;5;208mStart:\x1b[0m ${data.startPrice}`);
833+
console.log(`\x1b[1;33m3) Price:\x1b[0m \x1b[38;5;208mRange:\x1b[0m [${data.minPrice} - ${data.maxPrice}], \x1b[38;5;208mStart:\x1b[0m ${data.startPrice}, \x1b[38;5;208mGrid:\x1b[0m ${data.gridPrice === null ? 'startPrice' : data.gridPrice}`);
834834
console.log(`\x1b[1;33m4) Grid:\x1b[0m \x1b[38;5;208mWeights:\x1b[0m (S:${data.weightDistribution.sell}, B:${data.weightDistribution.buy}), \x1b[38;5;208mIncr:\x1b[0m ${data.incrementPercent}%, \x1b[38;5;208mSpread:\x1b[0m ${data.targetSpreadPercent}%`);
835835
console.log(`\x1b[1;33m5) Funding:\x1b[0m \x1b[38;5;208mSell:\x1b[0m ${data.botFunds.sell}, \x1b[38;5;208mBuy:\x1b[0m ${data.botFunds.buy} | \x1b[38;5;208mOrders:\x1b[0m (S:${data.activeOrders.sell}, B:${data.activeOrders.buy})`);
836-
console.log(`\x1b[1;33m6) Grid Ref:\x1b[0m \x1b[38;5;208mgridPrice:\x1b[0m ${data.gridPrice === null ? 'startPrice' : data.gridPrice}`);
837836
console.log('--------------------------------------------------');
838837
console.log('\x1b[1;32mS) Save & Exit\x1b[0m');
839838
console.log('\x1b[37mC) Cancel (Discard changes)\x1b[0m');
840839
showMenu = false;
841840
}
842841

843842
const choice = (await readInput('Select section to edit or action: ', {
844-
validate: (input) => ['1', '2', '3', '4', '5', '6', 's', 'c'].includes(input)
843+
validate: (input) => ['1', '2', '3', '4', '5', 's', 'c'].includes(input.toLowerCase())
845844
})).trim().toLowerCase();
846845

847846
if (choice === '\x1b') {
@@ -882,9 +881,12 @@ async function promptBotData(base = {}) {
882881
if (maxP === '\x1b') break;
883882
const startP = await askStartPrice('startPrice (pool, market or A/B)', data.startPrice);
884883
if (startP === '\x1b') break;
884+
const gp = await askGridPriceMode('gridPrice ref (ama/ama1/ama2/ama3/ama4/number/none)', data.gridPrice);
885+
if (gp === '\x1b') break;
885886
data.minPrice = minP;
886887
data.maxPrice = maxP;
887888
data.startPrice = startP;
889+
data.gridPrice = gp;
888890
showMenu = true;
889891
break;
890892
case '4':
@@ -922,14 +924,6 @@ async function promptBotData(base = {}) {
922924
data.activeOrders.buy = oBuy;
923925
showMenu = true;
924926
break;
925-
case '6':
926-
{
927-
const gp = await askGridPriceMode('gridPrice (ama/ama1/ama2/ama3/ama4/number/none)', data.gridPrice);
928-
if (gp === '\x1b') break;
929-
data.gridPrice = gp;
930-
}
931-
showMenu = true;
932-
break;
933927
case 's':
934928
// Final basic validation before saving
935929
if (!data.name || !data.assetA || !data.assetB || !data.preferredAccount) {

0 commit comments

Comments
 (0)