Compare commits
3 Commits
2545def7bb
...
6f782862f8
Author | SHA1 | Date |
---|---|---|
|
6f782862f8 | |
|
baff466ee0 | |
|
b01edcf65a |
|
@ -96,7 +96,10 @@ async def _setup_persistent_brokerd(
|
||||||
# - `open_symbol_search()`
|
# - `open_symbol_search()`
|
||||||
# NOTE: see ep invocation details inside `.data.feed`.
|
# NOTE: see ep invocation details inside `.data.feed`.
|
||||||
try:
|
try:
|
||||||
async with trio.open_nursery() as service_nursery:
|
async with (
|
||||||
|
tractor.trionics.collapse_eg(),
|
||||||
|
trio.open_nursery() as service_nursery
|
||||||
|
):
|
||||||
bus: _FeedsBus = feed.get_feed_bus(
|
bus: _FeedsBus = feed.get_feed_bus(
|
||||||
brokername,
|
brokername,
|
||||||
service_nursery,
|
service_nursery,
|
||||||
|
|
|
@ -34,6 +34,7 @@ import urllib.parse
|
||||||
import hashlib
|
import hashlib
|
||||||
import hmac
|
import hmac
|
||||||
import base64
|
import base64
|
||||||
|
import tractor
|
||||||
import trio
|
import trio
|
||||||
|
|
||||||
from piker import config
|
from piker import config
|
||||||
|
@ -372,8 +373,7 @@ class Client:
|
||||||
# 1658347714, 'status': 'Success'}]}
|
# 1658347714, 'status': 'Success'}]}
|
||||||
|
|
||||||
if xfers:
|
if xfers:
|
||||||
import tractor
|
await tractor.pause()
|
||||||
await tractor.pp()
|
|
||||||
|
|
||||||
trans: dict[str, Transaction] = {}
|
trans: dict[str, Transaction] = {}
|
||||||
for entry in xfers:
|
for entry in xfers:
|
||||||
|
@ -501,7 +501,8 @@ class Client:
|
||||||
for xkey, data in resp['result'].items():
|
for xkey, data in resp['result'].items():
|
||||||
|
|
||||||
# NOTE: always cache in pairs tables for faster lookup
|
# NOTE: always cache in pairs tables for faster lookup
|
||||||
pair = Pair(xname=xkey, **data)
|
with tractor.devx.maybe_open_crash_handler(): # as bxerr:
|
||||||
|
pair = Pair(xname=xkey, **data)
|
||||||
|
|
||||||
# register the above `Pair` structs for all
|
# register the above `Pair` structs for all
|
||||||
# key-sets/monikers: a set of 4 (frickin) tables
|
# key-sets/monikers: a set of 4 (frickin) tables
|
||||||
|
|
|
@ -21,7 +21,6 @@ Symbology defs and search.
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
import tractor
|
import tractor
|
||||||
from rapidfuzz import process as fuzzy
|
|
||||||
|
|
||||||
from piker._cacheables import (
|
from piker._cacheables import (
|
||||||
async_lifo_cache,
|
async_lifo_cache,
|
||||||
|
@ -41,8 +40,13 @@ from piker.accounting._mktinfo import (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# https://www.kraken.com/features/api#get-tradable-pairs
|
|
||||||
class Pair(Struct):
|
class Pair(Struct):
|
||||||
|
'''
|
||||||
|
A tradable asset pair as schema-defined by,
|
||||||
|
|
||||||
|
https://docs.kraken.com/api/docs/rest-api/get-tradable-asset-pairs
|
||||||
|
|
||||||
|
'''
|
||||||
xname: str # idiotic bs_mktid equiv i guess?
|
xname: str # idiotic bs_mktid equiv i guess?
|
||||||
altname: str # alternate pair name
|
altname: str # alternate pair name
|
||||||
wsname: str # WebSocket pair name (if available)
|
wsname: str # WebSocket pair name (if available)
|
||||||
|
@ -53,7 +57,6 @@ class Pair(Struct):
|
||||||
lot: str # volume lot size
|
lot: str # volume lot size
|
||||||
|
|
||||||
cost_decimals: int
|
cost_decimals: int
|
||||||
costmin: float
|
|
||||||
pair_decimals: int # scaling decimal places for pair
|
pair_decimals: int # scaling decimal places for pair
|
||||||
lot_decimals: int # scaling decimal places for volume
|
lot_decimals: int # scaling decimal places for volume
|
||||||
|
|
||||||
|
@ -79,6 +82,7 @@ class Pair(Struct):
|
||||||
tick_size: float # min price step size
|
tick_size: float # min price step size
|
||||||
status: str
|
status: str
|
||||||
|
|
||||||
|
costmin: str|None = None # XXX, only some mktpairs?
|
||||||
short_position_limit: float = 0
|
short_position_limit: float = 0
|
||||||
long_position_limit: float = float('inf')
|
long_position_limit: float = float('inf')
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,10 @@ from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import trio
|
import trio
|
||||||
import tractor
|
import tractor
|
||||||
from tractor.trionics import broadcast_receiver
|
from tractor.trionics import (
|
||||||
|
broadcast_receiver,
|
||||||
|
collapse_eg,
|
||||||
|
)
|
||||||
|
|
||||||
from ._util import (
|
from ._util import (
|
||||||
log, # sub-sys logger
|
log, # sub-sys logger
|
||||||
|
@ -281,8 +284,11 @@ async def open_ems(
|
||||||
client._ems_stream = trades_stream
|
client._ems_stream = trades_stream
|
||||||
|
|
||||||
# start sync code order msg delivery task
|
# start sync code order msg delivery task
|
||||||
async with trio.open_nursery() as n:
|
async with (
|
||||||
n.start_soon(
|
collapse_eg(),
|
||||||
|
trio.open_nursery() as tn,
|
||||||
|
):
|
||||||
|
tn.start_soon(
|
||||||
relay_orders_from_sync_code,
|
relay_orders_from_sync_code,
|
||||||
client,
|
client,
|
||||||
fqme,
|
fqme,
|
||||||
|
@ -298,4 +304,4 @@ async def open_ems(
|
||||||
)
|
)
|
||||||
|
|
||||||
# stop the sync-msg-relay task on exit.
|
# stop the sync-msg-relay task on exit.
|
||||||
n.cancel_scope.cancel()
|
tn.cancel_scope.cancel()
|
||||||
|
|
|
@ -498,6 +498,7 @@ async def cascade(
|
||||||
|
|
||||||
func_name: str = func.__name__
|
func_name: str = func.__name__
|
||||||
async with (
|
async with (
|
||||||
|
tractor.trionics.collapse_eg(), # avoid multi-taskc tb in console
|
||||||
trio.open_nursery() as tn,
|
trio.open_nursery() as tn,
|
||||||
):
|
):
|
||||||
# TODO: might be better to just make a "restart" method where
|
# TODO: might be better to just make a "restart" method where
|
||||||
|
|
|
@ -200,7 +200,8 @@ async def open_pikerd(
|
||||||
reg_addrs,
|
reg_addrs,
|
||||||
),
|
),
|
||||||
tractor.open_nursery() as actor_nursery,
|
tractor.open_nursery() as actor_nursery,
|
||||||
trio.open_nursery() as service_nursery,
|
tractor.trionics.collapse_eg(),
|
||||||
|
trio.open_nursery() as service_tn,
|
||||||
):
|
):
|
||||||
for addr in reg_addrs:
|
for addr in reg_addrs:
|
||||||
if addr not in root_actor.accept_addrs:
|
if addr not in root_actor.accept_addrs:
|
||||||
|
@ -211,7 +212,7 @@ async def open_pikerd(
|
||||||
|
|
||||||
# assign globally for future daemon/task creation
|
# assign globally for future daemon/task creation
|
||||||
Services.actor_n = actor_nursery
|
Services.actor_n = actor_nursery
|
||||||
Services.service_n = service_nursery
|
Services.service_n = service_tn
|
||||||
Services.debug_mode = debug_mode
|
Services.debug_mode = debug_mode
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -221,7 +222,7 @@ async def open_pikerd(
|
||||||
# TODO: is this more clever/efficient?
|
# TODO: is this more clever/efficient?
|
||||||
# if 'samplerd' in Services.service_tasks:
|
# if 'samplerd' in Services.service_tasks:
|
||||||
# await Services.cancel_service('samplerd')
|
# await Services.cancel_service('samplerd')
|
||||||
service_nursery.cancel_scope.cancel()
|
service_tn.cancel_scope.cancel()
|
||||||
|
|
||||||
|
|
||||||
# TODO: do we even need this?
|
# TODO: do we even need this?
|
||||||
|
|
|
@ -33,7 +33,6 @@ import trio
|
||||||
|
|
||||||
from piker.ui.qt import (
|
from piker.ui.qt import (
|
||||||
QtCore,
|
QtCore,
|
||||||
QtWidgets,
|
|
||||||
Qt,
|
Qt,
|
||||||
QLineF,
|
QLineF,
|
||||||
QFrame,
|
QFrame,
|
||||||
|
|
|
@ -1445,7 +1445,10 @@ async def display_symbol_data(
|
||||||
# for pause/resume on mouse interaction
|
# for pause/resume on mouse interaction
|
||||||
rt_chart.feed = feed
|
rt_chart.feed = feed
|
||||||
|
|
||||||
async with trio.open_nursery() as ln:
|
async with (
|
||||||
|
tractor.trionics.collapse_eg(),
|
||||||
|
trio.open_nursery() as ln,
|
||||||
|
):
|
||||||
# if available load volume related built-in display(s)
|
# if available load volume related built-in display(s)
|
||||||
vlm_charts: dict[
|
vlm_charts: dict[
|
||||||
str,
|
str,
|
||||||
|
|
|
@ -22,7 +22,10 @@ from contextlib import asynccontextmanager as acm
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
import trio
|
import trio
|
||||||
from tractor.trionics import gather_contexts
|
from tractor.trionics import (
|
||||||
|
gather_contexts,
|
||||||
|
collapse_eg,
|
||||||
|
)
|
||||||
|
|
||||||
from piker.ui.qt import (
|
from piker.ui.qt import (
|
||||||
QtCore,
|
QtCore,
|
||||||
|
@ -207,7 +210,10 @@ async def open_signal_handler(
|
||||||
async for args in recv:
|
async for args in recv:
|
||||||
await async_handler(*args)
|
await async_handler(*args)
|
||||||
|
|
||||||
async with trio.open_nursery() as tn:
|
async with (
|
||||||
|
collapse_eg(),
|
||||||
|
trio.open_nursery() as tn
|
||||||
|
):
|
||||||
tn.start_soon(proxy_to_handler)
|
tn.start_soon(proxy_to_handler)
|
||||||
async with send:
|
async with send:
|
||||||
yield
|
yield
|
||||||
|
@ -242,6 +248,7 @@ async def open_handlers(
|
||||||
widget: QWidget
|
widget: QWidget
|
||||||
streams: list[trio.abc.ReceiveChannel]
|
streams: list[trio.abc.ReceiveChannel]
|
||||||
async with (
|
async with (
|
||||||
|
collapse_eg(),
|
||||||
trio.open_nursery() as tn,
|
trio.open_nursery() as tn,
|
||||||
gather_contexts([
|
gather_contexts([
|
||||||
open_event_stream(
|
open_event_stream(
|
||||||
|
|
|
@ -600,6 +600,7 @@ async def open_fsp_admin(
|
||||||
kwargs=kwargs,
|
kwargs=kwargs,
|
||||||
) as (cache_hit, cluster_map),
|
) as (cache_hit, cluster_map),
|
||||||
|
|
||||||
|
tractor.trionics.collapse_eg(),
|
||||||
trio.open_nursery() as tn,
|
trio.open_nursery() as tn,
|
||||||
):
|
):
|
||||||
if cache_hit:
|
if cache_hit:
|
||||||
|
@ -613,6 +614,8 @@ async def open_fsp_admin(
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
yield admin
|
yield admin
|
||||||
|
|
||||||
|
# ??TODO, does this *need* to be inside a finally?
|
||||||
finally:
|
finally:
|
||||||
# terminate all tasks via signals
|
# terminate all tasks via signals
|
||||||
for key, entry in admin._registry.items():
|
for key, entry in admin._registry.items():
|
||||||
|
|
|
@ -792,6 +792,7 @@ async def open_order_mode(
|
||||||
brokerd_accounts,
|
brokerd_accounts,
|
||||||
ems_dialog_msgs,
|
ems_dialog_msgs,
|
||||||
),
|
),
|
||||||
|
tractor.trionics.collapse_eg(),
|
||||||
trio.open_nursery() as tn,
|
trio.open_nursery() as tn,
|
||||||
|
|
||||||
):
|
):
|
||||||
|
|
Loading…
Reference in New Issue