Commit Graph

4456 Commits (max_pain_deribit)

Author SHA1 Message Date
Nelson Torres 3526d5d564 minor refactor
cleaning the code
2024-12-08 13:38:23 -03:00
Nelson Torres 1ac643018a added aux method for update and check if completed 2024-12-08 13:34:58 -03:00
Nelson Torres f26a42e76f datetime for humans 2024-12-08 10:51:17 -03:00
Nelson Torres 3295303e37 More configs refactor
Now in the broker config file are the log configs for cryptofeed.
2024-12-07 11:15:43 -03:00
Nelson Torres f31d868a55 get_config refactor 2024-12-07 10:37:34 -03:00
Nelson Torres 0563b916a3 major refactor
all the logic now in the max_pain script
2024-12-07 10:17:27 -03:00
Nelson Torres 3e613ab2a0 fix the input values
for acm related to oi
2024-12-07 10:16:37 -03:00
Nelson Torres 57059da682 moved function out of api 2024-12-07 10:13:12 -03:00
Nelson Torres ca5e1b6ed1 removed unused variable
minor refactor
expiry date changed to 20DEC24
2024-12-06 11:09:17 +00:00
Nelson Torres ec1da6134b Update api.py
Now intrinsic values list is initialize in the aio_open_interest_feed_relay instead in the scope above.
2024-12-05 23:49:02 -03:00
Nelson Torres cbc5168b8d renaming variable
fixed variable name for better understanding.
2024-12-05 23:43:13 -03:00
Nelson Torres 2b70518eb9 Update poetry.lock 2024-12-05 23:32:09 -03:00
Nelson Torres bf86772d4b oi max_pain major refactor
Now the max_pain is calculated taking into account all strike prices and all close prices to find the intrinsic value as deribit.
2024-12-05 23:31:36 -03:00
Nelson Torres c4600a0392 auxiliar methods 2024-12-05 23:29:45 -03:00
Nelson Torres ec2123175a some refactor 2024-12-04 19:18:29 -03:00
Nelson Torres 5de14bc3f9 added first calcs for max_pain 2024-12-03 14:35:57 -03:00
Nelson Torres 6e08c60d53 deactivate cryptofeed debug log 2024-12-03 14:29:35 -03:00
Nelson Torres a9110b1196 Update api.py
Now we get the data for an e specific expiration date if and expiry_date is passed, or for all expiration if expiry_date is None
2024-12-02 09:47:20 -03:00
Nelson Torres 9abbd8ca1e Update api.py
open_interest for each strike price and each expiry date
2024-11-29 10:49:07 -03:00
Nelson Torres 24bf19c1fb Update api.py
get_currencies function
2024-11-29 10:41:20 -03:00
Nelson Torres 4ccda643b8 Update api.py
covers cases when option_type comes as PUT or P, same with calls CALL or C
2024-11-29 10:39:48 -03:00
Nelson Torres 7b02df9b49 Update api.py
This function receive a date in this format DDMMMYY and returns timestamps int
2024-11-29 10:38:17 -03:00
Nelson Torres f2f7855e54 max_pain_daemon 2024-11-26 15:16:21 -03:00
Nelson Torres 16480bd2d4 maybe_open_oi_feed 2024-11-26 15:15:59 -03:00
Nelson Torres 733b58250f open_oi_feed 2024-11-26 15:15:51 -03:00
Nelson Torres 564cd63014 aio_open_interest_feed_relay 2024-11-26 15:15:38 -03:00
Nelson Torres 17249205c9 get_instrumets for cryptofeed.FeedHandler 2024-11-26 15:15:01 -03:00
Nelson Torres b646133ead minor get_config fix 2024-11-26 15:11:04 -03:00
Nelson Torres cb436048d2 OpenInterest imports for cryptofeed 2024-11-26 15:10:24 -03:00
Tyler Goodlet 5cefe8bcdb `deribit.feed`: fix "trade" event streaming
The main change needed to make `piker.data.feed._FeedsBus` work was
to correctly format the `'trade'` msgs with the (new schema) expected
`'ticks': list[dict]` field which,
- we compute the `piker` quote-msg-`dict` from the (now directly proxied through)
  `cryptofeed.types.Trade`'s fields inside the body of `stream_quotes()`.
