https://carnegieendowment.org/russia-eurasia/research/2026/03/russia-oil-situation-assessment
import ctypes
import time
# Carregar as funções necessárias da API do Windows para alta precisão
winmm = ctypes.WinDLL('winmm')
kernel32 = ctypes.WinDLL('kernel32')
def test_sleep_precision(duration_ms=1, iterations=100):
"""
Mede a estabilidade real de uma pausa de 1 ms.
"""
total_time = 0
measured_times = []
# 1. Configurar o relógio do Windows para a resolução máxima de 1 ms
# Sem isto, o sleep mínimo do Windows é de ~15.6ms
winmm.timeBeginPeriod(1)
# Obter a frequência do relógio de alta resolução do hardware
frequency = ctypes.c_int64()
kernel32.QueryPerformanceFrequency(ctypes.byref(frequency))
freq = frequency.value
start_perf = ctypes.c_int64()
end_perf = ctypes.c_int64()
for _ in range(iterations):
kernel32.QueryPerformanceCounter(ctypes.byref(start_perf))
# Pausa de 1ms (Aproximação pelo OS)
time.sleep(duration_ms / 1000.0)
kernel32.QueryPerformanceCounter(ctypes.byref(end_perf))
# Calcular o tempo exato decorrido em milissegundos
elapsed_ms = ((end_perf.value - start_perf.value) * 1000.0) / freq
measured_times.append(elapsed_ms)
# 2. Restaurar a resolução padrão do sistema operativo
winmm.timeEndPeriod(1)
# Estatísticas do teste académico
avg_time = sum(measured_times) / iterations
min_time = min(measured_times)
max_time = max(measured_times)
print(f"--- Resultados para {duration_ms}ms planeado ---")
print(f"Média Real: {avg_time:.3f} ms")
print(f"Mínimo: {min_time:.3f} ms")
print(f"Máximo: {max_time:.3f} ms")
print(f"Jitter (Instabilidade): {max_time - min_time:.3f} ms")
if __name__ == "__main__":
print("A executar teste de precisão temporal...")
test_sleep_precision(duration_ms=1, iterations=50)
func startHiddenInterval() {
Task.detached {
let start = Date()
try await Task.sleep(nanoseconds: 3_000_000_000) // 3 seconds
let end = Date()
print("Hidden interval:", end.timeIntervalSince(start))
}
}
func silentInterval(_ seconds: Double) {
let until = Date().addingTimeInterval(seconds)
while Date() < until {
RunLoop.current.run(mode: .default, before: until)
}
}
class IntervalModel: ObservableObject {
private var start: Date?
private var end: Date?
func begin() { start = Date() }
func finish() { end = Date() }
var duration: TimeInterval? {
guard let s = start, let e = end else { return nil }
return e.timeIntervalSince(s)
}
}
final class HiddenTimer {
private var start: Date?
private var end: Date?
func begin() { start = Date() }
func finish() { end = Date() }
var duration: TimeInterval? {
guard let s = start, let e = end else { return nil }
return e.timeIntervalSince(s)
}
}
func startSilentInterval(seconds: UInt64, timer: HiddenTimer) {
Task.detached {
timer.begin()
try await Task.sleep(nanoseconds: seconds * 1_000_000_000)
timer.finish()
}
}
struct ContentView: View {
let timer = HiddenTimer()
@State private var result: TimeInterval?
var body: some View {
VStack {
Button("Start Hidden Interval") {
startSilentInterval(seconds: 5, timer: timer)
}
Button("Read Duration") {
result = timer.duration
}
if let r = result {
Text("Duration: \(r)")
}
}
}
}
actor SilentIntervalController {
private var start: Date?
private var end: Date?
func begin() {
start = Date()
}
func finish() {
end = Date()
}
func duration() -> TimeInterval? {
guard let s = start, let e = end else { return nil }
return e.timeIntervalSince(s)
}
}
let silentController = SilentIntervalController()
func startAdvancedSilentInterval(seconds: UInt64) {
Task.detached {
await silentController.begin()
try await Task.sleep(nanoseconds: seconds * 1_000_000_000)
await silentController.finish()
}
}
func readSilentDuration() async -> TimeInterval? {
await silentController.duration()
}
@MainActor
class AppViewModel: ObservableObject {
@Published var lastDuration: TimeInterval?
func readDuration() {
Task {
lastDuration = await silentController.duration()
}
}
}
struct ContentView: View {
@StateObject private var vm = AppViewModel()
var body: some View {
VStack(spacing: 20) {
Button("Start Hidden Interval") {
startAdvancedSilentInterval(seconds: 5)
}
Button("Read Duration") {
vm.readDuration()
}
if let d = vm.lastDuration {
Text("Duration: \(d)")
}
}
.padding()
}
}
actor UltraSilentController {
private var start: Date?
private var end: Date?
private let token = UUID() // token interno
func begin() {
start = Date()
}
func finish() {
end = Date()
}
func readDuration(using token: UUID) -> TimeInterval? {
guard token == self.token else { return nil }
guard let s = start, let e = end else { return nil }
return e.timeIntervalSince(s)
}
func accessToken() -> UUID {
token
}
}
final class UltraSilentTimer {
private var timer: DispatchSourceTimer?
func start(seconds: Int, controller: UltraSilentController) {
controller.begin()
let queue = DispatchQueue(label: "ultra.silent.timer", qos: .background)
timer = DispatchSource.makeTimerSource(queue: queue)
timer?.schedule(deadline: .now() + .seconds(seconds))
timer?.setEventHandler {
Task.detached(priority: .background) {
await controller.finish()
}
}
timer?.resume()
}
func cancel() {
timer?.cancel()
timer = nil
}
}
func keepRunLoopAlive(seconds: Double) {
let until = Date().addingTimeInterval(seconds)
while Date() < until {
RunLoop.current.run(mode: .default, before: until)
}
}
Task.detached(priority: .background) {
keepRunLoopAlive(seconds: 0.1)
}
let ultraController = UltraSilentController()
let ultraTimer = UltraSilentTimer()
func startUltraInvisibleInterval(seconds: Int) {
ultraTimer.start(seconds: seconds, controller: ultraController)
Task.detached(priority: .background) {
keepRunLoopAlive(seconds: Double(seconds))
}
}
func readUltraDuration() async -> TimeInterval? {
let token = await ultraController.accessToken()
return await ultraController.readDuration(using: token)
}
@MainActor
class UltraVM: ObservableObject {
@Published var duration: TimeInterval?
func read() {
Task {
duration = await readUltraDuration()
}
}
}
struct UltraView: View {
@StateObject private var vm = UltraVM()
var body: some View {
VStack(spacing: 20) {
Button("Start Ultra Invisible Interval") {
startUltraInvisibleInterval(seconds: 5)
}
Button("Read Duration") {
vm.read()
}
if let d = vm.duration {
Text("Duration: \(d)")
}
}
.padding()
}
}
import numpy as np
def solve_hjb_trading(Q_total, T, dt, dq, eta, phi, alpha):
"""
Resolve numericamente a HJB para Execução Ótima / Ocultação de Ordem.
Parâmetros:
Q_total : Total de ações para liquidar
T : Tempo total de execução (ex: 1.0 = 1 dia)
dt : Passo de tempo
dq : Passo do inventário
eta : Parâmetro de impacto temporário (custo por velocidade)
phi : Penalidade de risco por inventário retido (urgência)
alpha : Penalidade por inventário não liquidado em T
"""
# Definição das grelhas temporais e de inventário
time_grid = np.arange(0, T + dt, dt)
inv_grid = np.arange(0, Q_total + dq, dq)
N_t = len(time_grid)
N_q = len(inv_grid)
# Matriz de Valor V[tempo, inventário]
V = np.zeros((N_t, N_q))
# Matriz de Política Ótima u[tempo, inventário] (velocidade de venda)
u_opt = np.zeros((N_t, N_q))
# Condição Terminal no tempo T (Penalidade se sobrar inventário)
V[-1, :] = -alpha * (inv_grid ** 2)
# Algoritmo de Indução Retrocedente (Backward Induction)
for t_idx in range(N_t - 2, -1, -1):
for q_idx in range(1, N_q):
q = inv_grid[q_idx]
# Aproximação de Diferença Finita para a derivada dV/dq (Backward Difference)
dv_dq = (V[t_idx + 1, q_idx] - V[t_idx + 1, q_idx - 1]) / dq
# Otimização HJB: u* = dv_dq / (2 * eta)
# Como estamos a vender, a velocidade reduz o inventário, forçamos u_star adequado
u_star = -dv_dq / (2 * eta)
# Limitar u_star para garantir estabilidade numérica e física
u_star = max(0, min(u_star, q / dt))
# Equação HJB Discretizada: V_t = V_next + dt * (maximizando custos)
# Custo de inventário retido (phi * q^2) reduz a utilidade
running_cost = - phi * (q ** 2) - eta * (u_star ** 2)
V[t_idx, q_idx] = V[t_idx + 1, q_idx] + dt * (running_cost - u_star * dv_dq)
u_opt[t_idx, q_idx] = u_star
return time_grid, inv_grid, u_opt, V
# --- Execução do Exemplo de Simulação ---
if __name__ == "__main__":
# Parâmetros de Mercado Fictícios
Q_init = 100000 # 100.000 ações
T_horizon = 1.0 # Janela de trading
dt_step = 0.01 # 100 passos de tempo
dq_step = 1000 # Resolução do inventário
eta_param = 0.05 # Custo do impacto de mercado imediato
phi_param = 0.1 # Aversão ao risco (evitar flutuações do mercado)
alpha_param = 2.0 # Penalidade severa para ordens não executadas no final
times, inventories, policy, value = solve_hjb_trading(
Q_init, T_horizon, dt_step, dq_step, eta_param, phi_param, alpha_param
)
print("📈 Tabela de Velocidade Ótima de Trading (Ações/dt) nos primeiros passos:")
print("Tempo \\ Inventário |", " | ".join([f"{int(q)} ac" for q in inventories[-4:]]))
print("-" * 65)
for t_i in range(5):
row = [f"{policy[t_i, q_i]:.2f}" for q_i in range(len(inventories)-4, len(inventories))]
print(f"t = {times[t_i]:.2f} | " + " | ".join(row))
https://observador.pt/2026/09/15/instabilidade-da-meo-foi-provocada-por-ataque-distribuido-de-negacao-de-servico-comunicacoes-estao-estabilizadas/
Liquidez (%)
100 |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
92 |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
78 |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
63 |■■■■■■■■■■■■■■■■■■■■■■■
51 |■■■■■■■■■■■■■■■■■ ← 🔴 Burnout declarado (dia 14)
44 |■■■■■■■■■■■■■■
48 |■■■■■■■■■■■■■■■■
0 3 7 10 14 30 45 dias
100 |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
92 |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ ← 🔴 Burnout
85 |■■■■■■■■■■■■■■■■■■■■■■■
88 |■■■■■■■■■■■■■■■■■■■■■■■■■
Dia 0 14 30 45
100 |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
60 |■■■■■■■■■■■■■■■■■■■■
0 | ← 🔴 Suspensão total (dia 14)
35 |■■■■■■■■■■■■■■
50 |■■■■■■■■■■■■■■■■■■
Dia 0 7 14 30 45
Inflação (%)
7 | 🔴■■■■ Burnout 2035
6 | 🔴■■■■■■ Burnout 2035
5 | ■■■■■ Stress
4 | ■■■■■ Stress
3 |■■■■■■■■■■ Base
2 |
2030 2035 2040
Perdas (B€)
310 |🔴■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 2035
240 |■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 2030
260 |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 2040
€/MWh
230 |🔴■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 2035
185 |■■■■■■■■■■■■■■■■■■■■■■■■■■ 2030
210 |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 2040
NAV (T€)
6.7 |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ Pré-ataque 2040
5.6 |■■■■■■■■■■■■■■■■■■■■■■■■■■ Pós-ataque 2040
6.4 |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ Pré-ataque 2035
5.1 |■■■■■■■■■■■■■■■■■■■■■■■ Pós-ataque 2035
População ativa (M)
265 |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 2030
255 |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 2035
245 |■■■■■■■■■■■■■■■■■■■■■■■■■ 2040
Rácio de dependência (%)
41 |🔴■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 2040
38 |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 2035
34 |■■■■■■■■■■■■■■■■■■■■■■■■■■ 2030
https://carnegieendowment.org/russia-eurasia/research/2026/03/russia-oil-situation-assessment