Add get expiration dates in deribit api
							parent
							
								
									1c0a2e4eb3
								
							
						
					
					
						commit
						5423e38a75
					
				|  | @ -23,8 +23,22 @@ def check_if_complete( | ||||||
| 
 | 
 | ||||||
| async def max_pain_daemon( | async def max_pain_daemon( | ||||||
| ) -> None: | ) -> None: | ||||||
|     expiry_date: str = input('Please enter a valid expiration date (7feb25): ').upper() |     oi_by_strikes: dict[str, dict[str, Decimal | None]] | ||||||
|     print('Initializing...') |     expiry_dates: list[str] | ||||||
|  |     currency: str = 'btc' | ||||||
|  |     kind: str = 'option' | ||||||
|  | 
 | ||||||
|  |     async with get_client( | ||||||
|  |     ) as client: | ||||||
|  |         expiry_dates: list[str] = await client.get_expiration_dates( | ||||||
|  |             currency=currency, | ||||||
|  |             kind=kind | ||||||
|  |         ) | ||||||
|  | 
 | ||||||
|  |     print(f'Available expiration dates for {currency}-{kind}:') | ||||||
|  |     print(f'{expiry_dates}') | ||||||
|  |     expiry_date: str = input('Please enter a valid expiration date: ').upper() | ||||||
|  |     print('Starting little daemon...') | ||||||
|     instruments: list[Symbol] = [] |     instruments: list[Symbol] = [] | ||||||
|     oi_by_strikes: dict[str, dict[str, Decimal]] |     oi_by_strikes: dict[str, dict[str, Decimal]] | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -425,6 +425,29 @@ class Client: | ||||||
| 
 | 
 | ||||||
|         return response_list |         return response_list | ||||||
| 
 | 
 | ||||||
|  |     async def get_expiration_dates( | ||||||
|  |         self, | ||||||
|  |         currency: str = 'btc', | ||||||
|  |         kind: str = 'option', | ||||||
|  | 
 | ||||||
|  |     ) ->  list[str]: | ||||||
|  |         """ | ||||||
|  |         Get a dict with all expiration dates listed as value and currency as key. | ||||||
|  |         """ | ||||||
|  |          | ||||||
|  |         params: dict[str, str] = { | ||||||
|  |             'currency': currency.upper(), | ||||||
|  |             'kind': kind, | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         r: JSONRPCResult = await self._json_rpc_auth_wrapper( | ||||||
|  |             'public/get_expirations', | ||||||
|  |             params, | ||||||
|  |         ) | ||||||
|  |         resp = r.result | ||||||
|  | 
 | ||||||
|  |         return resp[currency][kind] | ||||||
|  | 
 | ||||||
|     def get_strikes_dict( |     def get_strikes_dict( | ||||||
|         self, |         self, | ||||||
|         instruments: list[Symbol], |         instruments: list[Symbol], | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue