Skip to content

Commit

Permalink
Added ECB converter 2
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaron committed Aug 21, 2024
1 parent 1fc19fc commit be738e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion roboquant/brokers/simbroker.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def _calculate_short_positions(self):
reserved += short_value
return reserved

def _calculate_buyingpower(self):
def _calculate_buyingpower(self) -> Amount:
"""Calculate buying power, based on:
buying_power = cash - open_orders - short_positions
Expand Down
7 changes: 7 additions & 0 deletions roboquant/monetary.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def __rmatmul__(self, other: float | int):
assert isinstance(other, (float, int))
return Amount(self, other)

def __call__(self, other: float | int):
return Amount(self, other)


# Commonly used currencies
USD = Currency("USD")
Expand All @@ -48,6 +51,10 @@ def convert(self, amount: "Amount", to_currency: Currency, time: datetime) -> fl
"""Convert the monetary amount into another currency at the provided time."""
...

def register(self):
"""Register this converter to be used for conversions between amounts"""
Amount.register_converter(self)


class NoConversion(CurrencyConverter):
"""The default currency converter that doesn't convert between currencies"""
Expand Down

0 comments on commit be738e6

Please sign in to comment.