Commit Graph

569 Commits (176b230a463c4b1eecee166a0d83741a7c31029e)

Author SHA1 Message Date
Tyler Goodlet fb5df5ab5e Drop `pandas` usage throughout brokers cli 2022-05-15 13:49:50 -04:00
Tyler Goodlet de55565f60 We already collect account values/names in `load_io_clients()` 2022-05-12 14:21:31 -04:00
Tyler Goodlet d0530c4e26 Deliver accounts from query instead of just pps with `ib` 2022-05-12 13:22:51 -04:00
Tyler Goodlet fb91e27651 Well that was easy, convert tick/lot step sizes to `float` 2022-05-11 10:41:03 -04:00
Tyler Goodlet 4b6ecbfc79 Bring binance requests down to 3/sec; seems faster? 2022-05-10 14:55:52 -04:00
Tyler Goodlet b44786e5b7 Support async-batched ohlc queries in all backends
Expect each backend to deliver a `config: dict[str, Any]` which provides
concurrency controls to `trimeter`'s batch task scheduler such that
backends can define their own concurrency limits.

The dirty deats in this patch include handling history "gaps" where
a query returns a history-frame-result which spans more then the typical
frame size (in seconds). In such cases we reset the target frame index
(datetime index sequence implemented with a `pendulum.Period`) using
a generator protocol `.send()` such that the sequence can be dynamically
re-indexed starting at the new (possibly) pre-gap datetime. The new gap
logic also allows us to detect out of order frames easier and thus wait
for the next-in-order to arrive before making more requests.
2022-05-09 11:15:14 -04:00
Tyler Goodlet 49509d55d2 Implement `open_history_client()` correctly for `kraken` 2022-05-09 11:15:14 -04:00
Tyler Goodlet 6ba3c15c4e Add to signal broker won't deliver more data 2022-05-09 11:15:14 -04:00
Tyler Goodlet a3db5d1bdc Relay frame size in `NoData` due to null-result history 2022-05-09 11:15:14 -04:00
Tyler Goodlet c672493998 Add , indicates hist size to decrement to storage logic 2022-05-09 11:15:14 -04:00
Tyler Goodlet ab8629aa11 Make ib history client expect datetimes for input 2022-05-09 11:15:13 -04:00
Tyler Goodlet 2a07005c97 Add binance history client support with datetime use throughout 2022-05-09 11:15:13 -04:00
goodboy 67cec4bc54
Merge pull request #304 from pikers/offline_history_loading
Offline history loading
2022-04-16 15:57:14 -04:00
Konstantine Tsafatinos 773ed5e7ad update to merge syntax in submit_limit, fix non_master push mistake 2022-04-16 15:01:31 -04:00
Konstantine Tsafatinos 59434b9a8a refactor submit
_limit and expore the 'paper' like feature
2022-04-16 14:54:25 -04:00
Konstantine Tsafatinos 250d9cbc03 fix kraken bug, allow for live order edits 2022-04-16 14:38:03 -04:00
Tyler Goodlet bcb4fe8c50 Indefinitely wait on feed hack for windows? 2022-04-16 13:25:14 -04:00
Tyler Goodlet 72ec34ffd2 Port to `pendulum` equivalent apis throughout 2022-04-16 13:23:42 -04:00
Tyler Goodlet d334e61b1f Drop 22s timeout on reset hack 2022-04-16 13:23:38 -04:00
Tyler Goodlet 4d23f6e4d7 Drop need for `ib_insync.IB.qualifyContractsAsync()' mod
As per https://github.com/erdewit/ib_insync/pull/454 the more correct
way to do this is with `.reqContractDetailsAsync()` which we wrap with
`Client.con_deats()` and which works just as well. Further drop all the
`dict`-ifying that was being done in that method and instead always
return `ContractDetails` object in an fqsn-like explicitly keyed `dict`.
2022-04-13 00:39:15 -04:00
Tyler Goodlet 8b1c521ae9 Ignore symbol-not-found errors 2022-04-13 00:39:15 -04:00
Tyler Goodlet 7586e20ab4 Use new unpacker helper name 2022-04-13 00:39:15 -04:00
Tyler Goodlet 80d70216f7 Drop back down ohlc bars request count to not trigger feed hack 2022-04-13 00:39:15 -04:00
Tyler Goodlet 66ea74c6d5 Put back more bars iters in loop to handle no-data in range cases 2022-04-13 00:39:15 -04:00
Tyler Goodlet b579d4b1f5 Get ib data feed hackzorz workin
ib has a throttle limit for "hft" bars but contained in here is some
hackery using ``xdotool`` to reset data farms auto-magically B)

This copies the working script into the ib backend mod as a routine and
now uses `trio.run_process()` and calls into it from the `get_bars()`
history retriever and then waits for "data re-established" events to be
received from the client before making more history queries.

TL;DR summary of changes:
- relay ib's "system status" events (like for data farm statuses)
  as a new "event" msg that can be processed by registers of
  `Client.inline_errors()` (though we should probably make a new
  method for this).
- add `MethodProxy.status_event()` which allows a proxy user to register
  for a particular "system event" (as mentioned above), which puts
  a `trio.Event` entry in a small table can be set by an relay task if
  there are any detected waiters.
- start a "msg relay task" when opening the method proxy which does
  the event setting mentioned above in the background.
- drop the request error handling around the proxy creation, doesn't
  seem necessary any more now that we have better error propagation from
  `asyncio`.
- add event waiting logic around the data feed reset hackzorin.
- change the order relay task to only log system events for now (though
  we need to do some better parsing/logic to get tws-external order
  updates to work again..
2022-04-13 00:39:15 -04:00
Tyler Goodlet 874374af06 Drop `pandas` use in ib backend for history
Found an issue (that was predictably brushed aside XD) where the
`ib_insync.util.df()` helper was changing the timestamps on bars data to
be way off (probably a `pandas.Timestamp` timezone thing?).

Anyway, dropped all that (which will hopefully let us drop `pandas` as
a hard dep) and added a buncha timestamp checking as well as start/end
datetime return values using `pendulum` so that consumer code can know
which "slice" is output.

Also added some WIP code to work around "no history found" request
errors where instead now we try to increment backward another 200
seconds - not sure if this actually correct yet.
2022-04-13 00:39:15 -04:00
Tyler Goodlet 62d073dc18 More IB repairs..
Make the throttle error propagate through to `trio` again by adding
`dict`-msg support between the two loops such that errors can be
re-raised on the `trio` side. This is all integrated into the
`MethoProxy` and accompanying result relay task.

Further fix a longer standing issue where sometimes the `ib_insync`
order entry method will raise a weird assertion error because it detects
some internal order-id state issue.. Just ignore those and make relay
back an error to the ems in such cases.

Add a bunch of notes for todos surrounding data feed reset hackery.
2022-04-13 00:39:15 -04:00
Tyler Goodlet 3e125625b1 Attempt to better handle history throttles using flag 2022-04-13 00:39:15 -04:00
Tyler Goodlet 8395a1fcfe IB: Comment on lowercase for the fqsn key 2022-04-13 00:39:15 -04:00
Tyler Goodlet 957686a9fe Comment exception debug in ib request error block 2022-04-13 00:39:15 -04:00
Tyler Goodlet 1e433ca4f4 Support "expiry" suffixes for derivatives with ib
To start we only have futes working but this allows both searching
and loading multiple expiries of the same instrument by specifying
different expiries with a `.<expiry>` suffix in the symbol key (eg.
`mnq.globex.20220617`). This also paves the way for options contracts
which will need something similar plus a strike property. This change
set also required a patch to `ib_insync` to allow retrieving multiple
"ambiguous" contracts from the `IB.reqContractDetailsAcync()` method,
see https://github.com/erdewit/ib_insync/pull/454 for further discussion
since the approach here might change.

This patch also includes a lot of serious reworking of some `trio`-`asyncio`
integration to use the newer `tractor.to_asyncio.open_channel_from()`
api and use it (with a relay task) to open a persistent connection with
an in-actor `ib_insync` `Client` mostly for history requests.

Deats,
- annot the module with a `_infect_asyncio: bool` for `tractor` spawning
- add a futes venu list
- support ambiguous futes contracts lookups so that all expiries will
  show in search
- support both continuous and specific expiry fute contract
  qualification
- allow searching with "fqsn" keys
- don't crash on "data not found" errors in history requests
- move all quotes msg "topic-key" generation (which should now be
  a broker-specific fqsn) and per-contract quote processing into
  `normalize()`
- set the fqsn key in the symbol info init msg
- use `open_client_proxy()` in bars backfiller endpoint
- include expiry suffix in position update keys
2022-04-13 00:39:15 -04:00
Tyler Goodlet 937406534c Maybe spawn `brokerd` in `asyncio` mode if declared in backend mod 2022-04-13 00:39:15 -04:00
Tyler Goodlet b26b66cc66 Add context-styled `asyncio` client proxy for ib
This adds a new client manager-factory: `open_client_proxy()` which uses
the newer `tractor.to_asyncio.open_channel_from()` (and thus the
inter-loop-task-channel style) a `aio_client_method_relay()` and
a re-implemented `MethodProxy` wrapper to allow transparently calling
`asyncio` client methods from `trio` tasks. Use this proxy in the
history backfiller task and add a new (prototype)
`open_history_client()` which will be used in the new storage management
layer. Drop `get_client()` which was the portal wrapping equivalent of
the same proxy but with a one-task-per-call approach. Oh, and
`Client.bars()` can take `datetime`, so let's use it B)
2022-04-13 00:39:15 -04:00
Tyler Goodlet 7936dcafbf Make linux timeout the same 2022-04-13 00:39:15 -04:00
Tyler Goodlet d32c26c5d7 Add flag to avoid logging json to console 2022-04-13 00:39:15 -04:00
Tyler Goodlet d2d3286fb8 Use `asyncio` in `Client.get_quote()` 2022-04-13 00:39:15 -04:00
Tyler Goodlet f604437897 Remove symbol key from first quote from ib feed 2022-04-10 17:33:02 -04:00
Tyler Goodlet 998a5acd92 Crypto$ backend updates
- move to 3.9+ type annots
- add initial draft `open_history_client()` endpoints
- deliver `'fqsn'` keys in quote-stream init msgs
2022-04-10 17:33:00 -04:00
Tyler Goodlet 58517295d2 Disable kraken orders due to #299 2022-04-10 17:27:15 -04:00
Tyler Goodlet c39fa825d0 More explicit order-cancel errors handling 2022-04-10 17:07:08 -04:00
Tyler Goodlet 88306a6c1e Drop invalid status msg, linting cleanups 2022-04-09 16:56:05 -04:00
Konstantine Tsafatinos cb970cef46 dark order gui patch, add filled status message 2022-04-08 19:25:24 -04:00
Konstantine Tsafatinos c2e654aae2 change logic order for handling no config case 2022-04-07 13:03:53 -04:00
Konstantine Tsafatinos 2baa1b4605 fix hang when kraken is not in config 2022-03-28 18:28:19 -04:00
Konstantine Tsafatinos cb8e97a142 address latest comments, refactor the pack position function 2022-03-23 10:34:53 -04:00
Konstantine Tsafatinos 1525c645ce refactor get_positions into get_trades, and refactor pack_position with postion calc logic 2022-03-20 13:52:45 -04:00
Konstantine Tsafatinos fd0acd21fb refactory based on github comments, change doc string style 2022-03-06 15:17:26 -05:00
Konstantine Tsafatinos 617bf3e0da fix typo and get rid of pprint of ws stream 2022-03-06 15:17:26 -05:00
Konstantine Tsafatinos a3345dbba2 cleaned up code and added loop to grab all trades for position calcs 2022-03-06 15:17:26 -05:00
Konstantine Tsafatinos ee0be13af1 repurpose ws code for ownTrades stream, get trade authentication going 2022-03-06 15:17:26 -05:00
Konstantine Tsafatinos b1bff1be85 remove ws support for orders, use rest api instead for easy oid association 2022-03-06 15:17:26 -05:00
Konstantine Tsafatinos 46948e0a8b add order cancel support over websockets 2022-03-06 15:17:26 -05:00
Konstantine Tsafatinos d826a66c8c use a mapping from userref to oid for order ack 2022-03-06 15:17:26 -05:00
Konstantine Tsafatinos 6c54c81f01 get stashed changes 2022-03-06 15:17:26 -05:00
Tyler Goodlet 0122669dd4 Factor out ws msg hearbeat and error handling
Move the core ws message handling into `stream_messages()` and call that
from 2 new stream processors: `process_data_feed_msgs()` and
`process_order_msgs()`. Add comments for hints on how to implement the
order msg parsing as well as `pprint` received msgs to console for now.
2022-03-06 15:17:26 -05:00
Konstantine Tsafatinos 0c905920e2 connect to krakens openOrders websocket 2022-03-06 15:17:26 -05:00
Konstantine Tsafatinos 03d2eddce3 order submission and cancellation working 2022-03-06 15:17:26 -05:00
Konstantine Tsafatinos 96dd5c632f basic order submission and cancelling with kraken 2022-03-06 15:17:26 -05:00
Konstantine Tsafatinos b21bbf5031 valdiate and ack order requests from ems 2022-03-06 15:17:26 -05:00
Konstantine Tsafatinos 66da58525d mock orders validated from kraken 2022-03-06 15:17:26 -05:00
Konstantine Tsafatinos b55debbe95 get basic order request loop receiving msgs 2022-03-06 15:17:26 -05:00
Konstantine Tsafatinos 1fe1f88806 added the bones for the handle_order_requests func 2022-03-06 15:17:26 -05:00
Konstantine Tsafatinos 3d2be3674e save progress on kraken to test out unit_select_fixes 2022-03-06 15:17:26 -05:00
Konstantine Tsafatinos 48c7b5262c get positions working for kraken 2022-03-06 15:17:26 -05:00
Konstantine Tsafatinos ef598444c4 get positions from trades 2022-03-06 15:17:26 -05:00
Konstantine Tsafatinos 0285a847d8 Store changes for rebase, positions prototype 2022-03-06 15:17:26 -05:00
Konstantine Tsafatinos 88061d8799 Add balance to the ledger 2022-03-06 15:17:26 -05:00
Konstantine Tsafatinos e12af8aa4c Add get_ledger function; parses raw ledger from kraken api 2022-03-06 15:17:26 -05:00
Konstantine Tsafatinos 184edb2a90 wrap api method calls with uri and nonce value 2022-03-06 15:17:26 -05:00
Konstantine Tsafatinos b88dd380a3 get kraken authentication and retrieve balances 2022-03-06 15:17:26 -05:00
Tyler Goodlet 01f5f2d015 Don't require a rt quote, increase client connect timeout 2022-03-03 17:49:21 -05:00
Tyler Goodlet 832e4c97d2 Drop shm: ShmArray` to `stream_quotes()` endpoint 2022-02-28 08:23:16 -05:00
Tyler Goodlet ca1c1cf415 Annoying doc strings 2022-02-11 10:30:30 -05:00
wattygetlood cc87508fd9 Only load 4 ib requests worth of bars on windows... 2022-02-10 10:26:52 -05:00
Tyler Goodlet e3c46a5d4d Add draft, commented tickbytick for ib 2022-02-07 12:53:30 -05:00
Tyler Goodlet 26b0071471 Subscribe for rate calcs from IB in default tick set 2022-02-07 12:53:30 -05:00
Tyler Goodlet 9bfad86c29 Drop timeout-cancel block 2022-02-07 09:49:45 -05:00
Tyler Goodlet a9d42b374f ib: Allow history backfilling even when markets are closed 2022-02-07 09:49:45 -05:00
Tyler Goodlet bb8fade16f Update `msgpub` import from `tractor.experimental` 2022-01-30 12:46:54 -05:00
Tyler Goodlet 95b31cbc0f Drop references to deprecated `tractor.msg.pub` 2022-01-29 12:44:45 -05:00
Tyler Goodlet 55cfe6082b Re-key ib's 'unreportable trades' (tick 48) as 2022-01-26 13:48:21 -05:00
Tyler Goodlet d27214621d Update some typing and add latency checks for binance 2022-01-25 07:57:01 -05:00
Tyler Goodlet 746db60e5b Increases IB api connect timeout to 1s 2022-01-23 18:18:10 -05:00
Tyler Goodlet fc3baf4bd1 Bump timeout up 2022-01-23 18:18:10 -05:00
Tyler Goodlet f1d61ac01b WIP ib: toying with showing history before first quote 2022-01-23 18:18:10 -05:00
Tyler Goodlet d69d3b319e Lengthen startup quote get timeout 2022-01-23 18:18:10 -05:00
Tyler Goodlet 0e4a7e3846 Only warn on slow quote query 2022-01-23 18:18:10 -05:00
Tyler Goodlet 24596022f9 Wait for a last price tick before delivering quote 2021-10-29 09:31:06 -04:00
Tyler Goodlet af0503956a Use `tractor.to_asyncio.open_channel_from()` in ib backend 2021-10-29 09:26:42 -04:00
Tyler Goodlet 1416d4e6ac Add actor wide client ignore set, increase history retreival to 24 requests 2021-10-29 09:25:41 -04:00
Tyler Goodlet eca9b14cd6 Add (list of) `hosts` support in config and better scan error msg 2021-10-29 09:20:52 -04:00
Tyler Goodlet b04645aa47 Expect `accounts: set[str]` startup msg through clearing system 2021-09-14 10:36:13 -04:00
Tyler Goodlet eb70baf161 Pass account names on wire: brokerd => emsd 2021-09-13 08:24:45 -04:00
Tyler Goodlet 6acfd6c38a Ugh, positions relay hotfix
Must have run into some confusion with data structures in `brokerd` vs.
`emsd`. This fixes the ems `relay.positions` state tracking to be
composed maps, vs. messages from `brokerd` should just be a sequence.
2021-09-12 19:30:43 -04:00
Tyler Goodlet d25aec53e3 Append pp values per account during startup on ib 2021-09-10 11:36:46 -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 2bc07ae05b Try explicit matches of symbol to our adhoc set for pp msgs 2021-09-07 09:22:56 -04:00
Tyler Goodlet 15025d6047 Move config module to top level 2021-09-06 21:26:28 -04:00
Tyler Goodlet c86c4218ce Allow blank accounts config 2021-09-06 09:28:11 -04:00
Tyler Goodlet 34d4d098d2 Add silver futes 2021-09-06 09:28:11 -04:00
Tyler Goodlet 28b6882725 Slapp in exchange suffix position msg key; avoid symbol aliasing on `in` check 2021-09-06 09:28:11 -04:00
Tyler Goodlet 15fc66f0a9 Add config account loader 2021-09-06 09:28:10 -04:00
Tyler Goodlet 6be6f25797 Add "crypto" type to binance and kraken symbols 2021-09-06 09:28:10 -04:00
Tyler Goodlet 908678da84 Add more futes, add in order status comments 2021-09-05 13:59:40 -04:00
Tyler Goodlet d3838c2a8b Use built-in type generics 2021-09-02 12:55:10 -04:00
Tyler Goodlet eb5762d912 Add adhoc-symbols search for ib
This gives us fast search over a known set of symbols you can't search
for with the api such as futures and commodities contracts.

