fix bugs
This commit is contained in:
@@ -314,10 +314,6 @@ class ConfigService
|
|||||||
$currentUp = (float) ($upSetting->value ?: 0);
|
$currentUp = (float) ($upSetting->value ?: 0);
|
||||||
$currentDown = (float) ($downSetting->value ?: 0);
|
$currentDown = (float) ($downSetting->value ?: 0);
|
||||||
|
|
||||||
if ($currentUp > 0 && $priceInt < (int) ($currentUp * 0.9)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($currentUp <= 0 || $priceInt > $currentUp) {
|
if ($currentUp <= 0 || $priceInt > $currentUp) {
|
||||||
$this->UpdateConfig('up_price', $priceInt);
|
$this->UpdateConfig('up_price', $priceInt);
|
||||||
}
|
}
|
||||||
@@ -327,7 +323,7 @@ class ConfigService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* بیشترین/کمترین قیمت پایه امروز — با اصلاح outlier در down_price.
|
* بیشترین/کمترین قیمت پایه امروز — settings + candle + جدول prices.
|
||||||
*
|
*
|
||||||
* @return array{up: int, down: int}
|
* @return array{up: int, down: int}
|
||||||
*/
|
*/
|
||||||
@@ -340,10 +336,11 @@ class ConfigService
|
|||||||
$candleHigh = $candle ? (int) round((float) $candle->high) : 0;
|
$candleHigh = $candle ? (int) round((float) $candle->high) : 0;
|
||||||
$candleLow = $candle ? (int) round((float) $candle->low) : 0;
|
$candleLow = $candle ? (int) round((float) $candle->low) : 0;
|
||||||
|
|
||||||
if ($up > 0 && $down > 0 && $down < (int) ($up * 0.9)) {
|
if ($candleHigh > 0) {
|
||||||
$correctedDown = $candleLow >= (int) ($up * 0.9) ? $candleLow : $up;
|
$up = $up > 0 ? max($up, $candleHigh) : $candleHigh;
|
||||||
$down = $correctedDown;
|
}
|
||||||
$this->UpdateConfig('down_price', $correctedDown);
|
if ($candleLow > 0) {
|
||||||
|
$down = $down > 0 ? min($down, $candleLow) : $candleLow;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($up <= 0 || $down <= 0) {
|
if ($up <= 0 || $down <= 0) {
|
||||||
@@ -367,6 +364,11 @@ class ConfigService
|
|||||||
[$up, $down] = [$down, $up];
|
[$up, $down] = [$down, $up];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$storedDown = $this->getInt('down_price', 0);
|
||||||
|
if ($down > 0 && $down < $storedDown) {
|
||||||
|
$this->UpdateConfig('down_price', $down);
|
||||||
|
}
|
||||||
|
|
||||||
return ['up' => $up, 'down' => $down];
|
return ['up' => $up, 'down' => $down];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,17 +388,9 @@ class ConfigService
|
|||||||
return ['min' => 0, 'max' => 0];
|
return ['min' => 0, 'max' => 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
$max = (int) $prices->max();
|
|
||||||
$threshold = (int) ($max * 0.9);
|
|
||||||
$valid = $prices->filter(fn (int $price) => $price >= $threshold);
|
|
||||||
|
|
||||||
if ($valid->isEmpty()) {
|
|
||||||
return ['min' => $max, 'max' => $max];
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'min' => (int) $valid->min(),
|
'min' => (int) $prices->min(),
|
||||||
'max' => $max,
|
'max' => (int) $prices->max(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user