roi.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. import {setupPopover} from './popover';
  2. const roiCache: Record<string, Promise<{lastModified: Date, profits: Profit[]}>> = {};
  3. async function getROI(cx: string) {
  4. const response = await fetch(`/roi_${cx.toLowerCase()}.json`);
  5. const lastModified = new Date(response.headers.get('last-modified')!);
  6. const profits = await response.json();
  7. return {lastModified, profits};
  8. }
  9. type MetricType = 'vwap' | 'bid' | 'ask';
  10. const lowVolume = document.querySelector('input#low-volume') as HTMLInputElement;
  11. const cxSelect = document.querySelector('select#cx') as HTMLSelectElement;
  12. const expertise = {
  13. AGRICULTURE: 'agri',
  14. CHEMISTRY: 'chem',
  15. CONSTRUCTION: 'const',
  16. ELECTRONICS: 'elec',
  17. FOOD_INDUSTRIES: 'food ind',
  18. FUEL_REFINING: 'fuel',
  19. MANUFACTURING: 'mfg',
  20. METALLURGY: 'metal',
  21. RESOURCE_EXTRACTION: 'res ext',
  22. } as const;
  23. const expertiseSelect = document.querySelector('select#expertise') as HTMLSelectElement;
  24. for (const key of Object.keys(expertise)) {
  25. const option = document.createElement('option');
  26. option.value = key;
  27. option.textContent = key.replace('_', ' ').toLowerCase();
  28. expertiseSelect.appendChild(option);
  29. }
  30. const buildingSelect = document.querySelector('select#building') as HTMLSelectElement;
  31. const formatSigFig = new Intl.NumberFormat(undefined, {
  32. notation: 'compact',
  33. maximumSignificantDigits: 3,
  34. }).format;
  35. if (localStorage.getItem('roi-cx')) cxSelect.value = localStorage.getItem('roi-cx')!;
  36. if (localStorage.getItem('roi-expertise')) expertiseSelect.value = localStorage.getItem('roi-expertise')!;
  37. if (localStorage.getItem('roi-low-volume')) lowVolume.checked = localStorage.getItem('roi-low-volume') === 'true';
  38. let savedBuilding = localStorage.getItem('roi-building') || '';
  39. let storedSortKey = localStorage.getItem('roi-sort-key') as any;
  40. if (storedSortKey === 'logistics_per_base') storedSortKey = 'normalized_logistics_per_base';
  41. let currentSortKey: keyof ProfitWithMetrics | 'outputs' = storedSortKey || 'break_even';
  42. let currentSortAsc: boolean = localStorage.getItem('roi-sort-asc') !== 'false';
  43. let headersInitialized = false;
  44. let metricControlsInitialized = false;
  45. let capexMetric: MetricType = (localStorage.getItem('roi-capex-metric') as MetricType) || 'vwap';
  46. let opexMetric: MetricType = (localStorage.getItem('roi-opex-metric') as MetricType) || 'vwap';
  47. let revenueMetric: MetricType = (localStorage.getItem('roi-revenue-metric') as MetricType) || 'vwap';
  48. // EXTREME DETAIL: Replaced `includeShips` with `roundTripHours`.
  49. // If the user inputs 0, ship CapEx evaluates to 0.
  50. let roundTripHours: number = parseInt(localStorage.getItem('roi-round-trip') || '0', 10);
  51. let showNegativeProfit: boolean = localStorage.getItem('roi-show-negative') !== 'false';
  52. // EXTREME DETAIL: Replaced numerical `workingCapitalDays` state with a string `workingCapitalOption`
  53. // to natively support the 'dynamic' Dropdown value alongside hardcoded integers.
  54. let workingCapitalOption: string = localStorage.getItem('roi-working-capital-opt') || 'dynamic';
  55. let targetPermit: number = parseInt(localStorage.getItem('roi-target-permit') || '2', 10);
  56. async function render() {
  57. const tbody = document.querySelector('tbody')!;
  58. tbody.innerHTML = '';
  59. const cx = cxSelect.value;
  60. if (!roiCache[cx])
  61. roiCache[cx] = getROI(cx);
  62. const {lastModified, profits} = await roiCache[cx];
  63. if (!metricControlsInitialized) {
  64. const controls = document.createElement('div');
  65. controls.style.marginBottom = '15px';
  66. // EXTREME DETAIL: Swapped the checkbox and number inputs for Round Trip (hrs) and the Dropdown Select.
  67. controls.innerHTML = `
  68. <label style="margin-right: 15px;">CapEx Price:
  69. <select id="capex-metric"><option value="vwap">VWAP</option><option value="bid">Bid</option><option value="ask">Ask</option></select>
  70. </label>
  71. <label style="margin-right: 15px;">OpEx Price:
  72. <select id="opex-metric"><option value="vwap">VWAP</option><option value="bid">Bid</option><option value="ask">Ask</option></select>
  73. </label>
  74. <label style="margin-right: 15px;">Revenue Price:
  75. <select id="revenue-metric"><option value="vwap">VWAP</option><option value="bid">Bid</option><option value="ask">Ask</option></select>
  76. </label>
  77. <label style="margin-right: 15px;">
  78. <input type="checkbox" id="show-negative"> Show Negative Profit
  79. </label>
  80. <label style="margin-right: 15px;">
  81. Round Trip (hrs): <input type="number" id="round-trip-hours" min="0" step="1" style="width: 50px;">
  82. </label>
  83. <label style="margin-right: 15px;">
  84. Days OpEx:
  85. <select id="working-capital">
  86. <option value="dynamic">Max for Shipment (dynamic)</option>
  87. <option value="0">0</option>
  88. <option value="1">1</option>
  89. <option value="2">2</option>
  90. <option value="3">3</option>
  91. <option value="4">4</option>
  92. <option value="5">5</option>
  93. <option value="6">6</option>
  94. <option value="7">7</option>
  95. <option value="14">14</option>
  96. <option value="30">30</option>
  97. </select>
  98. </label>
  99. <label>
  100. Permit Number: <input type="number" id="target-permit" min="1" step="1" style="width: 50px;">
  101. </label>
  102. `;
  103. const table = document.querySelector('table');
  104. if (table) table.parentNode?.insertBefore(controls, table);
  105. (document.getElementById('capex-metric') as HTMLSelectElement).value = capexMetric;
  106. (document.getElementById('opex-metric') as HTMLSelectElement).value = opexMetric;
  107. (document.getElementById('revenue-metric') as HTMLSelectElement).value = revenueMetric;
  108. (document.getElementById('show-negative') as HTMLInputElement).checked = showNegativeProfit;
  109. (document.getElementById('round-trip-hours') as HTMLInputElement).value = roundTripHours.toString();
  110. (document.getElementById('working-capital') as HTMLSelectElement).value = workingCapitalOption;
  111. (document.getElementById('target-permit') as HTMLInputElement).value = targetPermit.toString();
  112. document.getElementById('capex-metric')!.addEventListener('change', (e) => {
  113. capexMetric = (e.target as HTMLSelectElement).value as MetricType;
  114. render();
  115. });
  116. document.getElementById('opex-metric')!.addEventListener('change', (e) => {
  117. opexMetric = (e.target as HTMLSelectElement).value as MetricType;
  118. render();
  119. });
  120. document.getElementById('revenue-metric')!.addEventListener('change', (e) => {
  121. revenueMetric = (e.target as HTMLSelectElement).value as MetricType;
  122. render();
  123. });
  124. document.getElementById('show-negative')!.addEventListener('change', (e) => {
  125. showNegativeProfit = (e.target as HTMLInputElement).checked;
  126. render();
  127. });
  128. document.getElementById('round-trip-hours')!.addEventListener('change', (e) => {
  129. roundTripHours = parseInt((e.target as HTMLInputElement).value, 10);
  130. render();
  131. });
  132. document.getElementById('working-capital')!.addEventListener('change', (e) => {
  133. workingCapitalOption = (e.target as HTMLSelectElement).value;
  134. render();
  135. });
  136. document.getElementById('target-permit')!.addEventListener('change', (e) => {
  137. targetPermit = parseInt((e.target as HTMLInputElement).value, 10);
  138. render();
  139. });
  140. metricControlsInitialized = true;
  141. }
  142. if (!headersInitialized) {
  143. const ths = document.querySelectorAll('th');
  144. const keys: (keyof ProfitWithMetrics | 'outputs')[] = [
  145. 'outputs', 'expertise', 'profit_per_base', 'break_even',
  146. 'capex_val', 'opex_val', 'normalized_logistics_per_base', 'market_capacity_base'
  147. ];
  148. ths.forEach((th, i) => {
  149. if (keys[i]) {
  150. th.style.cursor = 'pointer';
  151. th.title = '';
  152. if (keys[i] === 'profit_per_base') {
  153. th.textContent = 'Profit/Base';
  154. th.dataset.tooltip = 'Click to sort.\n\nDaily profit scaled to a full 500-area planetary base.\n(Percentiles rank 100.0% as the most desirable outcome, i.e., highest profit or lowest cost.)';
  155. } else if (keys[i] === 'capex_val') {
  156. th.textContent = 'CapEx/Base';
  157. th.dataset.tooltip = 'Click to sort.\n\nTotal capital expenditure scaled to a full 500-area planetary base.\nIncludes base construction, working capital (days of OpEx), optional HQ Upgrade materials for the target permit, and Ship CapEx (set Round Trip hrs to 0 to exclude).';
  158. } else if (keys[i] === 'opex_val') {
  159. th.textContent = 'OpEx/Base';
  160. th.dataset.tooltip = 'Click to sort.\n\nDaily operational expenditure (input materials + worker consumables) scaled to a full 500-area planetary base.';
  161. } else if (keys[i] === 'normalized_logistics_per_base') {
  162. th.textContent = 'Logistics/Base';
  163. th.dataset.tooltip = 'Click to sort.\n\nDaily logistics bottleneck scaled to a full 500-area planetary base. The suffix indicates whether Weight (t) or Volume (m³) of Inputs (I) or Outputs (O) is the limiting bottleneck.\nSorts and percentiles are strictly normalized based on ship capacity limits (3000t or 1000m³).';
  164. } else if (keys[i] === 'market_capacity_base') {
  165. th.textContent = 'Market Cap (Bases)';
  166. th.dataset.tooltip = 'Click to sort.\n\nMarket Capacity: 7-day average traded volume ÷ daily output per base. Indicates how many full 500-area bases you can build before saturating the market.';
  167. } else if (keys[i] === 'break_even') {
  168. th.dataset.tooltip = 'Click to sort.\n\nBreak Even: CapEx ÷ daily profit. Note that CapEx dynamically includes working capital and HQ upgrades to accurately reflect operational readiness.';
  169. } else {
  170. th.dataset.tooltip = 'Click to sort.';
  171. }
  172. th.addEventListener('click', () => {
  173. if (currentSortKey === keys[i]) {
  174. currentSortAsc = !currentSortAsc;
  175. } else {
  176. currentSortKey = keys[i];
  177. currentSortAsc = keys[i] === 'break_even' ? true : false;
  178. }
  179. render();
  180. });
  181. }
  182. });
  183. headersInitialized = true;
  184. }
  185. const buildingTickers = new Set(profits.map(p => p.building));
  186. const buildings: {ticker: string, expertise: keyof typeof expertise}[] = Array.from(buildingTickers)
  187. .map((building) => ({ticker: building, expertise: profits.find(p => p.building === building)!.expertise}))
  188. .sort((a, b) => a.ticker.localeCompare(b.ticker));
  189. let selectedBuilding = buildingSelect.value || savedBuilding;
  190. let buildingFound = false;
  191. buildingSelect.innerHTML = '<option value="">(all)</option>';
  192. for (const building of buildings)
  193. if (expertiseSelect.value === '' || expertiseSelect.value === building.expertise) {
  194. const option = document.createElement('option');
  195. option.value = building.ticker;
  196. option.textContent = building.ticker;
  197. if (building.ticker === selectedBuilding) {
  198. buildingFound = true;
  199. option.selected = true;
  200. }
  201. buildingSelect.appendChild(option);
  202. }
  203. if (!buildingFound)
  204. selectedBuilding = '';
  205. savedBuilding = '';
  206. const filteredProfits = profits.filter(p => {
  207. const volumeRatio = p.output_per_day / p.average_traded_7d;
  208. if (!lowVolume.checked && volumeRatio > 0.05) return false;
  209. if (expertiseSelect.value !== '' && p.expertise !== expertiseSelect.value) return false;
  210. if (selectedBuilding !== '' && p.building !== selectedBuilding) return false;
  211. return true;
  212. });
  213. const dynamicOpEx = workingCapitalOption === 'dynamic';
  214. let profitsWithMetrics: ProfitWithMetrics[] = filteredProfits.map(p => {
  215. const bases = p.area / 500;
  216. const opex_val = p.opex[opexMetric] / bases;
  217. const revenue_val = p.revenue[revenueMetric] / bases;
  218. // EXTREME DETAIL: We determine exactly how many OpEx days are required.
  219. // If 'dynamic' is selected, the required working capital scales perfectly inverse to the logistics
  220. // footprint (e.g., if a base fills 0.5 ships a day, the max shipment interval is 1/0.5 = 2 days).
  221. let activeWorkingCapitalDays = 0;
  222. if (dynamicOpEx) {
  223. activeWorkingCapitalDays = p.normalized_logistics_per_base > 0
  224. ? 1 / p.normalized_logistics_per_base
  225. : 0;
  226. } else {
  227. activeWorkingCapitalDays = parseInt(workingCapitalOption, 10);
  228. }
  229. let capex_val = (p.capex[capexMetric] / bases) + (opex_val * activeWorkingCapitalDays);
  230. let hq_capex = 0;
  231. if (targetPermit >= 3) {
  232. const hqLevelStr = (targetPermit - 1).toString();
  233. if (p.hq_costs && p.hq_costs[hqLevelStr]) {
  234. hq_capex = p.hq_costs[hqLevelStr][capexMetric];
  235. capex_val += hq_capex;
  236. }
  237. }
  238. // EXTREME DETAIL: Little's Law dictates that Inventory in transit = Throughput * Lead Time.
  239. // Throughput = daily ship fraction. Lead Time = Round Trip Hours / 24.
  240. // This generates the absolute fleet size required to prevent bottlenecks.
  241. const shipsNeeded = p.normalized_logistics_per_base * (roundTripHours / 24);
  242. const activeShipCapex = shipsNeeded * 800_000;
  243. if (roundTripHours > 0) {
  244. capex_val += activeShipCapex;
  245. }
  246. const profit_per_base = revenue_val - opex_val;
  247. const break_even = profit_per_base > 0 ? capex_val / profit_per_base : Infinity;
  248. return {
  249. ...p,
  250. capex_val,
  251. opex_val,
  252. revenue_val,
  253. profit_per_base,
  254. break_even,
  255. hq_capex,
  256. activeWorkingCapitalDays,
  257. activeShipCapex,
  258. shipsNeeded
  259. };
  260. });
  261. if (!showNegativeProfit) {
  262. profitsWithMetrics = profitsWithMetrics.filter(p => p.profit_per_base > 0);
  263. }
  264. const numSort = (a: number, b: number) => (a < b ? -1 : a > b ? 1 : 0);
  265. const arrProfit = profitsWithMetrics.map(p => p.profit_per_base).sort(numSort);
  266. const arrBreak = profitsWithMetrics.map(p => p.break_even).sort(numSort);
  267. const arrCapex = profitsWithMetrics.map(p => p.capex_val).sort(numSort);
  268. const arrOpex = profitsWithMetrics.map(p => p.opex_val).sort(numSort);
  269. const arrLog = profitsWithMetrics.map(p => p.normalized_logistics_per_base).sort(numSort);
  270. const arrCap = profitsWithMetrics.map(p => p.market_capacity_base).sort(numSort);
  271. profitsWithMetrics.sort((a, b) => {
  272. let valA: any = a[currentSortKey as keyof ProfitWithMetrics];
  273. let valB: any = b[currentSortKey as keyof ProfitWithMetrics];
  274. if (currentSortKey === 'outputs') {
  275. valA = a.outputs.map(o => o.ticker).join(', ');
  276. valB = b.outputs.map(o => o.ticker).join(', ');
  277. }
  278. if (valA < valB) return currentSortAsc ? -1 : 1;
  279. if (valA > valB) return currentSortAsc ? 1 : -1;
  280. return 0;
  281. });
  282. for (const p of profitsWithMetrics) {
  283. const tr = document.createElement('tr');
  284. const pctProfit = getPercentile(p.profit_per_base, arrProfit, false);
  285. const pctBreak = getPercentile(p.break_even, arrBreak, true);
  286. const pctCapex = getPercentile(p.capex_val, arrCapex, true);
  287. const pctOpex = getPercentile(p.opex_val, arrOpex, true);
  288. const pctLog = getPercentile(p.normalized_logistics_per_base, arrLog, true);
  289. const pctCap = getPercentile(p.market_capacity_base, arrCap, false);
  290. tr.innerHTML = `
  291. <td>${p.outputs.map(o => o.ticker).join(', ')}</td>
  292. <td>${expertise[p.expertise]}</td>
  293. <td style="color: ${color(p.profit_per_base, 0, 150000)}">${formatSigFig(p.profit_per_base)} <span style="font-size: 0.85em; opacity: 0.6;">(${pctProfit})</span></td>
  294. <td><span style="color: ${color(p.break_even, 30, 3)}">${formatSigFig(p.break_even)}</span>d <span style="font-size: 0.85em; opacity: 0.6;">(${pctBreak})</span></td>
  295. <td style="color: ${color(p.capex_val, 3_000_000, 400_000)}">${formatSigFig(p.capex_val)} <span style="font-size: 0.85em; opacity: 0.6;">(${pctCapex})</span></td>
  296. <td style="color: ${color(p.opex_val, 400_000, 10_000)}">${formatSigFig(p.opex_val)} <span style="font-size: 0.85em; opacity: 0.6;">(${pctOpex})</span></td>
  297. <td style="color: ${color(p.normalized_logistics_per_base, 1.0, 0.1)}">${formatSigFig(p.logistics_per_base)} ${p.logistics_bottleneck} <span style="font-size: 0.85em; opacity: 0.6;">(${pctLog})</span></td>
  298. <td style="color: ${color(p.market_capacity_base, 0.04, 1)}">${formatSigFig(p.market_capacity_base)} <span style="font-size: 0.85em; opacity: 0.6;">(${pctCap})</span></td>
  299. `;
  300. const output = tr.querySelector('td')!;
  301. output.dataset.tooltip = p.recipe;
  302. const profitCell = tr.querySelectorAll('td')[2];
  303. const runs_per_base = p.runs_per_day / (p.area / 500);
  304. profitCell.dataset.tooltip = formatMatPrices(p.outputs, revenueMetric, runs_per_base) + '\n\n' +
  305. formatMatPrices(p.input_costs, opexMetric, runs_per_base) + '\n' +
  306. '+ worker consumables\n\n' +
  307. `(${formatSigFig(p.revenue_val)} - ${formatSigFig(p.opex_val)}) = ${formatSigFig(p.profit_per_base)}`;
  308. // EXTREME DETAIL: Updated the tooltip to track the dynamically assigned working capital
  309. // and the newly calculated Ship fleet size derived from the user's explicit Round Trip Time.
  310. const capexCell = tr.querySelectorAll('td')[4];
  311. capexCell.dataset.tooltip = `Base Construction: ${formatSigFig(p.capex[capexMetric] / (p.area / 500))}`;
  312. capexCell.dataset.tooltip += `\nWorking Capital (${formatSigFig(p.activeWorkingCapitalDays)} days): ${formatSigFig(p.opex_val * p.activeWorkingCapitalDays)}`;
  313. if (p.hq_capex > 0) {
  314. capexCell.dataset.tooltip += `\nHQ Upgrade (Permit ${targetPermit}): ${formatSigFig(p.hq_capex)}`;
  315. }
  316. if (roundTripHours > 0) {
  317. capexCell.dataset.tooltip += `\nShip CapEx: ${formatSigFig(p.activeShipCapex)} (${formatSigFig(p.shipsNeeded)} ships)`;
  318. }
  319. const marketCell = tr.querySelectorAll('td')[7];
  320. marketCell.dataset.tooltip = `Market Capacity: ${formatSigFig(p.average_traded_7d)} traded/day ÷ ${formatSigFig(p.output_per_day / (p.area / 500))} produced/day/base = ${formatSigFig(p.market_capacity_base)} equivalent bases`;
  321. tbody.appendChild(tr);
  322. }
  323. document.getElementById('last-updated')!.textContent =
  324. `last updated: ${lastModified.toLocaleString(undefined, {dateStyle: 'full', timeStyle: 'long', hour12: false})}`;
  325. saveState();
  326. }
  327. function getPercentile(val: number, sortedArr: number[], invert: boolean = false): string {
  328. if (sortedArr.length < 2) return "100.0%";
  329. let less = 0;
  330. for (let i = 0; i < sortedArr.length; i++) {
  331. if (sortedArr[i] < val) less++;
  332. else break;
  333. }
  334. let decimal = less / (sortedArr.length - 1);
  335. if (invert) {
  336. decimal = 1.0 - decimal;
  337. }
  338. return (decimal * 100).toFixed(1) + "%";
  339. }
  340. function saveState() {
  341. localStorage.setItem('roi-cx', cxSelect.value);
  342. localStorage.setItem('roi-expertise', expertiseSelect.value);
  343. localStorage.setItem('roi-building', buildingSelect.value);
  344. localStorage.setItem('roi-low-volume', lowVolume.checked.toString());
  345. localStorage.setItem('roi-sort-key', currentSortKey);
  346. localStorage.setItem('roi-sort-asc', currentSortAsc.toString());
  347. localStorage.setItem('roi-capex-metric', capexMetric);
  348. localStorage.setItem('roi-opex-metric', opexMetric);
  349. localStorage.setItem('roi-revenue-metric', revenueMetric);
  350. localStorage.setItem('roi-show-negative', showNegativeProfit.toString());
  351. localStorage.setItem('roi-round-trip', roundTripHours.toString());
  352. localStorage.setItem('roi-working-capital-opt', workingCapitalOption);
  353. localStorage.setItem('roi-target-permit', targetPermit.toString());
  354. }
  355. function color(n: number, low: number, high: number): string {
  356. const scale = Math.min(Math.max((n - low) / (high - low), 0), 1);
  357. return `color-mix(in xyz, #0aa ${scale * 100}%, #f80)`;
  358. }
  359. function formatMatPrices(matPrices: MatPrice[], metric: MetricType, runs_per_day: number): string {
  360. return matPrices.map(({ticker, amount, vwap_7d, bid, ask}) => {
  361. const val = metric === 'vwap' ? vwap_7d : metric === 'bid' ? (bid ?? vwap_7d) : (ask ?? vwap_7d);
  362. const daily_amount = amount * runs_per_day;
  363. return `${ticker}: ${formatSigFig(daily_amount)} × ${formatSigFig(val)} = ${formatSigFig(daily_amount * val)}`;
  364. }).join('\n');
  365. }
  366. setupPopover();
  367. lowVolume.addEventListener('change', render);
  368. cxSelect.addEventListener('change', render);
  369. expertiseSelect.addEventListener('change', render);
  370. buildingSelect.addEventListener('change', render);
  371. render();
  372. interface Metrics {
  373. vwap: number;
  374. bid: number;
  375. ask: number;
  376. }
  377. interface Profit {
  378. outputs: MatPrice[]
  379. recipe: string
  380. expertise: keyof typeof expertise
  381. building: string
  382. area: number
  383. capex: Metrics
  384. opex: Metrics
  385. revenue: Metrics
  386. input_costs: MatPrice[]
  387. runs_per_day: number
  388. logistics_per_base: number
  389. normalized_logistics_per_base: number
  390. logistics_bottleneck: string
  391. output_per_day: number
  392. average_traded_7d: number
  393. market_capacity_base: number
  394. hq_costs: Record<string, Metrics>
  395. }
  396. interface ProfitWithMetrics extends Profit {
  397. capex_val: number;
  398. opex_val: number;
  399. revenue_val: number;
  400. profit_per_day: number;
  401. profit_per_base: number;
  402. break_even: number;
  403. hq_capex: number;
  404. activeWorkingCapitalDays: number; // Added to interface to pass to the tooltip generator
  405. activeShipCapex: number; // Added to interface to pass to the tooltip generator
  406. shipsNeeded: number; // Added to interface to pass to the tooltip generator
  407. }
  408. interface MatPrice {
  409. ticker: string
  410. amount: number
  411. vwap_7d: number
  412. bid: number | null
  413. ask: number | null
  414. }
  415. interface Building {
  416. building_type: 'INFRASTRUCTURE' | 'PLANETARY' | 'PRODUCTION';
  417. building_ticker: string;
  418. expertise: keyof typeof expertise;
  419. }