1
0
This commit is contained in:
Jon Michael Aanes 2024-08-09 16:56:28 +02:00
parent 571ad4e938
commit aad7c9939e
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
2 changed files with 9 additions and 2 deletions

View File

@ -16,11 +16,11 @@ Defined hierarchy:
- `Commodity`
"""
import abc
import dataclasses
import datetime
import re
from decimal import Decimal
import abc
import enforce_typing
@ -176,6 +176,7 @@ class FiatCurrency(Currency):
def raw_short_name(self) -> str:
return self.iso_code
@enforce_typing.enforce_types
@dataclasses.dataclass(frozen=True, eq=True)
class CryptoCurrency(Currency):
@ -192,6 +193,7 @@ class CryptoCurrency(Currency):
def raw_short_name(self) -> str:
return self.ccxt_symbol
@enforce_typing.enforce_types
@dataclasses.dataclass(frozen=True, eq=True)
class Stock(Asset):
@ -225,6 +227,7 @@ class Index(Asset):
def raw_short_name(self) -> str:
return self.ticker
@enforce_typing.enforce_types
@dataclasses.dataclass(frozen=True, eq=True)
class Commodity(Asset):

View File

@ -2,11 +2,15 @@ import pytest
import fin_defs
@pytest.mark.parametrize('asset', fin_defs.WELL_KNOWN_SYMBOLS.values())
def test_to_from_string_id(asset: fin_defs.Asset):
assert fin_defs.Asset.from_string_id(asset.to_string_id()) == asset
import fin_defs
@pytest.mark.parametrize('asset', fin_defs.WELL_KNOWN_SYMBOLS.values())
def test_to_from_polygon_id(asset: fin_defs.Asset):
assert fin_defs.Asset.from_polygon_id(asset.to_polygon_id()) == asset