hedgequantx 1.2.54 → 1.2.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/app.js +30 -38
- package/src/pages/algo.js +49 -0
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -656,66 +656,57 @@ const dashboardMenu = async (service) => {
|
|
|
656
656
|
* Handles the update process with auto-restart
|
|
657
657
|
*/
|
|
658
658
|
const handleUpdate = async () => {
|
|
659
|
-
const { spawn } = require('child_process');
|
|
659
|
+
const { spawn, execSync: exec } = require('child_process');
|
|
660
660
|
const pkg = require('../package.json');
|
|
661
661
|
const currentVersion = pkg.version;
|
|
662
662
|
const spinner = ora('Checking for updates...').start();
|
|
663
663
|
|
|
664
664
|
try {
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
const behindCount = execSync('git rev-list HEAD..origin/main --count', { cwd: cliPath, stdio: 'pipe' }).toString().trim();
|
|
665
|
+
// Check latest version on npm
|
|
666
|
+
spinner.text = 'Checking npm registry...';
|
|
667
|
+
let latestVersion;
|
|
668
|
+
try {
|
|
669
|
+
latestVersion = exec('npm view hedgequantx version', { stdio: 'pipe' }).toString().trim();
|
|
670
|
+
} catch (e) {
|
|
671
|
+
spinner.fail('Cannot reach npm registry');
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
675
674
|
|
|
676
|
-
if (
|
|
675
|
+
if (currentVersion === latestVersion) {
|
|
677
676
|
spinner.succeed('Already up to date!');
|
|
678
677
|
console.log(chalk.cyan(` Version: v${currentVersion}`));
|
|
679
|
-
console.log(chalk.gray(` Commit: ${beforeCommit}`));
|
|
680
678
|
return;
|
|
681
679
|
}
|
|
682
680
|
|
|
683
|
-
//
|
|
684
|
-
spinner.text =
|
|
681
|
+
// Update via npm
|
|
682
|
+
spinner.text = `Updating v${currentVersion} -> v${latestVersion}...`;
|
|
685
683
|
try {
|
|
686
|
-
|
|
684
|
+
exec('npm install -g hedgequantx@latest', { stdio: 'pipe' });
|
|
687
685
|
} catch (e) {
|
|
688
|
-
//
|
|
689
|
-
|
|
686
|
+
// Try with sudo on Unix systems
|
|
687
|
+
if (process.platform !== 'win32') {
|
|
688
|
+
try {
|
|
689
|
+
exec('sudo npm install -g hedgequantx@latest', { stdio: 'pipe' });
|
|
690
|
+
} catch (e2) {
|
|
691
|
+
spinner.fail('Update failed - try manually: npm install -g hedgequantx@latest');
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
} else {
|
|
695
|
+
spinner.fail('Update failed - try manually: npm install -g hedgequantx@latest');
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
690
698
|
}
|
|
691
699
|
|
|
692
|
-
// Pull latest
|
|
693
|
-
spinner.text = 'Downloading updates...';
|
|
694
|
-
execSync('git pull origin main', { cwd: cliPath, stdio: 'pipe' });
|
|
695
|
-
const afterCommit = execSync('git rev-parse --short HEAD', { cwd: cliPath, stdio: 'pipe' }).toString().trim();
|
|
696
|
-
|
|
697
|
-
// Install dependencies
|
|
698
|
-
spinner.text = 'Installing dependencies...';
|
|
699
|
-
try {
|
|
700
|
-
execSync('npm install --silent', { cwd: cliPath, stdio: 'pipe' });
|
|
701
|
-
} catch (e) { /* ignore */ }
|
|
702
|
-
|
|
703
|
-
// Get new version
|
|
704
|
-
delete require.cache[require.resolve('../package.json')];
|
|
705
|
-
const newPkg = require('../package.json');
|
|
706
|
-
const newVersion = newPkg.version;
|
|
707
|
-
|
|
708
700
|
spinner.succeed('CLI updated!');
|
|
709
701
|
console.log();
|
|
710
|
-
console.log(chalk.green(` Version: v${currentVersion} -> v${
|
|
711
|
-
console.log(chalk.gray(` Commits: ${beforeCommit} -> ${afterCommit} (${behindCount} new)`));
|
|
702
|
+
console.log(chalk.green(` Version: v${currentVersion} -> v${latestVersion}`));
|
|
712
703
|
console.log();
|
|
713
704
|
console.log(chalk.cyan(' Restarting...'));
|
|
714
705
|
console.log();
|
|
715
706
|
|
|
716
707
|
// Restart CLI
|
|
717
|
-
const
|
|
718
|
-
|
|
708
|
+
const cliPath = exec('npm root -g', { stdio: 'pipe' }).toString().trim();
|
|
709
|
+
const child = spawn(process.argv[0], [path.join(cliPath, 'hedgequantx', 'bin', 'cli.js')], {
|
|
719
710
|
stdio: 'inherit',
|
|
720
711
|
shell: true
|
|
721
712
|
});
|
|
@@ -729,6 +720,7 @@ const handleUpdate = async () => {
|
|
|
729
720
|
|
|
730
721
|
} catch (error) {
|
|
731
722
|
spinner.fail('Update failed: ' + error.message);
|
|
723
|
+
console.log(chalk.yellow(' Try manually: npm install -g hedgequantx@latest'));
|
|
732
724
|
}
|
|
733
725
|
};
|
|
734
726
|
|
package/src/pages/algo.js
CHANGED
|
@@ -519,6 +519,55 @@ const copyTradingMenu = async () => {
|
|
|
519
519
|
console.log(chalk.gray(getSeparator()));
|
|
520
520
|
console.log();
|
|
521
521
|
|
|
522
|
+
// Check market status first
|
|
523
|
+
const marketSpinner = ora('Checking market status...').start();
|
|
524
|
+
|
|
525
|
+
// Use a simple market hours check
|
|
526
|
+
const now = new Date();
|
|
527
|
+
const utcDay = now.getUTCDay();
|
|
528
|
+
const utcHour = now.getUTCHours();
|
|
529
|
+
const isDST = (() => {
|
|
530
|
+
const jan = new Date(now.getFullYear(), 0, 1);
|
|
531
|
+
const jul = new Date(now.getFullYear(), 6, 1);
|
|
532
|
+
return now.getTimezoneOffset() < Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
|
|
533
|
+
})();
|
|
534
|
+
const ctOffset = isDST ? 5 : 6;
|
|
535
|
+
const ctHour = (utcHour - ctOffset + 24) % 24;
|
|
536
|
+
const ctDay = utcHour < ctOffset ? (utcDay + 6) % 7 : utcDay;
|
|
537
|
+
|
|
538
|
+
let marketClosed = false;
|
|
539
|
+
let marketMessage = '';
|
|
540
|
+
|
|
541
|
+
if (ctDay === 6) {
|
|
542
|
+
marketClosed = true;
|
|
543
|
+
marketMessage = 'Market closed (Saturday)';
|
|
544
|
+
} else if (ctDay === 0 && ctHour < 17) {
|
|
545
|
+
marketClosed = true;
|
|
546
|
+
marketMessage = 'Market opens Sunday 5:00 PM CT';
|
|
547
|
+
} else if (ctDay === 5 && ctHour >= 16) {
|
|
548
|
+
marketClosed = true;
|
|
549
|
+
marketMessage = 'Market closed (Friday after 4PM CT)';
|
|
550
|
+
} else if (ctHour === 16 && ctDay >= 1 && ctDay <= 4) {
|
|
551
|
+
marketClosed = true;
|
|
552
|
+
marketMessage = 'Daily maintenance (4:00-5:00 PM CT)';
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
if (marketClosed) {
|
|
556
|
+
marketSpinner.fail('Market is CLOSED');
|
|
557
|
+
console.log();
|
|
558
|
+
console.log(chalk.red.bold(' [X] ' + marketMessage));
|
|
559
|
+
console.log();
|
|
560
|
+
console.log(chalk.gray(' Futures markets (CME) trading hours:'));
|
|
561
|
+
console.log(chalk.gray(' Sunday 5:00 PM CT - Friday 4:00 PM CT'));
|
|
562
|
+
console.log(chalk.gray(' Daily maintenance: 4:00 PM - 5:00 PM CT'));
|
|
563
|
+
console.log();
|
|
564
|
+
await inquirer.prompt([{ type: 'input', name: 'continue', message: 'Press Enter to continue...' }]);
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
marketSpinner.succeed('Market is OPEN - Ready to trade!');
|
|
569
|
+
console.log();
|
|
570
|
+
|
|
522
571
|
// Get all active accounts from all connections
|
|
523
572
|
const allAccounts = await connections.getAllAccounts();
|
|
524
573
|
const activeAccounts = allAccounts.filter(acc => acc.status === 0);
|