|
|
@@ -14,7 +14,7 @@ def main() -> None:
|
|
|
|
|
|
bids: dict[str, float] = {}
|
|
|
for price in raw_prices:
|
|
|
- if price['ExchangeCode'] != to_cx or price['MMBuy'] is None:
|
|
|
+ if price['ExchangeCode'] != to_cx or price['Bid'] is None:
|
|
|
continue
|
|
|
assert price['Bid'] is not None
|
|
|
bids[price['MaterialTicker']] = price['Bid']
|
|
|
@@ -23,29 +23,37 @@ def main() -> None:
|
|
|
for price in raw_prices:
|
|
|
if price['ExchangeCode'] != from_cx or price['Ask'] is None or (to_price := bids.get(price['MaterialTicker'])) is None:
|
|
|
continue
|
|
|
- rates.append(FX(price['MaterialTicker'], to_price, (price['Ask'] - to_price) / to_price))
|
|
|
-
|
|
|
+ rate = (price['Ask'] - to_price) / to_price
|
|
|
+ if rate < 0.01:
|
|
|
+ rates.append(FX(price['MaterialTicker'], to_price, rate, price['AskCount']))
|
|
|
rates.sort()
|
|
|
+
|
|
|
+ print('mat rate per shipping max converted')
|
|
|
for rate in rates:
|
|
|
- print(f'{rate.ticker:4} {rate.rate:8.5f}', end=' ')
|
|
|
mat = materials[rate.ticker]
|
|
|
if mat['Weight'] >= mat['Volume']:
|
|
|
- print(f'{rate.to_price / mat["Weight"]:9,.0f}/t')
|
|
|
+ if (per_t := rate.to_price / mat['Weight']) < 1000:
|
|
|
+ continue
|
|
|
+ per_shipping = f'{per_t:9,.0f}/t '
|
|
|
else:
|
|
|
- print(f'{rate.to_price / mat["Volume"]:9,.0f}/m³')
|
|
|
+ if (per_m3 := rate.to_price / mat['Volume']) < 1000:
|
|
|
+ continue
|
|
|
+ per_shipping = f'{per_m3:9,.0f}/m³'
|
|
|
+ print(f'{rate.ticker:4} {rate.rate:8.5f} {per_shipping} {rate.depth * rate.to_price:12,.0f}')
|
|
|
|
|
|
class RawPrice(typing.TypedDict):
|
|
|
MaterialTicker: str
|
|
|
ExchangeCode: str
|
|
|
Ask: float | None
|
|
|
Bid: float | None
|
|
|
- MMBuy: float | None
|
|
|
+ AskCount: int
|
|
|
|
|
|
@dataclasses.dataclass(eq=False, frozen=True, slots=True)
|
|
|
class FX:
|
|
|
ticker: str
|
|
|
to_price: float
|
|
|
rate: float
|
|
|
+ depth: int
|
|
|
|
|
|
def __lt__(self, other: FX) -> bool:
|
|
|
return self.rate < other.rate
|