the FOSS computational trading platform (for non-tinas..) https://github.com/pikers/piker
Go to file
Tyler Goodlet 05af2b3e64 Rework `.accounting.Position` calcs to prep for `polars`
We're probably going to move to implementing all accounting using
`polars.DataFrame` and friends and thus this rejig preps for a much more
"stateless" implementation of our `Position` type and its internal
pos-accounting metrics: `ppu` and `cumsize`.

Summary:
- wrt to `._pos.Position`:
  - rename `.size`/`.accum_size` to `.cumsize` to be more in line
    with `polars.DataFrame.cumsum()`.
  - make `Position.expiry` delegate to the underlying `.mkt: MktPair`
    handling (hopefully) all edge cases..
  - change over to a new `._events: dict[str, Transaction]` in prep
    for #510 (and friends) and enforce a new `Transaction.etype: str`
    which is by default `clear`.
  - add `.iter_by_type()` which iterates, filters and sorts the
    entries in `._events` from above.
  - add `Position.clearsdict()` which returns the dict-ified and
    datetime-sorted table which can more-or-less be stored in the
    toml account file.
  - add `.minimized_clears()` a new (and close) version of the old
    method which always grabs at least one clear before
    a position-side-polarity-change.
  - mask-drop `.ensure_state()` since there is no more `.size`/`.price`
    state vars (per say) as we always re-calc the ppu and cumsize from
    the clears records on every read.
  - `.add_clear` no longer does bisec insorting since all sorting is
    done on position properties *reads*.
  - move the PPU (price per unit) calculator to a new `.accounting.calcs`
    as well as add in the `iter_by_dt()` clearing transaction sorted
    iterator.
    - also make some fixes to this to handle both lists of `Transaction`
      as well as `dict`s as before.

- start rename of `PpTable` -> `Account` and make a note about adding
  a `.balances` table.
- always `float()` the transaction size/price values since it seems if
  they get processed as `tomlkit.Integer` there's some suuper weird
  double negative on read-then-write to the clears table?
  - something like `cumsize = -1` -> `cumsize = --1` !?!?
- make `load_pps_from_ledger()` work again but now includes some very
  very first draft `polars` df processing from a transaction ledger.
  - use this from the `accounting.cli.disect` subcmd which is also in
    *super early draft* mode ;)
- obviously as mentioned in the `Position` section, add the new `.calcs`
  module with a `.ppu()` calculator func B)
2023-07-12 08:45:55 -04:00
.github/workflows Drop elastic search container build for now since we're also skipping the test 2023-05-26 16:50:53 -04:00
config binance: add accounts def to `brokers.toml` template 2023-06-27 13:42:08 -04:00
dockering (u)Limit the fd allocation for java 8 runtime.. 2023-05-09 14:49:25 -04:00
docs Drop marketstore and tina install from readme, add polars and apache! 2023-06-27 13:41:47 -04:00
examples basic bot: iter latest ticks first to decide new submission price per quote 2023-06-27 15:47:23 -04:00
piker Rework `.accounting.Position` calcs to prep for `polars` 2023-07-12 08:45:55 -04:00
scripts `ib`: restore and (maybe) use `xdotool` + `i3ipc` reset method 2023-03-03 17:37:26 -05:00
snippets Move ib data reset script into a new `scripts/` dir 2022-05-09 11:15:13 -04:00
tests Fix test to use new `load_account()` location 2023-07-12 08:45:55 -04:00
.gitignore Ignore snippets dir 2022-03-01 12:36:32 -05:00
LICENSE Relicense to AGPLv3 2020-06-16 00:12:19 -04:00
MANIFEST.in Slap in brokers.toml template if none exists 2021-05-22 15:11:39 -04:00
README.rst Drop marketstore and tina install from readme, add polars and apache! 2023-06-27 13:41:47 -04:00
develop.nix TOCHERRY: into #486, add polars/apache deps for nix 2023-06-27 13:41:47 -04:00
notes_to_self.rst Start nts 2022-01-25 07:57:01 -05:00
pytest.ini Ensure actual pp is sent to ems 2023-02-25 18:59:40 -05:00
requirements-test.txt Add docker and elasticsearch to test deps 2023-05-23 14:16:02 -04:00
requirements.txt Change to `piker_pin` branch in `tomlkit` fork 2023-05-25 13:53:14 -04:00
setup.py First draft `.storage.nativedb.` using parquet files 2023-06-27 13:41:47 -04:00

README.rst

piker

trading gear for hackers.

gh_actions

piker is a broker agnostic, next-gen FOSS toolset for real-time computational trading targeted at hardcore Linux users .

we use as much bleeding edge tech as possible including (but not limited to):

focus and features:

  • 100% federated: your code, your hardware, your data feeds, your broker fills.
  • zero web: low latency, native software that doesn't try to re-invent the OS
  • maximal privacy: prevent brokers and mms from knowing your planz; smack their spreads with dark volume.
  • zero clutter: modal, context oriented UIs that echew minimalism, reduce thought noise and encourage un-emotion.
  • first class parallelism: built from the ground up on next-gen structured concurrency primitives.
  • traders first: broker/exchange/asset-class agnostic
  • systems grounded: real-time financial signal processing that will make any queuing or DSP eng juice their shorts.
  • non-tina UX: sleek, powerful keyboard driven interaction with expected use in tiling wms
  • data collaboration: every process and protocol is multi-host scalable.
  • fight club ready: zero interest in adoption by suits; no corporate friendly license, ever.

fitting with these tenets, we're always open to new framework suggestions and ideas.

building the best looking, most reliable, keyboard friendly trading platform is the dream; join the cause.

sane install with poetry

TODO!

rigorous install on nixos using poetry2nix

TODO!

hacky install on nixos

NixOS is our core devs' distro of choice for which we offer a stringently defined development shell envoirment that can be loaded with:

nix-shell develop.nix

this will setup the required python environment to run piker, make sure to run:

pip install -r requirements.txt -e .

once after loading the shell

install wild-west style via pip

piker is currently under heavy pre-alpha development and as such should be cloned from this repo and hacked on directly.

for a development install:

git clone git@github.com:pikers/piker.git
cd piker
virtualenv env
source ./env/bin/activate
pip install -r requirements.txt -e .

check out our charts

bet you weren't expecting this from the foss:

piker -l info -b kraken -b binance chart btcusdt.binance --pdb

this runs the main chart (currently with 1m sampled OHLC) in in debug mode and you can practice paper trading using the following micro-manual:

order_mode (

edge triggered activation by any of the following keys, mouse-click on y-level to submit at that price ):

  • f/ ctl-f to stage buy
  • d/ ctl-d to stage sell
  • a to stage alert
search_mode (

ctl-l or ctl-space to open, ctl-c or ctl-space to close ) :

  • begin typing to have symbol search automatically lookup symbols from all loaded backend (broker) providers
  • arrow keys and mouse click to navigate selection
  • vi-like ctl-[hjkl] for navigation

you can also configure your position allocation limits from the sidepane.

run in distributed mode

start the service manager and data feed daemon in the background and connect to it:

pikerd -l info --pdb

connect your chart:

piker -l info -b kraken -b binance chart xmrusdt.binance --pdb

enjoy persistent real-time data feeds tied to daemon lifetime. the next time you spawn a chart it will load much faster since the data feed has been cached and is now always running live in the background until you kill pikerd.

if anyone asks you what this project is about

you don't talk about it.

how do i get involved?

enter the matrix.

how come there ain't that many docs

suck it up, learn the code; no one is trying to sell you on anything. also, we need lotsa help so if you want to start somewhere and can't necessarily write serious code, this might be the place for you!