Sentiment-Based Algorithmic Trading Strategy Creator

Strategy Setup & Asset Definition

Sentiment Scoring & Thresholds

Define actions based on sentiment levels (be specific):

Trade Execution & Risk Parameters

Strategy Summary

Please complete all previous tabs to generate the summary.

Asset Class: ${summaryData.assetClass}

`; html += `

Specific Asset(s): ${summaryData.specificAssets || 'Not specified'}

`; html += `

Sentiment Data Source: ${summaryData.sentimentDataSource || 'Not specified'}

`; html += '

Sentiment Rules

'; html += `

Sentiment Scale: ${summaryData.sentimentScale.replace(/_/g, ' ')}

`; html += `

Action for Strong Positive: ${summaryData.strongPositiveAction || 'Not specified'}

`; html += `

Action for Positive: ${summaryData.positiveAction || 'Not specified'}

`; html += `

Action for Neutral: ${summaryData.neutralAction || 'Not specified'}

`; html += `

Action for Negative: ${summaryData.negativeAction || 'Not specified'}

`; html += `

Action for Strong Negative: ${summaryData.strongNegativeAction || 'Not specified'}

`; html += '

Trade Configuration

'; html += `

Order Type: ${summaryData.orderType}

`; let sizingValueLabel = ''; if (summaryData.positionSizingType === 'FixedAmount') sizingValueLabel = 'Amount ($)'; else if (summaryData.positionSizingType === 'PercentagePortfolio') sizingValueLabel = 'Percentage (%)'; else if (summaryData.positionSizingType === 'FixedUnits') sizingValueLabel = 'Units'; html += `

Position Sizing: ${summaryData.positionSizingType.replace(/([A-Z])/g, ' $1').trim()} (${sizingValueLabel}: ${summaryData.positionSizingValue || 'N/A'})

`; html += `

Stop-Loss Rule: ${summaryData.stopLoss || 'Not specified'}

`; html += `

Take-Profit Rule: ${summaryData.takeProfit || 'Not specified'}

`; html += `

Re-evaluation Trigger: ${summaryData.reevaluationCondition || 'Not specified'}

`; summaryOutput.innerHTML = html; } function sats_downloadPDF() { if (typeof window.jspdf === 'undefined' || typeof window.jspdf.jsPDF === 'undefined') { alert('PDF library (jsPDF) is not loaded. This might be due to a network issue or ad-blocker. Please ensure you are connected to the internet and try again. If the issue persists, check your browser console for errors.'); console.error('jsPDF library not found under window.jspdf'); return; } const { jsPDF: JSPDF } = window.jspdf; const doc = new JSPDF(); sats_generateSummary(); const strategyName = sats_getInputValue('sats_strategyName') || 'Sentiment_Trading_Strategy'; doc.setFontSize(18); doc.text(strategyName, 14, 22); doc.setFontSize(11); doc.setTextColor(100); let yPos = 35; // Adjusted initial Y position const lineHeight = 7; const sectionSpacing = 5; // Space between sections const itemSpacing = 3; // Space between items in a list const leftMargin = 14; const wrapWidth = doc.internal.pageSize.getWidth() - (leftMargin * 2); function addWrappedText(text, x, y, maxWidth) { const lines = doc.splitTextToSize(text, maxWidth); doc.text(lines, x, y); return y + (lines.length * (lineHeight -2)); // Return new Y position } function addSection(title, data) { if (yPos > 250) { doc.addPage(); yPos = 20; } doc.setFontSize(14); doc.setTextColor(40, 40, 40); // Darker color for section titles doc.text(title, leftMargin, yPos); yPos += lineHeight; doc.setFontSize(10); doc.setTextColor(60, 60, 60); // Slightly lighter for content data.forEach(item => { if (yPos > 270) { // Check space before printing item doc.addPage(); yPos = 20; } let itemText = ` ${item.label}: ${item.value || 'Not specified'}`; const lines = doc.splitTextToSize(itemText, wrapWidth); doc.text(lines, leftMargin + 2, yPos); yPos += (lines.length * (lineHeight -2)) + itemSpacing; }); yPos += sectionSpacing; } const positionSizingType = sats_getInputValue('sats_positionSizingType'); let sizingValueLabel = ''; if (positionSizingType === 'FixedAmount') sizingValueLabel = 'Amount ($)'; else if (positionSizingType === 'PercentagePortfolio') sizingValueLabel = 'Percentage (%)'; else if (positionSizingType === 'FixedUnits') sizingValueLabel = 'Units'; const positionSizingValue = sats_getInputValue('sats_positionSizingValue'); addSection("Strategy Setup", [ { label: "Asset Class", value: sats_getInputValue('sats_assetClass') }, { label: "Specific Asset(s)", value: sats_getInputValue('sats_specificAssets') }, { label: "Sentiment Data Source", value: sats_getInputValue('sats_sentimentDataSource') } ]); addSection("Sentiment Rules", [ { label: "Sentiment Scale", value: sats_getInputValue('sats_sentimentScale').replace(/_/g, ' ') }, { label: "Action for Strong Positive", value: sats_getInputValue('sats_strongPositiveAction') }, { label: "Action for Positive", value: sats_getInputValue('sats_positiveAction') }, { label: "Action for Neutral", value: sats_getInputValue('sats_neutralAction') }, { label: "Action for Negative", value: sats_getInputValue('sats_negativeAction') }, { label: "Action for Strong Negative", value: sats_getInputValue('sats_strongNegativeAction') } ]); addSection("Trade Configuration", [ { label: "Order Type", value: sats_getInputValue('sats_orderType') }, { label: "Position Sizing", value: `${positionSizingType.replace(/([A-Z])/g, ' $1').trim()} (${sizingValueLabel}: ${positionSizingValue || 'N/A'})` }, { label: "Stop-Loss Rule", value: sats_getInputValue('sats_stopLoss') }, { label: "Take-Profit Rule", value: sats_getInputValue('sats_takeProfit') }, { label: "Re-evaluation Trigger", value: sats_getInputValue('sats_reevaluationCondition') } ]); doc.save(`${strategyName.replace(/[^\w\s]/gi, '').replace(/\s+/g, '_') || 'trading_strategy'}.pdf`); // Sanitize filename }
Scroll to Top