From ed03d77e6e02594716dc38a84bd032e9182a2e42 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 21 Mar 2022 15:25:45 -0400 Subject: [PATCH] Make a derivs intrustment type table for alloc config checks --- piker/clearing/_allocate.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/piker/clearing/_allocate.py b/piker/clearing/_allocate.py index 7868666d..71d7d9a0 100644 --- a/piker/clearing/_allocate.py +++ b/piker/clearing/_allocate.py @@ -284,6 +284,14 @@ class Allocator(BaseModel): return round(prop * self.slots) +_derivs = ( + 'future', + 'continuous_future', + 'option', + 'futures_option', +) + + def mk_allocator( symbol: Symbol, @@ -322,12 +330,7 @@ def mk_allocator( # specific configs by asset class / type - if asset_type in ( - 'future', - 'continuous_future', - 'option', - 'futures_option', - ): + if asset_type in _derivs: # since it's harder to know how currency "applies" in this case # given leverage properties alloc.size_unit = '# units' @@ -350,7 +353,7 @@ def mk_allocator( if startup_size > alloc.units_limit: alloc.units_limit = startup_size - if asset_type in ('future', 'option', 'futures_option'): + if asset_type in _derivs: alloc.slots = alloc.units_limit return alloc