piker icon indicating copy to clipboard operation
piker copied to clipboard

Account tests

Open goodboy opened this issue 2 years ago • 0 comments

More or less starting the final push to get piker.accounting and friends to a place where we can never get wrong position calcs, implement said calcs using polars.DataFrames, do offline ledger processing for all accounts, and be in a place to start implementing position metrics curves display in the chart UI as mentioned in https://github.com/pikers/piker/issues/515.


Tasks:

  • [ ] implement Client.get_assets() and .get_mkt_pairs() for all backends to support the new .data._symcache stuff:

    • [x] binance

      • [x] full symcache support
      • [ ] reorg pair types into a .symbols mod (rn it's called venues)
    • [x] kraken (4c550730)

      • [x] put sym stuff in .symbols.py
    • [x] ib (ALSO, figure out how the cache is going to work here since pulling all contracts is a bit infeasible..)

      • [x] disable SymbologyCache loading via _no_symcache = True attr.

      • [ ] make issue for attempting a soln for ib symcaching:

        • available search tools:
          • https://interactivebrokers.github.io/tws-api/basic_contracts.html
          • https://misc.interactivebrokers.com/cstools/contract_info/v3.10/index.php
          • https://www.interactivebrokers.com/en/index.php?f=products
        • forum discussions/potential solutions:
          • https://groups.io/g/insync/topic/87564236
          • https://groups.io/g/insync/message/7119
          • https://stackoverflow.com/questions/29876693/interactive-brokers-symbol-list
          • https://www.elitetrader.com/et/threads/ib-api-get-all-expirys-and-strikes-of-a-stock-symbol.279786/
      • [ ] kucoin

        • [ ] at least get data feeds workin again.. requires paper engine patch?
        • [ ] re-org into submods including new symbols.py..
        • [ ] add Client.get_assets() and .get_mkt_pairs() since support should be easy to add.
    • [ ] make follow up issue for backends not yet supporting broker mode / order ctl?

      • [ ] deribit? (is anyone maintaining this any more tho @guilledk?)
      • [ ] questrade.. lol gotta get back to this
  • [ ] re-implement open_account() as async ctx mngr and do ledger loading implicitly as well as provide public interface for updates via probably a .ledger attr?

    • [ ] expose public API to access account-state polars.DataFrames as well as the ledger df as loaded by .accounting.calc.open_ledger_dfs()

    • [ ] implement and document pl.DataFrame based .bep and .ppu

      • TURNS OUT, the old dict impl was kinda buggy anyway due to our dt-sorting which seems to not be always iterating out correctly?
      • [ ] definitely document all this in an .accounting/README.rst

Test list:

  • [ ] "offline" ledger test set:

    • [ ] binance.paper input ledgers (of various sorts) where we verify Account.pps: dict[str Position properties outputs
      • [ ] long to zero
      • [ ] short to zero
      • [ ] long to short (via single clear) and back to zero
    • [ ] use an ib.algopaper actual flex and API ledger and verify at least a (subset) of pps.
  • [ ] symcache tests which verify creation for all backends and reloads when requested?

goodboy avatar Jul 05 '23 15:07 goodboy