Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ib py311 fixes #535

Draft
wants to merge 39 commits into
base: account_tests
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
482ad1c
Add `prompt-toolkit` for full `xonsh` feats
goodboy Aug 14, 2023
6b90e2e
Factor and gen per-dep overrides via "fancy" `.extend()`
goodboy Aug 15, 2023
84dd0ae
Bump `msgspect`, `polars` versions and add CLI script eps
goodboy Aug 16, 2023
847cb77
Drop `marketstore` mod import from CLIs loader
goodboy Aug 16, 2023
6b22024
MVP get us working fully on nixos
goodboy Aug 16, 2023
ea9a5e5
Factor prefer wheels deps into new `ahot_overrides`
goodboy Aug 17, 2023
94540ce
Pin tomlkit as a path dep for now
goodboy Aug 25, 2023
0068119
ib: use `asyncio.wait_for()` on ticker first quote; on 3.11 input cor…
goodboy Aug 16, 2023
c3f8b08
Drop `.service._ahab` from storage cli runtime mods
goodboy Aug 18, 2023
9005335
ib: pack empty `dict` on no flow entry
goodboy Aug 18, 2023
fed8956
Import crash handler mngr from `piker.toolz`
goodboy Aug 18, 2023
a695208
brokers._daemon: drop question-comment about enabling feed module
goodboy Aug 18, 2023
9d31941
order_mode: embedded `Order` maybe be in dict form..
goodboy Aug 18, 2023
995d153
Drop hard redraws for now
goodboy Aug 18, 2023
2e6b133
Add `.ui` and `.dev` deps groups via `poetry` Bo
goodboy Aug 18, 2023
2b8cd03
By default silence `Client.get_quote()` timeout errors unless caller …
goodboy Aug 18, 2023
e9517cd
ib: handle commodity-contract trade records
goodboy Aug 18, 2023
546049b
data.history: handle venue-closure gap edge case
goodboy Aug 20, 2023
1002ce1
kraken.broker: one last fix to `Position.cumsize`..
goodboy Aug 24, 2023
4617644
ib.api: always key `._contracts` with '.ib' suffix
goodboy Aug 25, 2023
8369f55
TOSQUASH 2e6b1330f375c310ad: adding .dev / .ui groups
goodboy Aug 25, 2023
ad37cfb
Break backfill loop on `end_dt < start_dt`
goodboy Aug 29, 2023
e54c3dc
TOSQUASH 9005335e18: pack empty dict on no flow
goodboy Aug 29, 2023
778d260
ib.api: return None on manual quote timeout
goodboy Aug 30, 2023
481618c
kraken: handle ws live trading API symbology
goodboy Aug 30, 2023
4d274b1
Attempt to generate .uis deps free lock file
goodboy Sep 7, 2023
4a18001
Swap out `fuzzywuzzy` for the newer `rapidfuzz` lib
goodboy Sep 13, 2023
2c88ebe
binance: implement `Client.search_symbols()` using `rapidfuzz`
goodboy Sep 13, 2023
30d55fd
Add `--pdb` support to `piker search`
goodboy Sep 13, 2023
05959ea
Always ensure symcache mkt pair entry is valid type
goodboy Sep 19, 2023
14f1241
ib: fix mktpair fallback table: use `Client._con2mkts` to translate..
goodboy Sep 21, 2023
d4833eb
binance: switch to `rapidfuzz` API
goodboy Sep 21, 2023
46d83e9
deribit: switch to `rapidfuzz` API
goodboy Sep 21, 2023
a97a0ce
kraken: switch to `rapidfuzz` API
goodboy Sep 21, 2023
0ba75df
Add `data.match_from_pairs` fuzzy symbology scanner
goodboy Sep 22, 2023
e9887cb
binance: parse .expiry separate from .venue
goodboy Sep 22, 2023
1a859bc
kraken: drop now unused `rapidfuzz` import
goodboy Sep 22, 2023
c312f90
kucoin: port to using `rapidfuzz`
goodboy Sep 22, 2023
ad59a58
symcache: passthrough `rapidfuzz.process.extract` kwargs
goodboy Sep 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 138 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

173 changes: 133 additions & 40 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@
# - convert the repo to use poetry using `poetry init`:
# https://python-poetry.org/docs/basic-usage/#initialising-a-pre-existing-project
# - then manually ensuring all deps are converted over:
# - add this file to the repo and commit it
# -
{
description = "piker: trading gear for hackers (pkged with poetry2nix)";

inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

# see https://github.com/nix-community/poetry2nix/tree/master#api
inputs.poetry2nix = {
url = "github:nix-community/poetry2nix";
# url = "github:nix-community/poetry2nix";
# url = "github:K900/poetry2nix/qt5-explicit-deps";
url = "/home/lord_fomo/repos/poetry2nix";

inputs.nixpkgs.follows = "nixpkgs";
};

Expand All @@ -20,6 +27,7 @@
flake-utils,
poetry2nix,
}:
# TODO: build cross-OS and use the `${system}` var thingy..
flake-utils.lib.eachDefaultSystem (system:
let
# use PWD as sources
Expand All @@ -30,56 +38,141 @@
# TODO: port to 3.11 and support both versions?
python = "python3.10";

# see https://github.com/nix-community/poetry2nix/tree/master#api
# for more functions and examples.
# inherit
# (poetry2nix.legacyPackages.${system})
# mkPoetryApplication;
# pkgs = nixpkgs.legacyPackages.${system};

pkgs = nixpkgs.legacyPackages.x86_64-linux;
lib = pkgs.lib;
p2npkgs = poetry2nix.legacyPackages.x86_64-linux;

# define all pkg overrides per dep, see edgecases.md:
# https://github.com/nix-community/poetry2nix/blob/master/docs/edgecases.md
# TODO: add these into the json file:
# https://github.com/nix-community/poetry2nix/blob/master/overrides/build-systems.json
pypkgs-build-requirements = {
asyncvnc = [ "setuptools" ];
eventkit = [ "setuptools" ];
ib-insync = [ "setuptools" "flake8" ];
msgspec = [ "setuptools"];
pdbp = [ "setuptools" ];
pyqt6-sip = [ "setuptools" ];
tabcompleter = [ "setuptools" ];
tractor = [ "setuptools" ];
tricycle = [ "setuptools" ];
trio-typing = [ "setuptools" ];
trio-util = [ "setuptools" ];
xonsh = [ "setuptools" ];
};

# auto-generate override entries
p2n-overrides = p2npkgs.defaultPoetryOverrides.extend (self: super:
builtins.mapAttrs (package: build-requirements:
(builtins.getAttr package super).overridePythonAttrs (old: {
buildInputs = (
old.buildInputs or [ ]
) ++ (
builtins.map (
pkg: if builtins.isString pkg then builtins.getAttr pkg super else pkg
) build-requirements
);
})
) pypkgs-build-requirements
);

# override some ahead-of-time compiled extensions
# to be built with their wheels.
ahot_overrides = p2n-overrides.extend(
final: prev: {

# llvmlite = prev.llvmlite.override {
# preferWheel = false;
# };

# TODO: get this workin with p2n and nixpkgs..
# pyqt6 = prev.pyqt6.override {
# preferWheel = true;
# };

# NOTE: this DOESN'T work atm but after a fix
# to poetry2nix, it will and actually this line
# won't be needed - thanks @k900:
# https://github.com/nix-community/poetry2nix/pull/1257
pyqt5 = prev.pyqt5.override {
withWebkit = false;
preferWheel = true;
};

in
{
# let
# devEnv = poetry2nix.mkPoetryEnv {
# projectDir = ./.;
# };
# see PR from @k900:
# https://github.com/nix-community/poetry2nix/pull/1257
# pyqt5-qt5 = prev.pyqt5-qt5.override {
# withWebkit = false;
# preferWheel = true;
# };

# TODO: patch in an override for polars to build
# from src! See the details likely needed from
# the cryptography entry:
# https://github.com/nix-community/poetry2nix/blob/master/overrides/default.nix#L426-L435
polars = prev.polars.override {
preferWheel = true;
};
}
);

# WHY!? -> output-attrs that `nix develop` scans for:
# https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-develop.html#flake-output-attributes
in {
packages = {
piker = poetry2nix.mkPoetryEditablePackage {
# env = poetry2nix.mkPoetryEnv {

# NOTE: taken from surrounding inputs
# projectDir = projectDir;
editablePackageSources = { piker = ./piker; };

# override msgspec to include setuptools as input
# https://github.com/nix-community/poetry2nix/blob/master/docs/edgecases.md#modulenotfounderror-no-module-named-packagenamed
overrides = poetry2nix.defaultPoetryOverrides.extend
(self: super: {
msgspec = super.msgspec.overridePythonAttrs
(
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ];
}
);
}
);
# piker = poetry2nix.legacyPackages.x86_64-linux.mkPoetryEditablePackage {
# editablePackageSources = { piker = ./piker; };

piker = p2npkgs.mkPoetryApplication {
projectDir = projectDir;

# SEE ABOVE for auto-genned input set, override
# buncha deps with extras.. like `setuptools` mostly.
# TODO: maybe propose a patch to p2n to show that you
# can even do this in the edgecases docs?
overrides = ahot_overrides;

# XXX: won't work on llvmlite..
# preferWheels = true;
};
};
};

devShells.default = pkgs.mkShell {
# packages = [ poetry2nix.packages.${system}.poetry ];
packages = [ poetry2nix.packages.x86_64-linux.poetry ];
inputsFrom = [ self.packages.x86_64-linux.piker ];

# boot xonsh inside the poetry virtualenv when
# define the custom entry point via an expected
# output-attr that `nix-develop` scans for:
# https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-develop.html#flake-output-attributes
devShells.default = pkgs.mkShell {
# packages = [ poetry2nix.packages.${system}.poetry ];
packages = [ poetry2nix.packages.x86_64-linux.poetry ];
shellHook = "poetry run xonsh";
# shellHook = "poetry shell";
};
}
);
# TODO: boot xonsh inside the poetry virtualenv when
# defined via a custom entry point?
# NOTE XXX: apparently DON'T do these..?
# shellHook = "poetry run xonsh";
# shellHook = "poetry shell";
};


