Commit Graph

3163 Commits (0612fff3c1f69fa698b172de6ee446c0f703a407)

Author SHA1 Message Date
Tyler Goodlet f81d47efc4 Detail some comments 2021-09-11 13:10:20 -04:00
Tyler Goodlet 6fa8958acf Drop extra method 2021-09-11 10:56:03 -04:00
Tyler Goodlet 7e366d18cb Handle paper account loading
The paper engine returns `"paper"` instead of `None` in the pp msgs so
expect that. Don't bother with fills tracking for now (since we'll need
either the account in the msg or a lookup table locally for oids to
accounts). Change the order line update handler to a local module function,
there was no reason for it to be a pane method.
2021-09-11 10:42:32 -04:00
Tyler Goodlet 8886f11c62 Don't allow selecting accounts that haven't been loaded 2021-09-11 10:41:52 -04:00
Tyler Goodlet c00cf12f94 Deliver ems cached pps are dict of lists 2021-09-10 18:54:34 -04:00
Tyler Goodlet 054ddf6732 Send error on non-paper account requests to paperboi 2021-09-10 18:54:04 -04:00
Tyler Goodlet b6b3ca15c5 Activate pnl updates from order mode method on account switches 2021-09-10 14:59:42 -04:00
Tyler Goodlet 149bee1058 Create net-zero pps from startup vs. accounts diff 2021-09-10 14:01:29 -04:00
Tyler Goodlet f16591612e Support real-time account switch and status update
Make a pp tracker per account and load on order mode boot.
Only show details on the pp tracker for the selected account.
Make the settings pane assign a `.current_pp` state on the order mode
instance (for the charted symbol) on account selection switches and no
longer keep a ref to a single pp tracker and allocator in the pane.

`SettingsPane.update_status_ui()` now expects an explicit tracker
reference as input. Still need to figure out the pnl update task logic
despite the intermittent account changes.
2021-09-10 11:50:24 -04:00
Tyler Goodlet d25aec53e3 Append pp values per account during startup on ib 2021-09-10 11:36:46 -04:00
Tyler Goodlet 71afce69d0 Append paper account last when loading 2021-09-10 11:35:30 -04:00
Tyler Goodlet f9e5769b01 Lintn: add missing space 2021-09-10 11:35:00 -04:00
Tyler Goodlet 46d3bf0484 Drop commented assert about `form.model` 2021-09-10 11:34:29 -04:00
Tyler Goodlet 4e1bac0071 Update label on `.show()` 2021-09-10 11:33:58 -04:00
Tyler Goodlet e1efb0943b Track per-account pps in ems memory 2021-09-10 11:33:08 -04:00
Tyler Goodlet 87bca9aae1 Tweak accounts schema to be per-provider 2021-09-09 10:46:39 -04:00
Tyler Goodlet c9eb0b5afb Show account name on pp line 2021-09-09 10:34:48 -04:00
Tyler Goodlet 5e947e7887 Maybe show account names on order lines 2021-09-09 10:34:14 -04:00
Tyler Goodlet 15aba154f2 Return account name in next order info 2021-09-09 10:33:52 -04:00
Tyler Goodlet c53b8ec43c Make `ib` backend multi-client capable
This adds full support for a single `brokerd` managing multiple API
endpoint clients in tandem. Get the client scan loop correct and load
accounts from all discovered clients as specified in a user's
`broker.toml`. We now just always re-scan for all clients and if there's
a cache hit just skip a creation/connection logic.

