fix: restore rows=20 and add last-resort fallback to prevent null p2pBuyMax
Browse files
main.py
CHANGED
|
@@ -190,7 +190,7 @@ async def fetch_p2p() -> dict:
|
|
| 190 |
body_base = {
|
| 191 |
"fiat": "VES",
|
| 192 |
"page": 1,
|
| 193 |
-
"rows":
|
| 194 |
"asset": "USDT",
|
| 195 |
"countries": [],
|
| 196 |
"proMerchantAds": False,
|
|
@@ -262,6 +262,15 @@ async def fetch_p2p() -> dict:
|
|
| 262 |
return price
|
| 263 |
except (KeyError, ValueError, TypeError):
|
| 264 |
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 265 |
return None
|
| 266 |
|
| 267 |
p2p_buy = first_eligible_price(sell_ads_res.json().get("data", []))
|
|
|
|
| 190 |
body_base = {
|
| 191 |
"fiat": "VES",
|
| 192 |
"page": 1,
|
| 193 |
+
"rows": 20,
|
| 194 |
"asset": "USDT",
|
| 195 |
"countries": [],
|
| 196 |
"proMerchantAds": False,
|
|
|
|
| 262 |
return price
|
| 263 |
except (KeyError, ValueError, TypeError):
|
| 264 |
continue
|
| 265 |
+
|
| 266 |
+
# Último recurso: primer anuncio desde índice 1 con stock
|
| 267 |
+
for item in ads[1:]:
|
| 268 |
+
adv = item.get("adv", {})
|
| 269 |
+
try:
|
| 270 |
+
if float(adv.get("surplusAmount", 0)) > 0:
|
| 271 |
+
return float(adv["price"])
|
| 272 |
+
except (KeyError, ValueError, TypeError):
|
| 273 |
+
continue
|
| 274 |
return None
|
| 275 |
|
| 276 |
p2p_buy = first_eligible_price(sell_ads_res.json().get("data", []))
|