# TODO: grok the difference here..
# - avoid re-cloning git repos on every develop entry..
# - ideally allow hacking on the src code of some deps
# (tractor, pyqtgraph, tomlkit, etc.) WITHOUT having to
# re-install them every time a change is made.

# devShells.default = (p2npkgs.mkPoetryEnv {
# # let {
# # devEnv = p2npkgs.mkPoetryEnv {
# projectDir = projectDir;
# overrides = ahot_overrides;
# inputsFrom = [ self.packages.x86_64-linux.piker ];
# }).env.overrideAttrs (old: {
# buildInputs = [ packages.piker ];
# }
# );

}
); # end of .outputs scope
}
5 changes: 5 additions & 0 deletions piker/accounting/_pos.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,11 @@ def update_from_ledger(

if not (pos := pps.get(bs_mktid)):

assert isinstance(
mkt,
MktPair,
)

# if no existing pos, allocate fresh one.
pos = pps[bs_mktid] = Position(
mkt=mkt,
Expand Down
2 changes: 1 addition & 1 deletion piker/accounting/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def open_ledger_dfs(
can update the ledger on exit.

'''
from tractor._debug import open_crash_handler
from piker.toolz import open_crash_handler
with open_crash_handler():
if not ledger:
import time
Expand Down
3 changes: 0 additions & 3 deletions piker/brokers/_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,6 @@ def broker_init(
subpath: str = f'{modpath}.{submodname}'
enabled.append(subpath)

# TODO XXX: DO WE NEED THIS?
# enabled.append('piker.data.feed')

return (
brokermod,
start_actor_kwargs, # to `ActorNursery.start_actor()`
Expand Down
Loading