Add vwap to exposed fsp map

vwap_fsp
Tyler Goodlet 2020-11-10 20:18:16 -05:00
parent ef2be16d97
commit 33515f45cc
1 changed files with 9 additions and 11 deletions

View File

@ -25,13 +25,18 @@ import numpy as np
from ..log import get_logger from ..log import get_logger
from .. import data from .. import data
from ._momo import _rsi from ._momo import _rsi, _wma
from ._volume import _tina_vwap
from ..data import attach_shm_array, Feed from ..data import attach_shm_array, Feed
log = get_logger(__name__) log = get_logger(__name__)
_fsps = {'rsi': _rsi} _fsps = {
'rsi': _rsi,
'wma': _wma,
'vwap': _tina_vwap,
}
async def latency( async def latency(
@ -72,7 +77,6 @@ async def increment_signals(
dst_shm.push(last) dst_shm.push(last)
@tractor.stream @tractor.stream
async def cascade( async def cascade(
ctx: tractor.Context, ctx: tractor.Context,
@ -112,7 +116,6 @@ async def cascade(
# THERE'S A BIG BUG HERE WITH THE `index` field since we're # THERE'S A BIG BUG HERE WITH THE `index` field since we're
# prepending a copy of the first value a few times to make # prepending a copy of the first value a few times to make
# sub-curves align with the parent bar chart. # sub-curves align with the parent bar chart.
#
# This likely needs to be fixed either by, # This likely needs to be fixed either by,
# - manually assigning the index and historical data # - manually assigning the index and historical data
# seperately to the shm array (i.e. not using .push()) # seperately to the shm array (i.e. not using .push())
@ -125,7 +128,7 @@ async def cascade(
# and get historical output # and get historical output
history_output = await out_stream.__anext__() history_output = await out_stream.__anext__()
# build a struct array which includes an 'index' field to push # build a struct array which includes an 'index' field to push
# as history # as history
history = np.array( history = np.array(
np.arange(len(history_output)), np.arange(len(history_output)),
@ -133,15 +136,10 @@ async def cascade(
) )
history[fsp_func_name] = history_output history[fsp_func_name] = history_output
# TODO: talk to ``pyqtgraph`` core about proper way to solve this:
# XXX: hack to get curves aligned with bars graphics: prepend
# a copy of the first datum..
# dst.push(history[:1])
# check for data length mis-allignment and fill missing values # check for data length mis-allignment and fill missing values
diff = len(src.array) - len(history) diff = len(src.array) - len(history)
if diff >= 0: if diff >= 0:
print(f"WTF DIFFZZZ {diff}") print(f"WTF DIFF SIGNAL to HISTORY {diff}")
for _ in range(diff): for _ in range(diff):
dst.push(history[:1]) dst.push(history[:1])