- similarly, move the `'l1'` msg processing, **out of** the `asyncio`-side
  `_l1()` callback (defined as a closure in `.api.aio_price_feed_relay()`
  and passed to the `cryptofeed.FeedHandler`) and instead mod the
  callback to simply pass through the `.types.L1Book` ref directly to
  the `piker`/`trio` side task for conversion.

In support of all that,
- mask-to-drop the alt-branch to wait on a first rt event when the
  `cryptofeed.LastTradesResult.trades: list[Trade]` is empty; doesn't
  seem like this ever even happens?
- add a buncha typing, comments and doc-strs to the routines in
  `.deribit.api` including notes on where we can choose to mod the
  `.bs_fqme` for our eventually preferred `piker` style format.
- simplify some nested `@acm` enters to the new single `async with
  <tuple>)` style.
- be particularly pedantic about typing
  `tractor.to_asyncio.LinkedTaskChannel`
- bit of pep8 line-spacing fixes in `.venues`.
2024-11-22 14:58:30 -05:00
Tyler Goodlet d96e9d4f11 Ignore non-`.parquet` (suffixed) paths for now during tsdb fs-indexing 2024-11-19 21:39:02 -05:00
Tyler Goodlet a0dcf14aba Mask `ruff` config and pin `websockets=0.12`
- the `ruff` section in the `pyproject.toml` is somehow borked? (even
  though it def was working a while back..)
- `websockets` is completely broken in latest version since it's using
  old-ass `asyncio` APIs of some sort i think??
2024-11-19 21:37:20 -05:00
Tyler Goodlet 1705afb607 `.deribit.feed`: get live quotes workin (again)
The quote-msg `'topic'` field was being set and sent as the
`OptionPair.symbol: str` value instead of as the `MktPair.bs_fqme: str`
as is required for matching on the `piker.data.feed` side. So change to
that and simplify the actual `.bs_fqme: str` value to NOT include the
ISO-format time (for now) since it's a big ugly and longer term we need
a `piker`-fqme friendly-on-ze-eyes format/style anyway..
2024-11-19 21:14:33 -05:00
Tyler Goodlet dafd5a3ca5 Bit more `cryptofeed` adapter formatting and typing for clarity.. 2024-11-19 21:14:11 -05:00
Tyler Goodlet b9dde98d1e .deribit.venues: add todo for an ideal `OptionPair.expiry` fmt/value 2024-11-19 21:13:21 -05:00
Tyler Goodlet 1616cc0e82 `.data._sampling`: warn about subscriber-less msgs
Since it usually means the data-provider backend is keying the msgs
incorrectly (not using the equivalent `MktPair.bs_fqme` which as
would be rendered from the delivered `FeedInit.mkt` instance..) and
reporting the subs list should make it clear how the fqme matching is
off.

Deats,
- use the new `.log.mk_repr()` for a formatter.
- add a commented info emission that can be unmasked to help debug any
  such cases as mentioned in the summary ^^.
2024-11-19 21:09:09 -05:00
Tyler Goodlet 0a2ed195a7 Add `.log.mk_repr()` to create `reprlib.Repr`s 2024-11-19 21:05:16 -05:00
Tyler Goodlet 28e8628c61 Report the closest (via fuzzy match) pairs on unmatched input 2024-11-19 17:50:26 -05:00
Tyler Goodlet b734245183 Signal hist start using `OptionPair.creation_timestamp`
Such that the `get_hist()` query func raises `DataUnavailable` with an
explicit message regarding the start of the (option) contract's
lifetime.

