1
0

Compare commits

..

No commits in common. "4d2c694486047b49adee4cc82d459b39639b7e0e" and "6f3bc1258ef28c0ba57f00504f4adf02457beb04" have entirely different histories.

2 changed files with 17 additions and 28 deletions

View File

@ -20,7 +20,6 @@ import dataclasses
import datetime
import re
from decimal import Decimal
import abc
import enforce_typing
@ -106,11 +105,6 @@ class Asset:
return FiatCurrency(polygon_id.removeprefix('C:').removesuffix('USD'))
return Stock.from_polygon_id(polygon_id)
@abc.abstractmethod
def raw_short_name(self) -> str:
"""A short name or ticker that does not nessisarily uniquely identify
the asset, but may be commonly used within the industry."""
def to_string_id(self) -> str:
"""Formats the asset id using the fin_defs asset format."""
if isinstance(self, Stock):
@ -173,8 +167,6 @@ class FiatCurrency(Currency):
msg = f'iso_code was not in correct format: {self.iso_code}'
raise ValueError(msg)
def raw_short_name(self) -> str:
return self.iso_code
@enforce_typing.enforce_types
@dataclasses.dataclass(frozen=True, eq=True)
@ -189,9 +181,6 @@ class CryptoCurrency(Currency):
raise ValueError(msg)
"""
def raw_short_name(self) -> str:
return self.ccxt_symbol
@enforce_typing.enforce_types
@dataclasses.dataclass(frozen=True, eq=True)
class Stock(Asset):
@ -208,9 +197,6 @@ class Stock(Asset):
def from_polygon_id(polygon_id: str, stock_exchange: StockExchange) -> 'Stock':
return Stock(polygon_id, stock_exchange)
def raw_short_name(self) -> str:
return self.ticker
@enforce_typing.enforce_types
@dataclasses.dataclass(frozen=True, eq=True)
@ -222,8 +208,6 @@ class Index(Asset):
msg = f'ticker was not in correct format: {self.ticker}'
raise ValueError(msg)
def raw_short_name(self) -> str:
return self.ticker
@enforce_typing.enforce_types
@dataclasses.dataclass(frozen=True, eq=True)
@ -235,9 +219,6 @@ class Commodity(Asset):
msg = f'alpha_vantage_id was not in correct format: {self.alpha_vantage_id}'
raise ValueError(msg)
def raw_short_name(self) -> str:
return self.alpha_vantage_id # TODO
Commodity.CRUDE_OIL_WTI = Commodity('WTI')
Commodity.CRUDE_OIL_BRENT = Commodity('BRENT')
@ -308,7 +289,7 @@ WELL_KNOWN_SYMBOLS = (
]
}
| {'XXBT': BTC}
| {k.raw_short_name(): k for k in COMMON_NAMES}
| {str(k): k for k in COMMON_NAMES}
| {'SPX500': SPX, 'SP500': SPX, 'Nasdaq 100': NDX}
)

View File

@ -45,12 +45,20 @@ with open(PACKAGE_NAME + '/_version.py') as f:
version = parse_version_file(f.read())
REQUIREMENTS_MAIN = [
'enforce-typing',
]
REQUIREMENTS_TEST = [
'pytest',
]
def parse_requirements(text: str) -> list[str]:
return text.strip().split('\n')
def read_requirements(path: str) -> list[str]:
with open(path) as f:
return parse_requirements(f.read())
REQUIREMENTS_MAIN = """
enforce-typing"""
REQUIREMENTS_TEST = """
pytest"""
setup(
@ -63,9 +71,9 @@ setup(
author_email='jonjmaa@gmail.com',
url='https://gitfub.space/Jmaa/' + PACKAGE_NAME,
packages=[PACKAGE_NAME],
install_requires=REQUIREMENTS_MAIN,
install_requires=parse_requirements(REQUIREMENTS_MAIN),
extras_require={
'test': REQUIREMENTS_TEST,
'test': parse_requirements(REQUIREMENTS_TEST),
},
python_requires='>=3.9',
)