Initial commit: Oil Trading Bot (MT5, WTI)
Headless FastAPI-Backend (server.py + core/engine.py) mit Mobile-PWA (web/), Strategie-/Backtest-Suite und Doku. Secrets, DB, Logs und Laufzeit-State sind via .gitignore ausgeschlossen; Config-Vorlage: oil_widget_config.ini.example. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
# send_daily_report.ps1
|
||||
# Sendet täglich um 0 Uhr eine HTML-Zusammenfassung aller Trades des Vortages.
|
||||
|
||||
$python = "C:\Users\ah\AppData\Local\Programs\Python\Python312\python.exe"
|
||||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$pyScript = Join-Path $scriptDir "daily_summary.py"
|
||||
|
||||
# ── Graph-Credentials aus oil_widget_config.ini ([graph]) ─────────────────
|
||||
# Secrets gehören nicht ins Skript — zentrale Config wie bei den API-Keys.
|
||||
$iniPath = Join-Path (Split-Path -Parent $scriptDir) "oil_widget_config.ini"
|
||||
$graph = @{}
|
||||
$inGraph = $false
|
||||
foreach ($line in Get-Content $iniPath -Encoding UTF8) {
|
||||
if ($line -match '^\s*\[(.+)\]') { $inGraph = ($Matches[1] -eq 'graph'); continue }
|
||||
if ($inGraph -and $line -match '^\s*(\w+)\s*=\s*(.+?)\s*$') {
|
||||
$graph[$Matches[1]] = $Matches[2]
|
||||
}
|
||||
}
|
||||
$tenantId = $graph['tenant_id']
|
||||
$clientId = $graph['client_id']
|
||||
$clientSecret = $graph['client_secret']
|
||||
if (-not $tenantId -or -not $clientId -or -not $clientSecret) {
|
||||
Write-Error "Abschnitt [graph] in $iniPath fehlt oder ist unvollständig."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# ── Zusammenfassung aus Python holen ────────────────────────────────────────
|
||||
$yesterday = (Get-Date).AddDays(-1).ToString("yyyy-MM-dd")
|
||||
|
||||
# -join: Python gibt mehrere Zeilen aus → PowerShell macht ein String-Array daraus.
|
||||
# Ohne -join würde nur die erste Zeile (<html>) als Content ankommen → leere Mail.
|
||||
$htmlBody = (& $python $pyScript $yesterday 2>&1) -join "`n"
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($htmlBody) -or $htmlBody -match "Traceback|Error:") {
|
||||
$htmlBody = "<p>Fehler beim Generieren des Reports für $yesterday.</p><pre>$htmlBody</pre>"
|
||||
}
|
||||
|
||||
$subject = "Oil Trading $((Get-Date).AddDays(-1).ToString('dd.MM.yyyy'))"
|
||||
|
||||
# ── Microsoft Graph verbinden ────────────────────────────────────────────────
|
||||
$secureSecret = ConvertTo-SecureString $clientSecret -AsPlainText -Force
|
||||
$cred = New-Object System.Management.Automation.PSCredential($clientId, $secureSecret)
|
||||
Connect-MgGraph -TenantId $tenantId -ClientSecretCredential $cred -NoWelcome
|
||||
|
||||
# ── E-Mail senden ────────────────────────────────────────────────────────────
|
||||
$params = @{
|
||||
Message = @{
|
||||
Subject = $subject
|
||||
Body = @{
|
||||
ContentType = "HTML"
|
||||
Content = $htmlBody
|
||||
}
|
||||
ToRecipients = @(
|
||||
@{ EmailAddress = @{ Address = "axel@hocks.eu" } }
|
||||
)
|
||||
From = @{
|
||||
EmailAddress = @{ Address = "mailagent@hocks.eu" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Send-MgUserMail -UserId "mailagent@hocks.eu" -BodyParameter $params
|
||||
Write-Output "Report gesendet: $subject"
|
||||
Reference in New Issue
Block a user