Toss in a new client method to lookup contract details
`Client.con_deats()` and avoid calling it for now from `.search_stock()`
for speed; it seems originally we were doing the 2nd lookup due to weird
suffixes in the `.primaryExchange` which we can just discard.
2021-09-02 10:55:37 -04:00
Tyler Goodlet 3dad779c90 Add commented catch to skip backpressure errors wen debugging 2021-09-01 10:26:49 -04:00
Tyler Goodlet d940957455 Support account passthrough in `.submit_limit()` 2021-09-01 10:26:49 -04:00
Tyler Goodlet ffbfd187ad Raise cache miss on a disconnected ib client 2021-09-01 10:26:49 -04:00
Tyler Goodlet c6aa867c9b Add more futes, add in order status comments 2021-09-01 10:26:49 -04:00
Tyler Goodlet fe0d66e847 Drop removed module import 2021-08-26 17:04:59 -04:00
Tyler Goodlet 310d8f485e Add disclaimer to old data mod 2021-08-26 17:04:59 -04:00
Tyler Goodlet 68ce5b3550 Add lifo cache to new module; drop "utils", bleh 2021-08-26 17:04:59 -04:00
Tyler Goodlet a0660e553f Start top level cacheing apis module 2021-08-26 17:04:59 -04:00
Tyler Goodlet 89b2089562 Fixup missing ib section handling; drop `.api` subsection 2021-08-24 10:27:25 -04:00
Tyler Goodlet d5394ac677 Fix TWS triggered trades msg packing 2021-08-24 10:26:41 -04:00
Tyler Goodlet a10d20c041 Add ib config section support 2021-07-27 07:09:01 -04:00
Tyler Goodlet 9c24bb6480 Make json resp log debug level 2021-07-07 07:07:01 -04:00
Tyler Goodlet 588b5c317c Drop unseralizable "sec tag" for now 2021-06-14 00:02:23 -04:00
Tyler Goodlet 95f466b93d Fix to msg attr access 2021-06-10 12:02:26 -04:00
goodboy 689bc0cde0
Merge pull request #190 from pikers/ems_to_bidir_streaming
Ems to bidir streaming
2021-06-10 08:45:44 -04:00
Tyler Goodlet a9cbacd8aa Move details assignements to static declaration 2021-06-10 08:24:51 -04:00
Tyler Goodlet 8e8a005128 Fix attr accesses on msg type 2021-06-09 12:22:02 -04:00
Konstantine Tsafatinos 90e5a10a66 modify error string to format: <name>.<provider> 2021-06-09 12:02:05 -04:00
Tyler Goodlet db92683ede Port ib orders to new msgs and bidir streaming api 2021-06-08 14:33:41 -04:00
Tyler Goodlet 02459cd964 Use new top level portal import 2021-06-08 14:31:14 -04:00
Konstantine Tsafatinos 099bf260f5 fix unknown kraken symbol raised error 2021-06-01 18:01:45 -04:00
Tyler Goodlet 9792b9aa7d Drop search pause config; use default 2021-05-28 14:11:02 -04:00
Tyler Goodlet 51a8308105 Lower connection timeout duration 2021-05-28 14:11:02 -04:00
Tyler Goodlet ff856a6ee3 Woops, make unsub pairs a list 2021-05-28 14:11:02 -04:00
Tyler Goodlet 19711bf024 Reconnect slow binance conns instead of error 2021-05-28 14:11:02 -04:00
Tyler Goodlet d0e3f5a51c Port binance and kraken to "reliable" ws API 2021-05-28 14:11:02 -04:00
Tyler Goodlet 7fa9f3f542 Add `Client.search_symbols()` to all backends, use it in `piker search` 2021-05-28 12:29:58 -04:00
Tyler Goodlet e88e5b8ce2 Decrease binance search debounce period 2021-05-27 13:05:23 -04:00
Tyler Goodlet 3e39e9620c Add a no data available error 2021-05-27 13:05:23 -04:00
Tyler Goodlet 44f4fdf043 Type annot the internal symbol cache 2021-05-27 13:05:23 -04:00
Tyler Goodlet 27d704b32e To avoid feed breakage, just give up on history after too many throttles for now 2021-05-27 13:05:23 -04:00
Tyler Goodlet a4627c2b04 Send blank packet on no match to avoid blocking search stream 2021-05-27 13:05:23 -04:00
Tyler Goodlet ddc2c8975a Ignore whitespace patterns in ib search 2021-05-27 13:05:23 -04:00
Tyler Goodlet c9311dd7d0 Few more derivs symbols 2021-05-27 13:05:23 -04:00
Tyler Goodlet 6f3b799960 Skip ib exchanges we haven't tested yet 2021-05-27 13:05:23 -04:00
Tyler Goodlet fd8dc4f1a3 Make -b a multi-option for backends 2021-05-27 13:05:23 -04:00
Tyler Goodlet bbd5883e52 Add search pause configs to backends 2021-05-27 13:05:23 -04:00
Tyler Goodlet e5e9a7c582 Add symbol searching for ib backend
Obviously this only supports stocks to start, it looks like we might
actually have to hard code some of the futures/forex/cmdtys that don't
have a search.. so lame. Special throttling is added here since the api
will grog out at anything more then 1Hz.

