Make `accounts` field public, add an account name method
							parent
							
								
									d38a6bf032
								
							
						
					
					
						commit
						09d34f7355
					
				|  | @ -83,17 +83,16 @@ class Allocator(BaseModel): | ||||||
| 
 | 
 | ||||||
|         # required to get the account validator lookup working? |         # required to get the account validator lookup working? | ||||||
|         extra = 'allow' |         extra = 'allow' | ||||||
|         # underscore_attrs_are_private = False |         underscore_attrs_are_private = False | ||||||
| 
 | 
 | ||||||
|     symbol: Symbol |     symbol: Symbol | ||||||
| 
 |     accounts: bidict[str, Optional[str]] | ||||||
|     account: Optional[str] = 'paper' |     account: Optional[str] = 'paper' | ||||||
|     _accounts: bidict[str, Optional[str]] |  | ||||||
| 
 | 
 | ||||||
|     @validator('account', pre=True) |     @validator('account', pre=False) | ||||||
|     def set_account(cls, v, values): |     def set_account(cls, v, values): | ||||||
|         if v: |         if v: | ||||||
|             return values['_accounts'][v] |             return values['accounts'][v] | ||||||
| 
 | 
 | ||||||
|     size_unit: SizeUnit = 'currency' |     size_unit: SizeUnit = 'currency' | ||||||
|     _size_units: dict[str, Optional[str]] = _size_units |     _size_units: dict[str, Optional[str]] = _size_units | ||||||
|  | @ -129,6 +128,9 @@ class Allocator(BaseModel): | ||||||
|         else: |         else: | ||||||
|             return self.units_limit |             return self.units_limit | ||||||
| 
 | 
 | ||||||
|  |     def account_name(self) -> str: | ||||||
|  |         return self.accounts.inverse[self.account] | ||||||
|  | 
 | ||||||
|     def next_order_info( |     def next_order_info( | ||||||
|         self, |         self, | ||||||
| 
 | 
 | ||||||
|  | @ -280,7 +282,7 @@ def mk_allocator( | ||||||
| 
 | 
 | ||||||
|     alloc = Allocator( |     alloc = Allocator( | ||||||
|         symbol=symbol, |         symbol=symbol, | ||||||
|         _accounts=accounts, |         accounts=accounts, | ||||||
|         **defaults, |         **defaults, | ||||||
|     ) |     ) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue