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

View File

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