26 lines
817 B
PHP
26 lines
817 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
function getCurrentPrice(string $symbol): float {
|
|
$db = db();
|
|
|
|
// Check for active manipulation (spike or target)
|
|
$stmt = $db->prepare("SELECT target_price FROM price_controls WHERE symbol = ? AND is_active = 1 ORDER BY created_at DESC LIMIT 1");
|
|
$stmt->execute([$symbol]);
|
|
$manipulated = $stmt->fetchColumn();
|
|
|
|
if ($manipulated !== false) {
|
|
return (float)$manipulated;
|
|
}
|
|
|
|
// Otherwise return standard current price
|
|
$stmt = $db->prepare("SELECT current_price FROM cryptocurrencies WHERE symbol = ?");
|
|
$stmt->execute([$symbol]);
|
|
return (float)$stmt->fetchColumn() ?: 0.0;
|
|
}
|
|
|
|
function processOrders(): void {
|
|
// This could be a background job
|
|
// It would check pending orders against current prices and fill them
|
|
}
|