feat: fix Safe Paper Trading display formatting and API sync
- Fixed field mapping between API and frontend (amount→positionSize, entry→entryPrice, createdAt→timestamp) - Updated API sync function to properly convert API trade format to frontend format - Resolved display issues: 'Invalid Date', missing entry price, missing trade size - Added trade monitoring system and automation improvements - Enhanced automation with simple-automation.js for reliable 24/7 operation - Working automation now detecting 85% confidence BUY signals and executing trades
This commit is contained in:
@@ -5,10 +5,6 @@
|
||||
* Integrates Fear & Greed Index and macro indicators for better trading decisions
|
||||
*/
|
||||
|
||||
const { exec } = require('child_process');
|
||||
const { promisify } = require('util');
|
||||
const execAsync = promisify(exec);
|
||||
|
||||
// Import M2 Money Supply indicator
|
||||
const M2MoneySupplyIndicator = require('./m2-money-supply-indicator');
|
||||
|
||||
@@ -19,6 +15,8 @@ class EnhancedGlobalAutomation {
|
||||
timeframe: '60',
|
||||
intervalMinutes: 60,
|
||||
autoExecuteThreshold: 60,
|
||||
// API endpoint for container environment
|
||||
apiHost: '192.168.0.1:9001',
|
||||
// Enhanced with sentiment-based adjustments
|
||||
sentimentThresholds: {
|
||||
extremeFear: 75, // Lower threshold during extreme fear (more aggressive)
|
||||
@@ -125,8 +123,8 @@ class EnhancedGlobalAutomation {
|
||||
async estimateFearGreedFromPriceAction() {
|
||||
try {
|
||||
// Get recent analysis to estimate sentiment
|
||||
const { stdout } = await execAsync(`curl -s "http://localhost:9001/api/ai-analysis/latest?symbol=${this.config.symbol}&timeframe=${this.config.timeframe}"`);
|
||||
const data = JSON.parse(stdout);
|
||||
const response = await fetch(`http://${this.config.apiHost}/api/ai-analysis/latest?symbol=${this.config.symbol}&timeframe=${this.config.timeframe}`);
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success && data.data && data.data.analysis) {
|
||||
const analysis = data.data.analysis;
|
||||
@@ -258,8 +256,8 @@ class EnhancedGlobalAutomation {
|
||||
await this.updateMarketSentiment();
|
||||
|
||||
// Get current technical analysis
|
||||
const { stdout } = await execAsync(`curl -s "http://localhost:9001/api/ai-analysis/latest?symbol=${this.config.symbol}&timeframe=${this.config.timeframe}"`);
|
||||
const data = JSON.parse(stdout);
|
||||
const response = await fetch(`http://${this.config.apiHost}/api/ai-analysis/latest?symbol=${this.config.symbol}&timeframe=${this.config.timeframe}`);
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success && data.data && data.data.analysis) {
|
||||
const analysis = data.data.analysis;
|
||||
@@ -322,10 +320,15 @@ class EnhancedGlobalAutomation {
|
||||
};
|
||||
|
||||
// Create enhanced paper trade
|
||||
const curlData = JSON.stringify(tradeData).replace(/"/g, '\\"');
|
||||
const { stdout: tradeResult } = await execAsync(`curl -s -X POST http://localhost:9001/api/safe-paper-trading/create-trade -H "Content-Type: application/json" -d "${curlData}"`);
|
||||
const response = await fetch(`http://${this.config.apiHost}/api/safe-paper-trading/create-trade`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(tradeData)
|
||||
});
|
||||
|
||||
const result = JSON.parse(tradeResult);
|
||||
const result = await response.json();
|
||||
|
||||
if (result.success) {
|
||||
this.stats.totalTrades++;
|
||||
|
||||
Reference in New Issue
Block a user