Created
December 21, 2023 17:45
-
-
Save alejoasotelo/beb1d357278d6b591b3bd0ba4e465a75 to your computer and use it in GitHub Desktop.
Buscar cauciones en invertir online
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Buscar Cauciones en https://invertironline.com/ | |
Hay que ejecutar este script abriendo la consola dentro de invertironline.com y con la sesión iniciada. | |
En este ejemplo busca cauciones con una tasa de interés mínima de 130% para un monto mínimo de $100.000 de 1 a 30 días como máximo. | |
*/ | |
async function getCauciones(dias) { | |
const response = await fetch("https://iol.invertironline.com/Mercado/GetCaucionPuntas", { | |
"credentials": "include", | |
"headers": { | |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0", | |
"Accept": "*/*", | |
"Accept-Language": "es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3", | |
"X-NewRelic-ID": "VgEDVFNQChAHUVRSAgkOVFY=", | |
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", | |
"X-Requested-With": "XMLHttpRequest", | |
"Sec-Fetch-Dest": "empty", | |
"Sec-Fetch-Mode": "cors", | |
"Sec-Fetch-Site": "same-origin", | |
"Pragma": "no-cache", | |
"Cache-Control": "no-cache" | |
}, | |
"referrer": "https://iol.invertironline.com/Operar/Caucionar", | |
"body": `moneda=PESOS&plazo=${dias}&idTipoTransaccion=14`, | |
"method": "POST", | |
"mode": "cors" | |
}); | |
return await response.json(); | |
} | |
async function findCauciones({tasaMin, montoMin, diasMax}) { | |
let requests = []; | |
for (i=1; i <= diasMax; i++) { | |
requests.push(getCauciones(i)); | |
} | |
const responses = await Promise.all(requests); | |
return responses.map(response => { | |
const puntas = response.listaPuntas.filter( | |
(punta) => parseFloat(punta.precioCompra) >= tasaMin && parseFloat(punta.cantidadCompra) >= montoMin | |
); | |
return { | |
puntas, | |
plazo: response.plazo | |
} | |
}).filter(caucion => caucion.puntas.length > 0); | |
} | |
const cauciones = await findCauciones({ | |
tasaMin: 130, | |
montoMin: 100000, | |
diasMax: 30 | |
}); | |
console.log(cauciones) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment