Compare commits
No commits in common. "d635b6c4b985a292e58c84f63515d2fbcee130fd" and "571ad4e93899460cae3299322a232cbb2501dcea" have entirely different histories.
d635b6c4b9
...
571ad4e938
|
@ -3,7 +3,6 @@ on:
|
|||
push:
|
||||
tags:
|
||||
- 'v[0-9]+.[0-9]+.[0-9]+'
|
||||
paths-ignore: ["README.md", ".gitignore", "LICENSE", "ruff.toml"]
|
||||
|
||||
jobs:
|
||||
Package:
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
name: Test Python
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore: ["README.md", ".gitignore", "LICENSE", "ruff.toml"]
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
Test:
|
||||
|
|
|
@ -16,11 +16,11 @@ Defined hierarchy:
|
|||
- `Commodity`
|
||||
"""
|
||||
|
||||
import abc
|
||||
import dataclasses
|
||||
import datetime
|
||||
import re
|
||||
from decimal import Decimal
|
||||
import abc
|
||||
|
||||
import enforce_typing
|
||||
|
||||
|
@ -124,8 +124,7 @@ class Asset:
|
|||
if isinstance(self, Commodity):
|
||||
return f'commodity:{self.alpha_vantage_id}'
|
||||
|
||||
msg = f'Unsupported asset type: {repr(self)}'
|
||||
raise NotImplementedError(msg)
|
||||
raise NotImplementedError('Unsupported asset type: ' + str(self))
|
||||
|
||||
@staticmethod
|
||||
def from_string_id(asset_id: str) -> 'Asset':
|
||||
|
@ -177,7 +176,6 @@ 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):
|
||||
|
@ -194,7 +192,6 @@ 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):
|
||||
|
@ -228,7 +225,6 @@ 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):
|
||||
|
@ -240,7 +236,7 @@ class Commodity(Asset):
|
|||
raise ValueError(msg)
|
||||
|
||||
def raw_short_name(self) -> str:
|
||||
return self.alpha_vantage_id # TODO
|
||||
return self.alpha_vantage_id # TODO
|
||||
|
||||
|
||||
Commodity.CRUDE_OIL_WTI = Commodity('WTI')
|
||||
|
@ -482,15 +478,12 @@ class AssetAmount:
|
|||
return self.amount < other.amount
|
||||
|
||||
|
||||
AssetPair = tuple[Asset, Asset]
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True, eq=True)
|
||||
class ExchangeRateSample:
|
||||
class ExchangeRateSample(Asset):
|
||||
"""Single exchange rate sample with a timestamp and various stats."""
|
||||
|
||||
timestamp: datetime.date | datetime.datetime
|
||||
asset_pair: AssetPair
|
||||
base_asset: Asset
|
||||
_average: Decimal | None = None
|
||||
last: Decimal | None = None
|
||||
open: Decimal | None = None
|
||||
|
@ -513,7 +506,6 @@ class ExchangeRateSample:
|
|||
one = Decimal('1')
|
||||
return dataclasses.replace(
|
||||
self,
|
||||
asset_pair=(self.asset_pair[1], self.asset_pair[0]),
|
||||
_average=one / self._average if self._average else None,
|
||||
last=one / self.last if self.last else None,
|
||||
open=one / self.open if self.open else None,
|
||||
|
|
|
@ -1 +1 @@
|
|||
__version__ = '0.1.34'
|
||||
__version__ = '0.1.33'
|
||||
|
|
|
@ -2,15 +2,11 @@ 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
|
||||
|
|
Loading…
Reference in New Issue
Block a user