From bc9ea7773fc3b2062068fcca0393938a42a9ced2 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 18 Mar 2022 10:59:05 -0400 Subject: [PATCH] Use units by default for continuous futes --- piker/clearing/_allocate.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/piker/clearing/_allocate.py b/piker/clearing/_allocate.py index 6ef38692..7868666d 100644 --- a/piker/clearing/_allocate.py +++ b/piker/clearing/_allocate.py @@ -178,7 +178,9 @@ class Allocator(BaseModel): l_sub_pp = (self.currency_limit - live_cost_basis) / price else: - raise ValueError(f"Not valid size unit '{size}'") + raise ValueError( + f"Not valid size unit '{size_unit}'" + ) # an entry (adding-to or starting a pp) if ( @@ -290,7 +292,7 @@ def mk_allocator( # default allocation settings defaults: dict[str, float] = { 'account': None, # select paper by default - 'size_unit': 'currency', #_size_units['currency'], + 'size_unit': 'currency', 'units_limit': 400, 'currency_limit': 5e3, 'slots': 4, @@ -318,11 +320,14 @@ def mk_allocator( asset_type = symbol.type_key - # specific configs by asset class / type - if asset_type in ('future', 'option', 'futures_option'): - + if asset_type in ( + 'future', + 'continuous_future', + 'option', + 'futures_option', + ): # since it's harder to know how currency "applies" in this case # given leverage properties alloc.size_unit = '# units'