Skip to content

Commit 20c999d

Browse files
committed
Merge branch 'dev' into 'main'
v2.0.2 See merge request AndreyPopov/spot-trading-bot!42
2 parents 93f769b + c4cc807 commit 20c999d

6 files changed

Lines changed: 57 additions & 15 deletions

File tree

docs/developer/for-developers.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,18 @@ Formatting is handled by the configured linters, not Prettier:
8484

8585
Keep public release documentation and tags in the established project format.
8686
Development happens on GitLab; publish the GitHub mirror only after the GitLab side is ready.
87+
88+
## Release commands
89+
90+
For this project, bump the version in `src/package.json` without creating a git tag automatically:
91+
92+
```sh
93+
docker compose exec app sh -lc "cd /var/www/src && npm version 2.0.2 --no-git-tag-version"
94+
```
95+
96+
Then create and push the release tag from the host:
97+
98+
```sh
99+
git tag -a v2.0.2 -m "Release v2.0.2 — test"
100+
git push origin v2.0.2
101+
```

docs/guide/overview.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ In `real` mode the bot places live orders with real funds. Start on
5858
consider real keys. See the [Disclaimer](/help/disclaimer).
5959
:::
6060

61+
::: info AI-assisted deployment and coding
62+
Using AI is encouraged, especially for setup, deployment, and repetitive operator
63+
work. It usually does not break the project by itself — it helps you launch faster
64+
and reduces routine friction.
65+
66+
But always review AI-generated changes with your own eyes. New features and non-trivial
67+
edits should be tested on **Binance testnet first**. AI often gets architecture or
68+
integration details wrong — not only because the model can make mistakes, but also
69+
because humans frequently describe requirements incompletely.
70+
71+
Treat AI as an accelerator, not as a final authority: inspect the code, verify the
72+
behavior, and test the risky paths manually.
73+
:::
74+
6175
## How to read these docs
6276

6377
- **[Getting Started](/guide/getting-started)** — get it running in a few minutes.

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
layout: home
33

44
hero:
5-
name: Spot Trading Bot for Binance
5+
name: Spot Trading Bot for<br>Binance
66
text: DCA / Grid hybrid
77
tagline: A self-hosted, non-custodial spot bot that averages a position down, closes the whole grid at a profit, and scalps the oscillations in between.
88
image:

src/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"name": "spot-trading-bot",
33
"description": "DCA/Grid hybrid. A self-hosted, non-custodial spot bot that averages a position down, closes the whole grid at a profit, and scalps the oscillations in between.",
4-
"version": "2.0.1",
4+
"version": "2.0.2",
55
"private": true,
66
"license": "GPL-3.0-or-later",
77
"scripts": {
88
"build-css": "sass scss/:public/stylesheets/ --no-source-map",
99
"gen-qr": "node ./tools/gen-qr.js",
1010
"dev": "concurrently \"npm:watch-css\" \"npm:start\"",
1111
"start": "nodemon ./bin/www",
12-
"setup-user": "node ./bin/setup-user.js",
12+
"setup-user": "npm_config_update_notifier=false node ./bin/setup-user.js",
1313
"test": "node --test",
1414
"prod-runtime": "pm2-runtime start ./bin/www --name my-app",
1515
"lint": "eslint .",

src/routes/spotbot.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,26 @@ function hybridView(obj) {
7373
}
7474
}
7575

76+
function emptyPairState() {
77+
return {
78+
BUY: [],
79+
SELL: [],
80+
param: {},
81+
};
82+
}
83+
84+
async function loadOrCreatePairState(filePath) {
85+
try {
86+
return JSON.parse(await fs.readFile(filePath, 'utf8'));
87+
} catch (err) {
88+
if (err?.code !== 'ENOENT') throw err;
89+
90+
const data = emptyPairState();
91+
await writeFileAtomic(filePath, JSON.stringify(data, null, 2), 'utf8');
92+
return data;
93+
}
94+
}
95+
7696
router.post('/table/:symbol', async (req, res, next) => {
7797
try {
7898
const rawSymbol = req.body.message;
@@ -257,8 +277,7 @@ router.post('/calculator/restart', async (req, res, next) => {
257277

258278
const filePath = path.join(__dirname, '../data', `${symbol}-binance.json`);
259279

260-
const content = await fs.readFile(filePath, 'utf8');
261-
let data = JSON.parse(content);
280+
let data = await loadOrCreatePairState(filePath);
262281

263282
const newData = req.body.message;
264283
// data = { ...data, ...newData };
@@ -332,8 +351,7 @@ router.post('/calculator/param', async (req, res, next) => {
332351
const symbol = rawPair.replace(/[^a-zA-Z0-9_-]/g, '');
333352
const filePath = path.join(__dirname, '../data', `${symbol}-binance.json`);
334353

335-
const content = await fs.readFile(filePath, 'utf8');
336-
const data = JSON.parse(content);
354+
const data = await loadOrCreatePairState(filePath);
337355

338356
if (!data.param || typeof data.param !== 'object') {
339357
data.param = {};
@@ -379,12 +397,7 @@ router.post('/calculator/hybrid', async (req, res) => {
379397
const symbol = String(msg.pair).replace(/[^a-zA-Z0-9_-]/g, '');
380398
const filePath = path.join(__dirname, '../data', `${symbol}-binance.json`);
381399

382-
let data;
383-
try {
384-
data = JSON.parse(await fs.readFile(filePath, 'utf8'));
385-
} catch {
386-
return res.status(404).json({ message: `No cycle for ${symbol}` });
387-
}
400+
const data = await loadOrCreatePairState(filePath);
388401
if (!data.param || typeof data.param !== 'object') {
389402
data.param = {};
390403
}

0 commit comments

Comments
 (0)