Add piker chart command
parent
489e8c226f
commit
0d06dbbefa
|
@ -1,9 +1,11 @@
|
|||
"""
|
||||
Console interface to UI components.
|
||||
"""
|
||||
from datetime import datetime
|
||||
from functools import partial
|
||||
import os
|
||||
import click
|
||||
import trio
|
||||
import tractor
|
||||
|
||||
from ..cli import cli
|
||||
|
@ -102,3 +104,33 @@ def optschain(config, symbol, date, tl, rate, test):
|
|||
loglevel=loglevel if tl else None,
|
||||
start_method='forkserver',
|
||||
)
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.option('--tl', is_flag=True, help='Enable tractor logging')
|
||||
@click.option('--date', '-d', help='Contracts expiry date')
|
||||
@click.option('--test', '-t', help='Test quote stream file')
|
||||
@click.option('--rate', '-r', default=1, help='Logging level')
|
||||
@click.argument('symbol', required=True)
|
||||
@click.pass_obj
|
||||
def chart(config, symbol, date, tl, rate, test):
|
||||
"""Start an option chain UI
|
||||
"""
|
||||
from .qt._exec import run_qtrio
|
||||
from .qt._chart import QuotesTabWidget
|
||||
from .qt.quantdom.base import Symbol
|
||||
from .qt.quantdom.loaders import get_quotes
|
||||
|
||||
async def plot_symbol(widgets):
|
||||
qtw = widgets['main']
|
||||
s = Symbol(ticker=symbol, mode=Symbol.SHARES)
|
||||
get_quotes(
|
||||
symbol=s.ticker,
|
||||
date_from=datetime(1900, 1, 1),
|
||||
date_to=datetime(2030, 12, 31),
|
||||
)
|
||||
# spawn chart
|
||||
qtw.update_chart(s)
|
||||
await trio.sleep_forever()
|
||||
|
||||
run_qtrio(plot_symbol, (), QuotesTabWidget)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
"""
|
||||
Super hawt Qt UI components
|
||||
"""
|
|
@ -5,7 +5,6 @@ Run ``trio`` in guest mode on top of the Qt event loop.
|
|||
All global Qt runtime settings are mostly defined here.
|
||||
"""
|
||||
import traceback
|
||||
from datetime import datetime
|
||||
|
||||
import PyQt5 # noqa
|
||||
from pyqtgraph import QtGui
|
||||
|
@ -15,10 +14,6 @@ import qdarkstyle
|
|||
import trio
|
||||
from outcome import Error
|
||||
|
||||
from _chart import QuotesTabWidget
|
||||
from quantdom.base import Symbol
|
||||
from quantdom.loaders import get_quotes
|
||||
|
||||
|
||||
# Taken from Quantdom
|
||||
class MainWindow(QtGui.QMainWindow):
|
||||
|
@ -98,20 +93,3 @@ def run_qtrio(
|
|||
window.setCentralWidget(instance)
|
||||
window.show()
|
||||
app.exec_()
|
||||
|
||||
|
||||
async def plot_aapl(widgets):
|
||||
qtw = widgets['main']
|
||||
s = Symbol(ticker='AAPL', mode=Symbol.SHARES)
|
||||
get_quotes(
|
||||
symbol=s.ticker,
|
||||
date_from=datetime(1900, 1, 1),
|
||||
date_to=datetime(2030, 12, 31),
|
||||
)
|
||||
# spawn chart
|
||||
qtw.update_chart(s)
|
||||
await trio.sleep_forever()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run_qtrio(plot_aapl, (), QuotesTabWidget)
|
||||
|
|
Loading…
Reference in New Issue