Support fqme rendering *without* the src key
Since most (legacy) stock brokers design their symbology without including the target exchange's source asset name - normally a fiat currency like USD - this adds an option for rendering market endpoints without that token for simpler use in backends for such brokers. As an example IB doesn't expect a `mnq/usd.cme.ib` symbol and instead presumes that since the CME lists all assets in USD then the source asset is implied. Impl details: - add `MktPair.pair: str` which replaces `.key` as a better name. - offer a `without_src: bool` to a new `.get_fqme()` getter method which will render everything the same minus the src token. - expose the new flag through both the new `.get_fqme()` and `.get_bs_fqme()` methods and wrap those both under the original property names `.bs_fqme` and `.fqme`.master
parent
12bfabf056
commit
89e8a834bf
|
@ -356,6 +356,13 @@ class MktPair(Struct, frozen=True):
|
||||||
'''
|
'''
|
||||||
The "endpoint key" for this market.
|
The "endpoint key" for this market.
|
||||||
|
|
||||||
|
'''
|
||||||
|
return self.pair
|
||||||
|
|
||||||
|
@property
|
||||||
|
def pair(self) -> str:
|
||||||
|
'''
|
||||||
|
The "endpoint asset pair key" for this market.
|
||||||
Eg. mnq/usd or btc/usdt or xmr/btc
|
Eg. mnq/usd or btc/usdt or xmr/btc
|
||||||
|
|
||||||
In most other tina platforms this is referred to as the
|
In most other tina platforms this is referred to as the
|
||||||
|
@ -390,13 +397,16 @@ class MktPair(Struct, frozen=True):
|
||||||
|
|
||||||
return maybe_cons_tokens(field_strs)
|
return maybe_cons_tokens(field_strs)
|
||||||
|
|
||||||
# NOTE: the main idea behind an fqme is to map a "market address"
|
def get_fqme(
|
||||||
# to some endpoint from a transaction provider (eg. a broker) such
|
self,
|
||||||
# that we build a table of `fqme: str -> bs_mktid: Any` where any "piker
|
|
||||||
# market address" maps 1-to-1 to some broker trading endpoint.
|
# NOTE: allow dropping the source asset from the
|
||||||
# @cached_property
|
# market endpoint's pair key. Eg. to change
|
||||||
@property
|
# mnq/usd.<> -> mnq.<> which is useful when
|
||||||
def fqme(self) -> str:
|
# searching (legacy) stock exchanges.
|
||||||
|
without_src: bool = False,
|
||||||
|
|
||||||
|
) -> str:
|
||||||
'''
|
'''
|
||||||
Return the fully qualified market endpoint-address for the
|
Return the fully qualified market endpoint-address for the
|
||||||
pair of transacting assets.
|
pair of transacting assets.
|
||||||
|
@ -431,21 +441,33 @@ class MktPair(Struct, frozen=True):
|
||||||
https://github.com/pikers/piker/issues/467
|
https://github.com/pikers/piker/issues/467
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
key: str = self.pair if not without_src else str(self.dst)
|
||||||
return maybe_cons_tokens([
|
return maybe_cons_tokens([
|
||||||
self.key, # final "pair name" (eg. qqq[/usd], btcusdt)
|
key, # final "pair name" (eg. qqq[/usd], btcusdt)
|
||||||
self.venue,
|
self.venue,
|
||||||
self.suffix, # includes expiry and other con info
|
self.suffix, # includes expiry and other con info
|
||||||
self.broker,
|
self.broker,
|
||||||
])
|
])
|
||||||
|
|
||||||
@property
|
# NOTE: the main idea behind an fqme is to map a "market address"
|
||||||
def bs_fqme(self) -> str:
|
# to some endpoint from a transaction provider (eg. a broker) such
|
||||||
|
# that we build a table of `fqme: str -> bs_mktid: Any` where any "piker
|
||||||
|
# market address" maps 1-to-1 to some broker trading endpoint.
|
||||||
|
# @cached_property
|
||||||
|
fqme = property(get_fqme)
|
||||||
|
|
||||||
|
def get_bs_fqme(
|
||||||
|
self,
|
||||||
|
**kwargs,
|
||||||
|
) -> str:
|
||||||
'''
|
'''
|
||||||
FQME sin broker part XD
|
FQME sin broker part XD
|
||||||
|
|
||||||
'''
|
'''
|
||||||
head, _, broker = self.fqme.rpartition('.')
|
sin_broker, *_ = self.get_fqme(**kwargs).rpartition('.')
|
||||||
return head
|
return sin_broker
|
||||||
|
|
||||||
|
bs_fqme = property(get_bs_fqme)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fqsn(self) -> str:
|
def fqsn(self) -> str:
|
||||||
|
|
Loading…
Reference in New Issue