Other,
- mask some unused imports (for now?)
- drop a duplicate `tractor.get_console_log()` call which was causing
  duplicate console emits (it's already setup by brokerd init now).
- comment various unused code bits i found.
- add a info log around live quotes so we can see for the moment when
  they actually occur.. XD
2024-11-19 17:45:39 -05:00
Tyler Goodlet dc2c379d86 `.deribit.api` bit of tidying/typing
There were some imports missing or unused as well as a variety of spots
that had grokability issues due to missing type hints.

Other tweaks as part some more thorough manual testing:
- always raise when not `brokers.toml` section since the API can never
  work (no free data without keys).
- inline the `Asset.atype='crypto_currency` field despite it maybe not
  being the best value for `OptionPair` instruments..
- tossed in a now-masked pause block for debugging history queries in
  `Client.bars()`.
- commented out all the live order ctl (internal) endpoints for now
  since they're unused.
2024-11-19 17:09:16 -05:00
Tyler Goodlet be84d0dae1 'Fix `Optional` and use `'linear/reverse'` in `OptionPair.venue`' 2024-11-19 17:05:13 -05:00
Tyler Goodlet bdc3bc9219 Mk jsronrpc's underlying ws timeout `float('inf')`
Since currently we're only using this IPC subsys for `deribit`, and
generally speaking we're primarly supporting options markets (which are
fairly "slow moving"), flip to a default of NOT resetting the `NoBsWs`
on timeout since doing so normally breaks the jsron-rpc IPC session.
Without a proper `fixture` passed to `open_autorecon_ws()` (which we
should eventually implement!!) relying on a timeout-to-reset more or
less will just cause breakage issues - a proper reconnect sequence must
be implemented before using that feature.

Deats,
- expose and proxy through the `msg_recv_timeout` from
  `open_jsonrpc_session()` into the underlying `open_autorecon_ws()`
  call.
2024-11-19 16:58:40 -05:00
Tyler Goodlet 9232d09440 Refine history gap/termination signalling
Namely handling backends which do not provide a default "frame
size-duration" in their init-config by making the backfiller guess the
value based on the first frame received.

Deats,
- adjust `start_backfill()` to take a more explicit
  `def_frame_duration: Duration` expected to be unpacked from any
  backend hist init-config by the `tsdb_backfill()` caller which now
  also computes a value from the first received frame when the config
  section isn't provided.
- in `start_backfill()` we now always expect the `def_frame_duration`
  input and always decrement the query range by this value whenever
  a `NoData` is raised by the provider-backend paired with an explicit
  `log.warning()` about the handling.
- also relay any `DataUnavailable.args[0]` message from the provider
  in the handler.
- repair "gap reporting" which checks for expected frame duration vs.
  that received with much better humanized logging on the missing
  segment using `pendulum.Interval/Duration.in_words()` output.
2024-11-19 16:58:06 -05:00
Tyler Goodlet f96bd51442 Only use `frame_types` if delivered during enter
The `open_history_client()` provider endpoint can *optionally*
deliver a `frame_types: dict[int, pendulum.Duration]` subsection in its
`config: dict[str, dict]` (as was implemented with the `ib` backend).
This allows the `tsp` backfilling machinery to use this "recommended
frame duration" to subtract from the `last_start_dt` any time a `NoData`
gap is signalled by the `get_hist()` call allowing gaps to be ignored
safely without missing history by knowing the next earliest dt we can
query from using the `end_dt`. However, currently all crypto$ providers
haven't implemented this feat yet..

As such only try to use the `frame_types` feature if provided when
handling `NoData` conditions inside `tsp.start_backfill()` and otherwise
raise as normal.
2024-11-18 09:45:19 -05:00
Nelson Torres 6555ccfbba config refactor
only one get_config method for api class and cryptofeed feed handler
2024-11-15 15:24:08 -03:00
Nelson Torres 75d1d007fb move constants to venue 2024-11-15 14:41:47 -03:00
Nelson Torres 2bdbe0f20e refactor redundant code 2024-11-15 14:26:16 -03:00
Nelson Torres a117177759 name formatting fixes 2024-11-15 11:23:05 -03:00
Nelson Torres 30060a83c9 get_mkt_info cleanup 2024-11-15 11:22:27 -03:00
Nelson Torres 156a35b606 cache_symbols refactor 2024-11-15 11:20:48 -03:00