Additionally, decouple the bar loading request error handling from the
shm pushing loop so that we can always recover from a historical bars
throttle-error even if it's on the first try for a new symbol.
2021-05-27 13:05:22 -04:00
Tyler Goodlet ef1b0911f3 Add symbol search to ib 2021-05-27 13:05:22 -04:00
Tyler Goodlet 82a8e0a7b6 Accept lower case sym requests in kraken backend 2021-05-27 13:05:22 -04:00
Tyler Goodlet ad494db213 Make search routine a tractor context 2021-05-27 13:05:22 -04:00
Tyler Goodlet 4b818ea2f2 Add initial symbol search api for kraken 2021-05-27 13:05:22 -04:00
Tyler Goodlet c26f4d9877 Add kraken fuzzy symbol search 2021-05-27 13:05:22 -04:00
Tyler Goodlet 27aed85404 Handle no matching symbols case 2021-05-27 13:05:22 -04:00
Tyler Goodlet 9cad59366f Extract min tick info from symbol data 2021-05-25 08:46:10 -04:00
Tyler Goodlet 165d6257fa Get symbol search working for binance 2021-05-25 08:46:04 -04:00
Tyler Goodlet 7b8c482719 Add reconnect logic help link 2021-05-24 12:16:49 -04:00
goodboy 372b0dbace
Merge pull request #170 from guilledk/binance_backend
Add Binance backend
2021-05-24 10:54:55 -04:00
Tyler Goodlet b6d8c300d4 Slap in brokers.toml template if none exists 2021-05-22 15:11:39 -04:00
Guillermo Rodriguez a0dfdd935f
Post @goodboy review commit 2021-05-21 22:23:35 -03:00
Tyler Goodlet 7b26bd45e2 Get binance OHLC history and quote format correct
This gets the binance provider meeting the data feed schema requirements
of both the OHLC sampling/charting machinery as well as proper
formatting of historical OHLC history.

