Skip to content

Commit

Permalink
refactor: rename MarketPrices to MarketPriceSnapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
eseidel committed Feb 20, 2024
1 parent 810472f commit 5102163
Show file tree
Hide file tree
Showing 43 changed files with 78 additions and 77 deletions.
4 changes: 2 additions & 2 deletions packages/cli/bin/contracts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:cli/printing.dart';
void printContracts(
String label,
List<Contract> contracts,
MarketPrices marketPrices, {
MarketPriceSnapshot marketPrices, {
required bool describeContracts,
}) {
if (contracts.isEmpty) {
Expand All @@ -28,7 +28,7 @@ void printContracts(
Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
final printAll = argResults['all'] as bool;
final contractSnapshot = await ContractSnapshot.load(db);
final marketPrices = await MarketPrices.load(db);
final marketPrices = await MarketPriceSnapshot.load(db);
printContracts(
'completed',
contractSnapshot.completedContracts,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/deals_nearby.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Future<void> cliMain(FileSystem fs, Database db, ArgResults argResults) async {
systemConnectivity,
sellsFuel: defaultSellsFuel(marketListings),
);
final marketPrices = await MarketPrices.load(db);
final marketPrices = await MarketPriceSnapshot.load(db);

final behaviorCache = await BehaviorCache.load(db);
final shipCache = await ShipSnapshot.load(db);
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/bin/exports_supply_chain.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class Sourcer {
final MarketListingSnapshot marketListings;
final SystemsCache systemsCache;
final TradeExportCache exportCache;
final MarketPrices marketPrices;
final MarketPriceSnapshot marketPrices;

void sourceViaShuttle(
TradeSymbol tradeSymbol,
Expand Down Expand Up @@ -225,7 +225,7 @@ void source(
MarketListingSnapshot marketListings,
SystemsCache systemsCache,
TradeExportCache exportCache,
MarketPrices marketPrices,
MarketPriceSnapshot marketPrices,
TradeSymbol tradeSymbol,
WaypointSymbol waypointSymbol,
) {
Expand All @@ -242,7 +242,7 @@ Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
final exportCache = TradeExportCache.load(fs);
final systemsCache = SystemsCache.load(fs)!;
final marketListings = await MarketListingSnapshot.load(db);
final marketPrices = await MarketPrices.load(db);
final marketPrices = await MarketPriceSnapshot.load(db);
final agent = await myAgent(db);
final constructionCache = ConstructionCache(db);

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/bin/extract_scores.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:collection/collection.dart';
/// Given a set of trade symbols, compute the percentage sell price
/// across the set.
double _scoreMarkets(
MarketPrices marketPrices,
MarketPriceSnapshot marketPrices,
Map<TradeSymbol, WaypointSymbol> marketForGood,
) {
// Walk the prices for the given symbols at the given market, and compute
Expand Down Expand Up @@ -63,7 +63,7 @@ Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
final charting = ChartingCache(db);
final hqSystem = await myHqSystemSymbol(db);
final marketListings = await MarketListingSnapshot.load(db);
final marketPrices = await MarketPrices.load(db);
final marketPrices = await MarketPriceSnapshot.load(db);

final List<ExtractionScore> scores;
if (isSiphon) {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/find_mounts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:cli/printing.dart';
import 'package:cli/trading.dart';

Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
final marketPrices = await MarketPrices.load(db);
final marketPrices = await MarketPriceSnapshot.load(db);
final systemsCache = SystemsCache.load(fs)!;
final systemConnectivity = await loadSystemConnectivity(db);
final routePlanner = RoutePlanner.fromSystemsCache(
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/bin/fleet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ void main(List<String> args) async {
}

String describeInventory(
MarketPrices marketPrices,
MarketPriceSnapshot marketPrices,
List<ShipCargoItem> inventory, {
String indent = '',
}) {
Expand Down Expand Up @@ -53,7 +53,7 @@ String _behaviorOrTypeString(Ship ship, BehaviorState? behavior) {
void logShip(
SystemsCache systemsCache,
BehaviorCache behaviorCache,
MarketPrices marketPrices,
MarketPriceSnapshot marketPrices,
Ship ship,
) {
const indent = ' ';
Expand Down Expand Up @@ -113,7 +113,7 @@ Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
}

final systemsCache = SystemsCache.load(fs)!;
final marketPrices = await MarketPrices.load(db);
final marketPrices = await MarketPriceSnapshot.load(db);
for (final ship in matchingShips) {
logShip(
systemsCache,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/fleet_charters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void main(List<String> args) async {
void logShip(
SystemsCache systemsCache,
BehaviorCache behaviorCache,
MarketPrices marketPrices,
MarketPriceSnapshot marketPrices,
Ship ship,
) {
const indent = ' ';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/fleet_inventory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Future<void> main(List<String> args) async {

Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
final shipCache = await ShipSnapshot.load(db);
final marketPrices = await MarketPrices.load(db);
final marketPrices = await MarketPriceSnapshot.load(db);
final countByTradeSymbol = <TradeSymbol, int>{};
final ships = shipCache.ships;
for (final ship in ships) {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/fleet_needed_mounts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:cli/cli.dart';
Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
final shipCache = await ShipSnapshot.load(db);
final behaviorCache = await BehaviorCache.load(db);
final marketPrices = await MarketPrices.load(db);
final marketPrices = await MarketPriceSnapshot.load(db);
final centralCommand =
CentralCommand(behaviorCache: behaviorCache, shipCache: shipCache);

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/bin/fleet_value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Future<void> main(List<String> args) async {
}

int _costOutMounts(
MarketPrices marketPrices,
MarketPriceSnapshot marketPrices,
MountSymbolSet mounts,
) {
return mounts.fold<int>(
Expand All @@ -36,7 +36,7 @@ Map<ShipType, int> _shipTypeCounts(

Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
final shipCache = await ShipSnapshot.load(db);
final marketPrices = await MarketPrices.load(db);
final marketPrices = await MarketPriceSnapshot.load(db);
final shipyardPrices = await ShipyardPriceSnapshot.load(db);
final shipyardShips = ShipyardShipCache.load(fs);

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/market_feeder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
final systemsCache = SystemsCache.load(fs)!;
final marketListings = await MarketListingSnapshot.load(db);

final marketPrices = await MarketPrices.load(db);
final marketPrices = await MarketPriceSnapshot.load(db);
final systemConnectivity = await loadSystemConnectivity(db);
final routePlanner = RoutePlanner.fromSystemsCache(
systemsCache,
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/bin/market_listings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void addSymbols(
String category,
Set<TradeSymbol> tradeSymbols,
WaypointSymbol marketSymbol,
MarketPrices marketPrices,
MarketPriceSnapshot marketPrices,
) {
if (tradeSymbols.isEmpty) {
return;
Expand Down Expand Up @@ -66,7 +66,7 @@ Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
final marketListings = await MarketListingSnapshot.load(db);

final waypoints = systemsCache.waypointsInSystem(hqSystem);
final marketPrices = await MarketPrices.load(db);
final marketPrices = await MarketPriceSnapshot.load(db);

for (final waypoint in waypoints) {
final marketSymbol = waypoint.symbol;
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/market_nearby_buys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:cli/printing.dart';
import 'package:cli/trading.dart';

Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
final marketPrices = await MarketPrices.load(db);
final marketPrices = await MarketPriceSnapshot.load(db);
final systemsCache = SystemsCache.load(fs)!;
final systemConnectivity = await loadSystemConnectivity(db);
final routePlanner = RoutePlanner.fromSystemsCache(
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/market_nearby_sells.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:cli/printing.dart';
import 'package:cli/trading.dart';

Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
final marketPrices = await MarketPrices.load(db);
final marketPrices = await MarketPriceSnapshot.load(db);
final systemsCache = SystemsCache.load(fs)!;
final systemConnectivity = await loadSystemConnectivity(db);
final routePlanner = RoutePlanner.fromSystemsCache(
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/market_pairs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
final systemsCache = SystemsCache.load(fs)!;
final hqSystem = await myHqSystemSymbol(db);
final marketListings = await MarketListingSnapshot.load(db);
final marketPrices = await MarketPrices.load(db);
final marketPrices = await MarketPriceSnapshot.load(db);

final listings = marketListings.listings
.where((l) => l.waypointSymbol.system == hqSystem)
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/market_price_freshness.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:cli/printing.dart';
import 'package:stats/stats.dart';

Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
final prices = await MarketPrices.load(db);
final prices = await MarketPriceSnapshot.load(db);
logger.info('${prices.count} prices loaded.');

final now = DateTime.timestamp();
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/market_price_ranges.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void printPriceRanges(List<MarketPrice> gameStats) {
}

Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
final prices = await MarketPrices.load(db);
final prices = await MarketPriceSnapshot.load(db);

logger.info('${prices.count} prices loaded.');
printPriceRanges(prices.prices);
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/market_prices.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:cli/cli.dart';
import 'package:cli/printing.dart';

Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
final marketPrices = await MarketPrices.load(db);
final marketPrices = await MarketPriceSnapshot.load(db);
final marketListings = await MarketListingSnapshot.load(db);

logger.info(
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/market_scores.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:cli/cli.dart';
import 'package:cli/market_scores.dart';

Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
final marketPrices = await MarketPrices.load(db);
final marketPrices = await MarketPriceSnapshot.load(db);
final topTen = scoreMarketSystems(marketPrices, limit: 10);
for (final entry in topTen.entries) {
final market = entry.key;
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/market_trade_volumes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ void main(List<String> args) async {
}

Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
final marketPrices = await MarketPrices.load(db);
final marketPrices = await MarketPriceSnapshot.load(db);
final tradeVolumesBySymbol = <TradeSymbol, Set<int>>{};
for (final price in marketPrices.prices) {
final tradeSymbol = price.symbol;
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/bin/simulate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ final mountPrices = <TradeSymbol, int>{
};

int mountPrice(
MarketPrices marketPrices,
MarketPriceSnapshot marketPrices,
ShipMountSymbolEnum mountSymbol,
) {
final tradeSymbol = tradeSymbolForMountSymbol(mountSymbol);
Expand All @@ -122,7 +122,7 @@ int mountPrice(
return marketPrices.medianPurchasePrice(tradeSymbol) ?? defaultPrice;
}

int costOutMounts(MarketPrices marketPrices, MountSymbolSet mounts) =>
int costOutMounts(MarketPriceSnapshot marketPrices, MountSymbolSet mounts) =>
mounts.map((mount) => mountPrice(marketPrices, mount)).sum;

// For running simulations when we haven't yet found the ship prices.
Expand All @@ -149,7 +149,7 @@ int shipPrice(ShipyardPriceSnapshot shipyardPrices, ShipType shipType) {
}

Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
final marketPrices = await MarketPrices.load(db);
final marketPrices = await MarketPriceSnapshot.load(db);
final systemsCache = SystemsCache.load(fs)!;
final systemConnectivity = await loadSystemConnectivity(db);
final routePlanner = RoutePlanner.fromSystemsCache(
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/static_cache_find_missing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:cli/trading.dart';
import 'package:collection/collection.dart';

Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
final marketPrices = await MarketPrices.load(db);
final marketPrices = await MarketPriceSnapshot.load(db);
final systemsCache = SystemsCache.load(fs)!;
final systemConnectivity = await loadSystemConnectivity(db);
final routePlanner = RoutePlanner.fromSystemsCache(
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/system_watchers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void main(List<String> args) async {
void logShip(
SystemsCache systemsCache,
BehaviorCache behaviorCache,
MarketPrices marketPrices,
MarketPriceSnapshot marketPrices,
Ship ship,
) {
const indent = ' ';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/systems_explored.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ String _typeName(SystemType type) {
}

Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
final marketPrices = await MarketPrices.load(db);
final marketPrices = await MarketPriceSnapshot.load(db);
final shipyardPrices = await ShipyardPriceSnapshot.load(db);
final chartingSnapshot = await ChartingSnapshot.load(db);
final systemsCache = SystemsCache.load(fs)!;
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/waypoint_cache_ages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
final systemsCache = SystemsCache.load(fs)!;
final chartingSnapshot = await ChartingSnapshot.load(db);
final constructionSnapshot = await ConstructionSnapshot.load(db);
final marketPrices = await MarketPrices.load(db);
final marketPrices = await MarketPriceSnapshot.load(db);
final shipyardPrices = await ShipyardPriceSnapshot.load(db);

final waypoints = systemsCache.waypointsInSystem(startSystemSymbol);
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/lib/behavior/central_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ class CentralCommand {
CostedDeal? findNextDealAndLog(
AgentCache agentCache,
ContractSnapshot contractSnapshot,
MarketPrices marketPrices,
MarketPriceSnapshot marketPrices,
SystemsCache systemsCache,
SystemConnectivity systemConnectivity,
RoutePlanner routePlanner,
Expand Down Expand Up @@ -464,7 +464,7 @@ class CentralCommand {
}

/// Updates _availableMounts with any mounts we know of a place to buy.
void updateAvailableMounts(MarketPrices marketPrices) {
void updateAvailableMounts(MarketPriceSnapshot marketPrices) {
for (final mountSymbol in ShipMountSymbolEnum.values) {
if (_availableMounts.contains(mountSymbol)) {
continue;
Expand Down Expand Up @@ -992,7 +992,7 @@ Future<ShipType?> shipToBuyFromPlan(
/// Computes the market subsidies for the current construction job.
List<SellOpp> computeConstructionMaterialSubsidies(
MarketListingSnapshot marketListings,
MarketPrices marketPrices,
MarketPriceSnapshot marketPrices,
TradeExportCache exportsCache,
Construction construction,
) {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/lib/behavior/miner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import 'package:types/types.dart';

/// Returns the expected value of the survey.
int expectedValueFromSurvey(
MarketPrices marketPrices,
MarketPriceSnapshot marketPrices,
Survey survey, {
required Map<TradeSymbol, WaypointSymbol> marketForGood,
}) {
Expand Down Expand Up @@ -64,7 +64,7 @@ class ValuedSurvey {
/// Finds a recent survey
Future<List<ValuedSurvey>> surveysWorthMining(
Database db,
MarketPrices marketPrices, {
MarketPriceSnapshot marketPrices, {
required WaypointSymbol surveyWaypointSymbol,
required Map<TradeSymbol, WaypointSymbol> marketForGood,
int minimumSurveys = 10,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/lib/behavior/mount_from_buy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Future<MountRequest?> mountRequestForShip(
/// Generates a buy job for the first mount we know how to find a buy job for.
BuyJob? buyJobForMount(
MountSymbolSet needed,
MarketPrices marketPrices,
MarketPriceSnapshot marketPrices,
RoutePlanner routePlanner,
Ship ship, {
required int expectedCreditsPerSecond,
Expand Down
Loading

0 comments on commit 5102163

Please sign in to comment.