Sfoglia il codice sorgente

store historical hardcoded prices

raylu 1 mese fa
parent
commit
60997a02bb

+ 5 - 34
py/prepare.py

@@ -14,8 +14,11 @@ def read_data(f: typing.TextIO) -> dict[str, list[Row]]:
 		data[row[0]].append(Row(int(row[1]), int(row[2]), row[3]))
 	return data
 
-def get_prices(f: typing.TextIO) -> typing.Mapping[str, float]:
-	raw_prices: typing.Sequence[Price] = json.load(f)
+def get_prices(month: str) -> typing.Mapping[str, float]:
+	with open(f'rawData/{month}-prices.json', 'r') as f:
+		raw_prices: typing.Sequence[Price] = json.load(f)
+	with open(f'rawData/{month}-prices-hardcoded.json', 'r') as f:
+		hardcoded_prices: typing.Mapping[str, int] = json.load(f)
 	volumes: dict[str, float] = collections.defaultdict(float)
 	traded: dict[str, int] = collections.defaultdict(int)
 	for price in raw_prices:
@@ -26,38 +29,6 @@ def get_prices(f: typing.TextIO) -> typing.Mapping[str, float]:
 		traded[price['MaterialTicker']] += price['Traded30D']
 
 	prices = {ticker: volume / traded[ticker] for ticker, volume in volumes.items()}
-
-	hardcoded_prices = {
-		'AFP': 65638,
-		'ANZ': 70601,
-		'BFP': 23408,
-		'BSU': 605062,
-		'CPU': 1426423,
-		'CRU': 171386,
-		'DIS': 19583,
-		'GCH': 18303,
-		'GNZ': 30361,
-		'GWS': 9778478,
-		'HAM': 4686751,
-		'HNZ': 93580,
-		'IMM': 101522,
-		'JUI': 0,
-		'NOZ': 74525,
-		'PFG': 2677222,
-		'PK': 1144,
-		'RDS': 598170,
-		'SDM': 1721027,
-		'SST': 5863587,
-		'SU': 157860,
-		'SUD': 84327,
-		'TAC': 245797,
-		'TOR': 540169,
-		'VCB': 673713,
-		'VFT': 1781416,
-		'VOE': 3699358,
-		'VOR': 2547315,
-		'WR': 129412,
-	}
 	assert frozenset(prices).isdisjoint(hardcoded_prices), frozenset(prices).intersection(hardcoded_prices)
 	prices.update(hardcoded_prices)
 	return prices

+ 1 - 2
py/prepare_from_csv.py

@@ -12,8 +12,7 @@ def main() -> None:
 	with open(f'rawData/{month}.csv', 'r', newline='') as f:
 		data = prepare.read_data(f)
 
-	with open(f'rawData/{month}-prices.json', 'r') as f:
-		prices = prepare.get_prices(f)
+	prices = prepare.get_prices(month)
 	prod_data, company_data = get_prod_and_company_data(data, prices)
 	prepare.write_data(month, data, prod_data, company_data)
 	prepare.check_missing_tickers(prod_data)

+ 1 - 2
py/prepare_from_sqlite.py

@@ -19,8 +19,7 @@ def main() -> None:
 	print(', '.join(f'{k}: {run[k]}' for k in run.keys())) # noqa: SIM118
 	assert run['type'] == 'PRODUCTION' and run['range'] == 'DAYS_30' and run['materials_failed']  == 0
 
-	with open(f'rawData/{month}-prices.json', 'r') as f:
-		prices = prepare.get_prices(f)
+	prices = prepare.get_prices(month)
 	prod_data, company_data = get_prod_and_company_data(db, run_id, prices)
 
 	with open(f'rawData/{month}.csv', 'r', newline='') as f:

+ 31 - 0
rawData/aug26-prices-hardcoded.json

@@ -0,0 +1,31 @@
+{
+	"AFP": 65638,
+	"ANZ": 70601,
+	"BFP": 23408,
+	"BSU": 605062,
+	"CPU": 1426423,
+	"CRU": 171386,
+	"DIS": 19583,
+	"GCH": 18303,
+	"GNZ": 30361,
+	"GWS": 9778478,
+	"HAM": 4686751,
+	"HNZ": 93580,
+	"IMM": 101522,
+	"JUI": 0,
+	"NOZ": 74525,
+	"PFG": 2677222,
+	"PK": 1144,
+	"RDS": 598170,
+	"SDM": 1721027,
+	"SST": 5863587,
+	"SU": 157860,
+	"SUD": 84327,
+	"TAC": 245797,
+	"TOR": 540169,
+	"VCB": 673713,
+	"VFT": 1781416,
+	"VOE": 3699358,
+	"VOR": 2547315,
+	"WR": 129412
+}

+ 30 - 0
rawData/jul26-prices-hardcoded.json

@@ -0,0 +1,30 @@
+{
+	"AFP": 65638,
+	"ANZ": 70601,
+	"ARP": 8457,
+	"BID": 55692,
+	"BFP": 23408,
+	"DD": 30111,
+	"GCH": 18303,
+	"GEN": 232097,
+	"GNZ": 30361,
+	"GWS": 9778478,
+	"HAM": 4686751,
+	"HNZ": 93580,
+	"IMM": 101522,
+	"JUI": 0,
+	"LU": 95730,
+	"PFG": 2677222,
+	"RDS": 598170,
+	"SDM": 1721027,
+	"SST": 5863587,
+	"SU": 157860,
+	"SUD": 84327,
+	"TAC": 245797,
+	"TOR": 540169,
+	"VCB": 673713,
+	"VFT": 1781416,
+	"VOE": 3699358,
+	"VOR": 2547315,
+	"VSC": 39446
+}

+ 26 - 0
rawData/jun26-prices-hardcoded.json

@@ -0,0 +1,26 @@
+{
+	"ANZ": 70601,
+	"BFP": 23408,
+	"BGS": 219000,
+	"CRU": 169623,
+	"FUN": 124010,
+	"GCH": 18303,
+	"GNZ": 30361,
+	"HAM": 4686751,
+	"HNZ": 93580,
+	"HPR": 1490000,
+	"LU": 95730,
+	"PFG": 2677222,
+	"RDS": 598170,
+	"RDL": 1390000,
+	"SDM": 1721027,
+	"SEQ": 17977,
+	"SST": 5863587,
+	"SU": 157860,
+	"TAC": 245797,
+	"TCU": 155561,
+	"TOR": 540169,
+	"VCB": 673713,
+	"VOE": 3699358,
+	"VOR": 2547315
+}

+ 22 - 0
rawData/may26-prices-hardcoded.json

@@ -0,0 +1,22 @@
+{
+	"AFP": 116868,
+	"ANZ": 70601,
+	"BFP": 23408,
+	"BND": 230,
+	"BID": 47011,
+	"CRU": 169623,
+	"CQT": 378452,
+	"FUN": 124010,
+	"GCH": 18303,
+	"GNZ": 30361,
+	"HNZ": 93580,
+	"PFG": 2677222,
+	"PK": 869,
+	"RDS": 598170,
+	"SDM": 1721027,
+	"SST": 5863587,
+	"SU": 157860,
+	"TOR": 540169,
+	"VCB": 673713,
+	"WOR": 202000
+}