commit
						8cde68fedb
					
				| 
						 | 
				
			
			@ -282,7 +282,6 @@ class Client:
 | 
			
		|||
        pattern: str,
 | 
			
		||||
        # how many contracts to search "up to"
 | 
			
		||||
        upto: int = 3,
 | 
			
		||||
        asdicts: bool = True,
 | 
			
		||||
    ) -> Dict[str, ContractDetails]:
 | 
			
		||||
        """Search for stocks matching provided ``str`` pattern.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -304,11 +303,17 @@ class Client:
 | 
			
		|||
            # XXX: if there is more then one entry in the details list
 | 
			
		||||
            details = {}
 | 
			
		||||
            for details_set in results:
 | 
			
		||||
 | 
			
		||||
                # then the contract is so called "ambiguous".
 | 
			
		||||
                for d in details_set:
 | 
			
		||||
                    con = d.contract
 | 
			
		||||
                    unique_sym = f'{con.symbol}.{con.primaryExchange}'
 | 
			
		||||
                    details[unique_sym] = asdict(d) if asdicts else d
 | 
			
		||||
 | 
			
		||||
                    as_dict = asdict(d)
 | 
			
		||||
                    # nested dataclass we probably don't need and that won't IPC serialize
 | 
			
		||||
                    as_dict.pop('secIdList')
 | 
			
		||||
 | 
			
		||||
                    details[unique_sym] = as_dict
 | 
			
		||||
 | 
			
		||||
                    if len(details) == upto:
 | 
			
		||||
                        return details
 | 
			
		||||
| 
						 | 
				
			
			@ -1086,6 +1091,9 @@ async def stream_quotes(
 | 
			
		|||
    syminfo = asdict(details)
 | 
			
		||||
    syminfo.update(syminfo['contract'])
 | 
			
		||||
 | 
			
		||||
    # nested dataclass we probably don't need and that won't IPC serialize
 | 
			
		||||
    syminfo.pop('secIdList')
 | 
			
		||||
 | 
			
		||||
    # TODO: more consistent field translation
 | 
			
		||||
    atype = syminfo['asset_type'] = asset_type_map[syminfo['secType']]
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -97,8 +97,7 @@ class _Token:
 | 
			
		|||
 | 
			
		||||
    def __post_init__(self):
 | 
			
		||||
        # np.array requires a list for dtype
 | 
			
		||||
        self.dtype_descr = np.dtype(
 | 
			
		||||
            list(self.dtype_descr)).descr
 | 
			
		||||
        self.dtype_descr = np.dtype(list(map(tuple, self.dtype_descr))).descr
 | 
			
		||||
 | 
			
		||||
    def as_msg(self):
 | 
			
		||||
        return asdict(self)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -514,7 +514,10 @@ async def open_feed(
 | 
			
		|||
 | 
			
		||||
                # cast shm dtype to list... can't member why we need this
 | 
			
		||||
                shm_token = data['shm_token']
 | 
			
		||||
                shm_token['dtype_descr'] = list(shm_token['dtype_descr'])
 | 
			
		||||
 | 
			
		||||
                # XXX: msgspec won't relay through the tuples XD
 | 
			
		||||
                shm_token['dtype_descr'] = list(map(tuple, shm_token['dtype_descr']))
 | 
			
		||||
 | 
			
		||||
                assert shm_token == shm.token  # sanity
 | 
			
		||||
 | 
			
		||||
            feed._max_sample_rate = max(ohlc_sample_rates)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue