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