Notably,
- spec a minimal ohlc dtype based on the kline endpoint
- use a dataclass to parse out OHLC bar datums and pack into np.ndarray/shm
- add the ``aggTrade`` endpoint to get last clearing (traded) prices,
  validate with ``pydantic`` and then normalize these into our tick-quote
  format for delivery over the feed stream api.
- a notable requirement is that the "first" quote from the feed must
  contain a 'last` field so the clearing system can start up correctly.
2021-05-21 15:35:36 -04:00
Tyler Goodlet 2ef5a52521 Fix broken import in ib backend 2021-05-20 19:34:45 -04:00
Guillermo Rodriguez 432bd96474
Added missing toml dependency to setup.py
Pinned qdarkstyle to 2.8.1
Updated arrow timestamp api used in kraken backend
2021-05-16 18:53:54 -03:00
Guillermo Rodriguez 604e195bc0
Got rid of websocket OHLC API, and added l1 tick streaming 2021-05-07 10:59:08 -03:00
Guillermo Rodriguez 7e493625f6
Finally backfilling is working, still need to work on realtime updates! 2021-05-05 10:17:52 -03:00
Guillermo Rodriguez d327584039
Rough translation of kraken backend to binance API, still missing some
important parts
2021-05-04 22:52:53 -03:00
Tyler Goodlet 3375735914 Port kivy monitor to new tractor stream api 2021-04-29 09:10:11 -04:00
Tyler Goodlet 7d6bc4d856 Move feed api(s) into new submodule
Also add a --pdb flag to chart app.
2021-04-15 10:43:29 -04:00
Tyler Goodlet ddae08493b Manage the send mem chan lifetime 2021-04-10 14:18:40 -04:00
Tyler Goodlet 5a970dad72 Port kraken backend to new data feed api 2021-04-10 14:18:40 -04:00
Tyler Goodlet 24bda8636e Port quest to new client api 2021-04-10 14:18:40 -04:00
Tyler Goodlet 1d013126b9 Fix type annot 2021-04-10 14:18:40 -04:00
Tyler Goodlet b2eacb85d4 Don't hold lock on initial client construction 2021-04-10 14:18:40 -04:00
Tyler Goodlet 5fc2aba3ed Drop some more old cruft 2021-04-10 14:18:40 -04:00
Tyler Goodlet a82f43e3a5 Rework data feed API to allow for caching streams
Move all feed/stream agnostic logic and shared mem writing into a new
set of routines inside the ``data`` sub-package. This lets us move
toward a more standard API for broker and data backends to provide
cache-able persistent streams to client apps.