Route orders with an account name to the correct client in the
`handle_order_requests()` endpoint and spawn an event relay task per
client for transmitting trade events back to `emsd`.
2021-09-09 08:07:11 -04:00
Tyler Goodlet dedfb27a3a Add per-account order entry for ib
Make the `handle_order_requests()` tasks now lookup the appropriate API
client for a given account (or error if it can't be found) and use it
for submission. Account names are loaded from the
`brokers.toml::accounts.ib` section both UI side and in the `brokerd`.
Change `_aio_get_client()` to a `load_aio_client()` which now tries to
scan and load api clients for all connections defined in the config as
well as deliver the client cache and account lookup tables.
2021-09-08 15:55:45 -04:00
Tyler Goodlet b01538f183 Support an account field in clearing system
Each backend broker may support multiple (types) of accounts; this patch
lets clients send order requests that pass through an `account` field in
certain `emsd` <-> `brokerd` transactions. This allows each provider to read
in and conduct logic based on what account value is passed via requests
to the `trades_dialogue()` endpoint as well as tie together positioning
updates with relevant account keys for display in UIs.

This also adds relay support for a `Status` msg with a `'broker_errored'`
status which for now will trigger the same logic as cancelled orders on
the client side and thus will remove order lines submitted on a chart.
2021-09-08 15:46:33 -04:00
Tyler Goodlet 504040eb59 Add an `account` field to EMS msging schemas 2021-09-08 14:03:18 -04:00
Tyler Goodlet 0d2cddec9a Return accounts in `bidict` 2021-09-08 14:01:54 -04:00
Tyler Goodlet 063788499a Use a pnl task per symbol 2021-09-07 12:54:32 -04:00
Tyler Goodlet b5c1120ad0 Set account in ui handler 2021-09-07 12:54:10 -04:00
Tyler Goodlet 5d25a0d370 Better pp loading at startup
- directly lookup the position data for the current symbol
- let `mk_alloc()` create the allocator
- load and set account name for pp in sidepane
2021-09-07 09:23:18 -04:00
Tyler Goodlet 2bc07ae05b Try explicit matches of symbol to our adhoc set for pp msgs 2021-09-07 09:22:56 -04:00
Tyler Goodlet 7b86b6ae20 Add account settings change support 2021-09-07 09:22:24 -04:00
Tyler Goodlet 09d34f7355 Make `accounts` field public, add an account name method 2021-09-07 09:21:55 -04:00
Tyler Goodlet d38a6bf032 Create alloc instance in factory body, template out defaults loading 2021-09-07 08:38:24 -04:00
Tyler Goodlet 214c622328 Move allocator components to clearing sub-pkg 2021-09-06 22:05:42 -04:00
Tyler Goodlet 343cb4b0ae Port order mode setup to new pp apis; reduces implicit update logic 2021-09-06 21:36:30 -04:00
Tyler Goodlet 5333d25bf6 Better separation of UI vs. allocator settings
Get rid of `PositionTracker.init_status_ui()` and instead make
a helper func `mk_allocator()` which takes in the alloc and adjusts
default settings on the allocator alone (which is expected to be
passed in). Expect a `Position` instance to be passed into the tracker
which will be looked up for UI updates. Move *update-from-position-msg*
ops into a `Position.update_from_msg()` method.
2021-09-06 21:35:11 -04:00
Tyler Goodlet 15025d6047 Move config module to top level 2021-09-06 21:26:28 -04:00
goodboy 73b555a677
Merge pull request #205 from pikers/ordermode_pps
Ordermode pps for gamified chart trading .
2021-09-06 16:35:26 -04:00
Tyler Goodlet 202b857620 Add micro-manual for order mode to readme 2021-09-06 14:09:39 -04:00
Tyler Goodlet 85fd0a7a30 Avoid "n" as name since it conflicts with pdb 2021-09-06 13:46:07 -04:00
Tyler Goodlet b9ee0997a7 Only do tracker update if pp msg is received for sym 2021-09-06 12:42:25 -04:00
Tyler Goodlet 3713831070 Fix fsp pane width to exactly the same as OHLC chart 2021-09-06 09:28:11 -04:00
Tyler Goodlet 37719efe37 Scale status bar labels to actual bar height 2021-09-06 09:28:11 -04:00
Tyler Goodlet 28047c523d Drop cruft from before pane-per-chart was added 2021-09-06 09:28:11 -04:00
Tyler Goodlet c26161ed7e Make config acounts loading more explicit. 2021-09-06 09:28:11 -04:00
Tyler Goodlet c86c4218ce Allow blank accounts config 2021-09-06 09:28:11 -04:00
Tyler Goodlet c5191d66cb Use new method name in order mode 2021-09-06 09:28:11 -04:00
Tyler Goodlet 27f10293bd Fix pp line label update logic
We weren't updating the LHS size labels on creation and we now use the
lot size digits to do so. Change `PositionTracker.update()` to
`.update_from_pp_msg()`.
2021-09-06 09:28:11 -04:00
Tyler Goodlet 171832cfb8 Tweak account label 2021-09-06 09:28:11 -04:00
Tyler Goodlet 35fe26cb95 Assign unique shm keys for duplicate fsps to avoid array clobbering 2021-09-06 09:28:11 -04:00
Tyler Goodlet 709288d034 Sway fixes that avoid weird window resizing 2021-09-06 09:28:11 -04:00
Tyler Goodlet e95589e5b0 Ignore ohlc step stream subs lookup errors 2021-09-06 09:28:11 -04:00