Skip to content

Commit be738e6

Browse files
committed
Added ECB converter 2
1 parent 1fc19fc commit be738e6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

roboquant/brokers/simbroker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def _calculate_short_positions(self):
182182
reserved += short_value
183183
return reserved
184184

185-
def _calculate_buyingpower(self):
185+
def _calculate_buyingpower(self) -> Amount:
186186
"""Calculate buying power, based on:
187187
188188
buying_power = cash - open_orders - short_positions

roboquant/monetary.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ def __rmatmul__(self, other: float | int):
2323
assert isinstance(other, (float, int))
2424
return Amount(self, other)
2525

26+
def __call__(self, other: float | int):
27+
return Amount(self, other)
28+
2629

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

54+
def register(self):
55+
"""Register this converter to be used for conversions between amounts"""
56+
Amount.register_converter(self)
57+
5158

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

0 commit comments

Comments
 (0)