The data layer now takes care of
- starting a single background brokerd task to start a stream for as
  symbol if none yet exists and register that stream for later lookups
- the existing broker backend actor is now always re-used if possible
  if it can be found in a service tree
- synchronization with the brokerd stream's startup sequence is now
  oriented around fast startup concurrency such that client code gets
  a handle to historical data and quote schema as fast as possible
- historical data loading is delegated to the backend more formally by
  starting a ``backfill_bars()`` task
- write shared mem in the brokerd task and only destruct it once requested
  either from the parent actor or further clients
- fully de-duplicate stream data by using a dynamic pub-sub strategy
  where new clients register for copies of the same quote set per symbol

This new API is entirely working with the IB backend; others will need
to be ported. That's to come shortly.
2021-04-10 14:18:40 -04:00
Tyler Goodlet f17a26c948 Don't mistakenly alias options to underlyingn for positions 2021-04-10 14:18:40 -04:00
Tyler Goodlet 0d4073dbd2 Move quote stream setup into a cacheing func 2021-04-10 14:18:40 -04:00
Tyler Goodlet aa61bf5a65 Use mem-chans for quote streams; clone for multiple consumers 2021-04-10 14:18:40 -04:00
Tyler Goodlet 6265ae8057 Add position event relay to ib broker backend 2021-03-11 21:38:31 -05:00
Tyler Goodlet 2cabe1831c Attempt to handle existing order updates with ib backend 2021-03-06 16:33:56 -05:00
Tyler Goodlet 8997b6029b Drop cruft 2021-03-01 12:02:07 -05:00
Tyler Goodlet 72c4a4366b Tag TWS trade events 2021-03-01 12:01:48 -05:00
Tyler Goodlet 1142a538ea Don't forward errors without an order id 2021-02-22 10:45:01 -05:00
Tyler Goodlet e6ea053d40 Get kivy/questrade shit working again 2021-02-21 12:32:40 -05:00
Tyler Goodlet add63734f1 Add an auto-reconnect websocket API 2021-02-19 18:42:50 -05:00
Tyler Goodlet bbd54e8f95 Report asset types, tick sizes, and order actions from ib 2021-02-19 17:23:37 -05:00
Tyler Goodlet 0c184b1b41 Port ib to new provide new tick size fields in symbol info 2021-02-06 14:37:24 -05:00
Tyler Goodlet 69df73afc3 Deliver symbol info from kraken; start using pydantic 2021-02-06 14:23:27 -05:00
Tyler Goodlet 708086cbcb Convert contractsto dicts on errors 2021-01-26 13:34:49 -05:00
Tyler Goodlet b4a4f12aa4 Send init message with kraken 2021-01-22 22:55:49 -05:00
Tyler Goodlet 10e47e349c Include symbol deats in feed init message from ib
Async spawn a deats getter task whenever we load a symbol data feed.
Pass these symbol details in the first message delivered by the feed at
open. Move stream loop into a new func.
2021-01-22 17:11:53 -05:00
Tyler Goodlet 794665db70 Drop log msg 2021-01-18 20:28:52 -05:00
Tyler Goodlet 2bf95d7ec7 Fix clients map typing annot 2021-01-15 21:10:08 -05:00
Tyler Goodlet bdc02010cf Finally, sanely normalize local trades event data 2021-01-15 21:10:08 -05:00
Tyler Goodlet c835cc10e0 Get "live" order mode mostly workin 2021-01-15 21:10:08 -05:00
Tyler Goodlet ee8caa80d4 Add order cancellation and error support 2021-01-15 21:10:08 -05:00
Tyler Goodlet 12aebcc89c Expose "proxy" api a little better 2021-01-15 21:10:08 -05:00
Tyler Goodlet 280739b51a Add trades data streaming support 2021-01-15 21:10:08 -05:00
Tyler Goodlet dba8457be9 Trigger kraken sample increment after startup 2021-01-07 12:17:10 -05:00
Tyler Goodlet 268f207a6c Shadow 'close' field with 'last' 2021-01-05 08:02:48 -05:00
Tyler Goodlet c7ff0804db Graph snap quote immediately on ib spin up 2021-01-04 14:43:59 -05:00
Tyler Goodlet 5fddb581ab Kill backfiller on "no history" error 2021-01-01 12:34:50 -05:00
Tyler Goodlet d7f80d8ddb Add note about shm limit 2020-12-29 18:05:36 -05:00