Fix % format comma separator and empty positions.json parse error
This commit is contained in:
@@ -49,7 +49,10 @@ class Portfolio:
|
|||||||
if not self._path.exists():
|
if not self._path.exists():
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
data = json.loads(self._path.read_text())
|
content = self._path.read_text().strip()
|
||||||
|
if not content:
|
||||||
|
return
|
||||||
|
data = json.loads(content)
|
||||||
self.positions = {pair: Position(**fields) for pair, fields in data.items()}
|
self.positions = {pair: Position(**fields) for pair, fields in data.items()}
|
||||||
log.info("Loaded %d position(s) from %s", len(self.positions), self._path)
|
log.info("Loaded %d position(s) from %s", len(self.positions), self._path)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ class Scanner:
|
|||||||
)
|
)
|
||||||
for opp in opportunities:
|
for opp in opportunities:
|
||||||
log.info(
|
log.info(
|
||||||
" %-12s change=%+.2f%% volume=$%,.0f",
|
" %-12s change=%+.2f%% volume=$%.0f",
|
||||||
opp.pair, opp.change_pct, opp.volume_usd,
|
opp.pair, opp.change_pct, opp.volume_usd,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
19
update.sh
Normal file
19
update.sh
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Copies updated source files to /opt/crypto-trader after a git pull.
|
||||||
|
# Usage: sudo bash update.sh
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
INSTALL_DIR="/opt/crypto-trader"
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
|
echo "ERROR: Run with sudo: sudo bash update.sh"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for item in *.py *.txt systemd; do
|
||||||
|
[ -e "$SCRIPT_DIR/$item" ] && cp -r "$SCRIPT_DIR/$item" "$INSTALL_DIR/"
|
||||||
|
done
|
||||||
|
|
||||||
|
chown -R crypto-trader:crypto-trader "$INSTALL_DIR"
|
||||||
|
echo "Updated. Run a test: sudo -u crypto-trader $INSTALL_DIR/venv/bin/python $INSTALL_DIR/bot.py"
|
||||||
Reference in New Issue
Block a user