Script básico para BN8.1 Script avanzado para BN8.2-3 y BN8+ Logro en Bitburner.
BN8.1
función ronda(valor) { let signos = ["", "k", "m", "b", "t"] let which = 0 while (valor > 999 || valor < -999) { valor = Math. round(valor / 10) / 100 ++que } devuelve valor + signos[que] } /** @param {NS} ns */ exporta la función asíncrona main(ns) { ns.disableLog("TODO") let index = ns.args[0] // debe ser FSIG o FLCM let history = [] let max_shares = ns.stock.getMaxShares(index) let max_history = 40 let fee = 100000 while (true) { let money = (ns.getServerMoneyAvailable( "inicio") - tarifa) * 0.9 let precio = ns.stock.getPrice(index) let my_shares = ns.stock.getPosition(index)[0] ns.clearLog() if (history.length > (max_history - 1) ) { if (precio > Math.max(...historia)) { let comprar = Math.floor((dinero / precio)) if ((comprar + mis_acciones) > max_acciones) { comprar = max_acciones - mis_acciones } if (comprar > 0 && (precio * comprar) > 10000000) { ns.print("Comprar (largo): " + ns.stock.buy(índice, comprar)) } } else if (precio < Math.min(...historia )) { if (my_shares > 0) { ns.print("Vender(largo): " + ns.stock.sell(index, my_shares)) } } } history.splice(0, 0, price) if (history.length > max_history) { history.pop() } let profit = ns.stock.getSaleGain(index, my_shares, "Largo") ns.print("Índice: " + index) ns.print("Max Shares: " + round(max_shares)) ns.print("My Long Shares: " + round(ns.stock.getPosition(index)[0])) ns.print("Precio : $" + round(price)) ns.print("Historial guardado: " + history.length) ns.print("Precio más alto: $" + round(Math.max(...history))) ns.print ("Precio más bajo: $" + round(Math.min(...history))) ns.print("------------------------ -") ns.print("Ganancia: $" + round(ganancia)) ns.print("-------------------------") while (precio == ns.stock.getPrice(index)) { esperar ns.sleep(100) } } }
BN8.2-3 & BN8 + Logro
function ronda(valor) { let signos = ["", "k", "m", "b", "t", "q"] let which = 0 while (valor > 999 || valor < -999) { value = Math.round(value / 10) / 100 ++cuál } valor de retorno + signos[cuál] } /** @param {NS} ns */ exportar función asíncrona principal(ns) { ns.disableLog("TODO" ) let index = ns.args[0] // debe ser FSIG o FLCM let history = [] let max_shares = ns.stock.getMaxShares(index) let max_history = 40 let fee = 100000 while (true) { let money = ( ns.getServerMoneyAvailable("home") - fee) * 0.9 let precio = ns.stock.getPrice(index) let my_shares = ns.stock.getPosition(index)[0] let my_shorts = ns.stock.getPosition(index)[ 2] ns.clearLog() if (history.length > (max_history - 1)) { if (price > Math.max(...history)) { if (my_shorts > 0) { ns.print("Sell(Short ): " + ns.stock.sellShort(index, my_shorts)) } let comprar = Math.floor((dinero / precio)) if ((comprar + mis_acciones) > max_shares) { comprar = max_shares - mis_acciones } if (comprar > 0 && (precio * comprar) > 10000000) { ns.print("Comprar(Largo): " + ns.stock.buy(inde x, comprar)) } } else if (precio < Math.min(...history)) { if (my_shares > 0) { ns.print("Vender(largo): " + ns.stock.sell(index, my_shares)) } if (my_shorts == 0) { let comprar = Math.floor(((ns.getServerMoneyAvailable("home") - fee) / price)) if (comprar > max_shares) { comprar = max_shares } ns.print ("Comprar (Corto): " + ns.stock.short (índice, comprar)) } } } history.splice(0, 0, precio) if (history.length > max_history) { history.pop() } let profit if (my_shares > my_shorts) { beneficio = ns.stock.getSaleGain(index, my_shares, "Largo") } else { beneficio = ns.stock.getSaleGain(index, my_shorts, "Short") } ns.print("Índice: " + index) ns.print("Max Shares: " + round(max_shares)) ns.print("My Long Shares: " + round(ns.stock.getPosition(index)[0])) ns.print(" Mis acciones cortas: " + round(ns.stock.getPosition(index)[2])) ns.print("Precio: $" + round(price)) ns.print("Historial guardado: " + history.length) ns.print("Precio más alto: $" + round(Math.max(...history))) ns.print("Precio más bajo: $" + round(Math.min(...history))) ns. imprimir(" -------------------------") ns.print("Beneficio: $" + round(beneficio)) ns.print("--- ----------------------") while (precio == ns.stock.getPrice(index)) { esperar ns.sleep(100) } } }
Eso es todo lo que estamos compartiendo hoy para este Quemador de bits guía. Esta guía fue originalmente creada y escrita por señormaldito. En caso de que no actualicemos esta guía, puede encontrar la última actualización siguiendo este liga.