From 8d21c382e01ad39c087e6cb9d48df5227dc36a10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Mart=C3=ADnez?= Date: Mon, 12 Aug 2019 12:58:54 +0100 Subject: [PATCH] Add new issues template --- .github/CODEOWNERS | 0 .github/ISSUE_TEMPLATE/bug_report.md | 28 ++++++ .../ISSUE_TEMPLATE/documentation-request.md | 35 ++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 +++++ .github/ISSUE_TEMPLATE/submit-question.md | 10 +++ .github/PULL_REQUEST_TEMPLATE.md | 49 +++++++++++ notebook/cuIndicator/viz/__init__.py | 14 +++ .../viz/_accumulation_distribution.py | 30 +++++++ notebook/cuIndicator/viz/_ease_of_movement.py | 30 +++++++ notebook/cuIndicator/viz/_keltner_channel.py | 30 +++++++ .../cuIndicator/viz/_on_balance_volume.py | 30 +++++++ .../viz/_stochastic_oscillator_k.py | 30 +++++++ notebook/cuIndicator/viz/admi.py | 39 +++++++++ .../cuIndicator/viz/average_true_range.py | 30 +++++++ notebook/cuIndicator/viz/bollinger_bands.py | 43 +++++++++ notebook/cuIndicator/viz/ch_oscillator.py | 39 +++++++++ .../viz/commodity_channel_index.py | 32 +++++++ notebook/cuIndicator/viz/coppock_curve.py | 31 +++++++ notebook/cuIndicator/viz/donchian_channel.py | 30 +++++++ notebook/cuIndicator/viz/ewa.py | 25 ++++++ notebook/cuIndicator/viz/force_index.py | 30 +++++++ notebook/cuIndicator/viz/kst_oscillator.py | 35 ++++++++ notebook/cuIndicator/viz/ma.py | 26 ++++++ notebook/cuIndicator/viz/macd.py | 49 +++++++++++ notebook/cuIndicator/viz/mass_index.py | 39 +++++++++ notebook/cuIndicator/viz/momentum.py | 30 +++++++ notebook/cuIndicator/viz/money_flow_index.py | 30 +++++++ notebook/cuIndicator/viz/parabolic_sar.py | 80 +++++++++++++++++ notebook/cuIndicator/viz/rate_of_change.py | 31 +++++++ notebook/cuIndicator/viz/rsi.py | 30 +++++++ .../viz/stochastic_oscillator_d.py | 30 +++++++ notebook/cuIndicator/viz/trix.py | 30 +++++++ .../cuIndicator/viz/true_strength_index.py | 39 +++++++++ .../cuIndicator/viz/ultimate_oscillator.py | 30 +++++++ notebook/cuIndicator/viz/vortex_indicator.py | 30 +++++++ util/print_env.sh | 87 +++++++++++++++++++ 36 files changed, 1201 insertions(+) create mode 100644 .github/CODEOWNERS create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/documentation-request.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/submit-question.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 notebook/cuIndicator/viz/__init__.py create mode 100644 notebook/cuIndicator/viz/_accumulation_distribution.py create mode 100644 notebook/cuIndicator/viz/_ease_of_movement.py create mode 100644 notebook/cuIndicator/viz/_keltner_channel.py create mode 100644 notebook/cuIndicator/viz/_on_balance_volume.py create mode 100644 notebook/cuIndicator/viz/_stochastic_oscillator_k.py create mode 100644 notebook/cuIndicator/viz/admi.py create mode 100644 notebook/cuIndicator/viz/average_true_range.py create mode 100644 notebook/cuIndicator/viz/bollinger_bands.py create mode 100644 notebook/cuIndicator/viz/ch_oscillator.py create mode 100644 notebook/cuIndicator/viz/commodity_channel_index.py create mode 100644 notebook/cuIndicator/viz/coppock_curve.py create mode 100644 notebook/cuIndicator/viz/donchian_channel.py create mode 100644 notebook/cuIndicator/viz/ewa.py create mode 100644 notebook/cuIndicator/viz/force_index.py create mode 100644 notebook/cuIndicator/viz/kst_oscillator.py create mode 100644 notebook/cuIndicator/viz/ma.py create mode 100644 notebook/cuIndicator/viz/macd.py create mode 100644 notebook/cuIndicator/viz/mass_index.py create mode 100644 notebook/cuIndicator/viz/momentum.py create mode 100644 notebook/cuIndicator/viz/money_flow_index.py create mode 100644 notebook/cuIndicator/viz/parabolic_sar.py create mode 100644 notebook/cuIndicator/viz/rate_of_change.py create mode 100644 notebook/cuIndicator/viz/rsi.py create mode 100644 notebook/cuIndicator/viz/stochastic_oscillator_d.py create mode 100644 notebook/cuIndicator/viz/trix.py create mode 100644 notebook/cuIndicator/viz/true_strength_index.py create mode 100644 notebook/cuIndicator/viz/ultimate_oscillator.py create mode 100644 notebook/cuIndicator/viz/vortex_indicator.py create mode 100755 util/print_env.sh diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..e69de29b diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..f653c065 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,28 @@ +--- +name: Bug report +about: Create a bug report to help us improve gQuant +title: "[BUG]" +labels: "? - Needs Triage, bug" +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**Steps/Code to reproduce bug** +Follow this guide http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports to craft a minimal bug report. This helps us reproduce the issue you're having and resolve the issue more quickly. + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Environment overview (please complete the following information)** + - Environment location: [Bare-metal, Docker, Cloud(specify cloud provider)] + - Method of gQuant install: [Docker build, or from source] + + +**Environment details** +Please run and paste the output of the `/print_env.sh` script here, to gather any other relevant environment details + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/documentation-request.md b/.github/ISSUE_TEMPLATE/documentation-request.md new file mode 100644 index 00000000..89a026f3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation-request.md @@ -0,0 +1,35 @@ +--- +name: Documentation request +about: Report incorrect or needed documentation +title: "[DOC]" +labels: "? - Needs Triage, doc" +assignees: '' + +--- + +## Report incorrect documentation + +**Location of incorrect documentation** +Provide links and line numbers if applicable. + +**Describe the problems or issues found in the documentation** +A clear and concise description of what you found to be incorrect. + +**Steps taken to verify documentation is incorrect** +List any steps you have taken: + +**Suggested fix for documentation** +Detail proposed changes to fix the documentation if you have any. + +--- + +## Report needed documentation + +**Report needed documentation** +A clear and concise description of what documentation you believe it is needed and why. + +**Describe the documentation you'd like** +A clear and concise description of what you want to happen. + +**Steps taken to search for needed documentation** +List any steps you have taken: diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..83a1dc60 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for gQuant +title: "[FEA]" +labels: "? - Needs Triage, feature request" +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I wish I could use gQuant to do [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context, code examples, or references to existing implementations about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/submit-question.md b/.github/ISSUE_TEMPLATE/submit-question.md new file mode 100644 index 00000000..4076ea9d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/submit-question.md @@ -0,0 +1,10 @@ +--- +name: Submit question +about: Ask a general question about gQuant +title: "[QST]" +labels: "? - Needs Triage, question" +assignees: '' + +--- + +**What is your question?** diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..bafe6d23 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,49 @@ + diff --git a/notebook/cuIndicator/viz/__init__.py b/notebook/cuIndicator/viz/__init__.py new file mode 100644 index 00000000..83feeca9 --- /dev/null +++ b/notebook/cuIndicator/viz/__init__.py @@ -0,0 +1,14 @@ +import ipywidgets as widgets + +def get_para_widgets(): + para_selector = widgets.IntSlider(min=2, max=60, description="TRIX") + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + return (stock_df["close"],) + tuple([w.value for w in para_selector_widgets]) + +def process_outputs(output, stock_df): + stock_df['out'] = output + stock_df['out'] = stock_df['out'].fillna(0) + return stock_df \ No newline at end of file diff --git a/notebook/cuIndicator/viz/_accumulation_distribution.py b/notebook/cuIndicator/viz/_accumulation_distribution.py new file mode 100644 index 00000000..a97106a0 --- /dev/null +++ b/notebook/cuIndicator/viz/_accumulation_distribution.py @@ -0,0 +1,30 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import accumulation_distribution as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntSlider(min=2, max=60, description="Accumulation Distribution") + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + return (stock_df["high"], stock_df["low"], stock_df["close"], stock_df["volume"]) + tuple([w.value for w in para_selector_widgets]) + +def process_outputs(output,stock_df): + stock_df['out'] = output + stock_df['out'] = output.fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='Accumulation Distribution', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs \ No newline at end of file diff --git a/notebook/cuIndicator/viz/_ease_of_movement.py b/notebook/cuIndicator/viz/_ease_of_movement.py new file mode 100644 index 00000000..3b4e164a --- /dev/null +++ b/notebook/cuIndicator/viz/_ease_of_movement.py @@ -0,0 +1,30 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import ease_of_movement as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntSlider(min=2, max=60, description="Ease of Movement") + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + return (stock_df["high"], stock_df["low"], stock_df["volume"]) + tuple([w.value for w in para_selector_widgets]) + +def process_outputs(output,stock_df): + stock_df['out'] = output + stock_df['out'] = output.fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='Ease of Movement', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs \ No newline at end of file diff --git a/notebook/cuIndicator/viz/_keltner_channel.py b/notebook/cuIndicator/viz/_keltner_channel.py new file mode 100644 index 00000000..d1605dfb --- /dev/null +++ b/notebook/cuIndicator/viz/_keltner_channel.py @@ -0,0 +1,30 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import keltner_channel as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntSlider(min=2, max=60, description="Keltner Channel") + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + return (stock_df["high"], stock_df["low"], stock_df["close"]) + tuple([w.value for w in para_selector_widgets]) + +def process_outputs(output,stock_df): + stock_df['out'] = output + stock_df['out'] = output.fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='Keltner Channel', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs \ No newline at end of file diff --git a/notebook/cuIndicator/viz/_on_balance_volume.py b/notebook/cuIndicator/viz/_on_balance_volume.py new file mode 100644 index 00000000..133f66aa --- /dev/null +++ b/notebook/cuIndicator/viz/_on_balance_volume.py @@ -0,0 +1,30 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import on_balance_volume as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntSlider(min=2, max=60, description="On Balance volume") + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + return (stock_df["close"], stock_df["volume"]) + tuple([w.value for w in para_selector_widgets]) + +def process_outputs(output,stock_df): + stock_df['out'] = output + stock_df['out'] = output.fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='On Balance volume', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs \ No newline at end of file diff --git a/notebook/cuIndicator/viz/_stochastic_oscillator_k.py b/notebook/cuIndicator/viz/_stochastic_oscillator_k.py new file mode 100644 index 00000000..25f5f95d --- /dev/null +++ b/notebook/cuIndicator/viz/_stochastic_oscillator_k.py @@ -0,0 +1,30 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import stochastic_oscillator_k as indicator_fun + +def get_para_widgets(): + #para_selector = widgets.IntSlider(min=2, max=60, description="Ultimate Oscillator") + para_selector_widgets = [] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + return (stock_df["high"], stock_df["low"], stock_df["close"]) + +def process_outputs(output,stock_df): + stock_df['out'] = output + stock_df['out'] = output.fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='Stochastic Oscillator K', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs \ No newline at end of file diff --git a/notebook/cuIndicator/viz/admi.py b/notebook/cuIndicator/viz/admi.py new file mode 100644 index 00000000..ea7e6fe6 --- /dev/null +++ b/notebook/cuIndicator/viz/admi.py @@ -0,0 +1,39 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import average_directional_movement_index as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntRangeSlider(value=[10, 30], + min=3, + max=60, + step=1, + description="ADMI:", + disabled=False, + continuous_update=False, + orientation='horizontal', + readout=True) + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + widget = para_selector_widgets[0] + return (stock_df["high"], stock_df["low"], stock_df["close"], widget.value[0], widget.value[1]) + +def process_outputs(output, stock_df): + stock_df['out'] = output + stock_df['out'] = stock_df['out'].fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='ADMI', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs diff --git a/notebook/cuIndicator/viz/average_true_range.py b/notebook/cuIndicator/viz/average_true_range.py new file mode 100644 index 00000000..711ac0ef --- /dev/null +++ b/notebook/cuIndicator/viz/average_true_range.py @@ -0,0 +1,30 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import average_true_range as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntSlider(min=2, max=60, description="Average True Range") + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + return (stock_df["high"],stock_df["low"], stock_df["close"]) + tuple([w.value for w in para_selector_widgets]) + +def process_outputs(output,stock_df): + stock_df['out'] = output + stock_df['out'] = output.fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='Average True Range', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs \ No newline at end of file diff --git a/notebook/cuIndicator/viz/bollinger_bands.py b/notebook/cuIndicator/viz/bollinger_bands.py new file mode 100644 index 00000000..d23d1b4b --- /dev/null +++ b/notebook/cuIndicator/viz/bollinger_bands.py @@ -0,0 +1,43 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import bollinger_bands as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntSlider(min=2, max=60, description="Bollinger Bands") + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + return (stock_df["close"],) + tuple([w.value for w in para_selector_widgets]) + +def process_outputs(output, stock_df): + stock_df['out0'] = output.b1 + stock_df['out0'] = stock_df['out0'].fillna(0) + stock_df['out1'] = output.b2 + stock_df['out1'] = stock_df['out1'].fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + sc_co2 = LinearScale() + ax_y = Axis(label='Bollinger b1', scale=sc_co, orientation='vertical') + ax_y2 = Axis(label='Bollinger b2', scale=sc_co2, orientation='vertical', side='right') + new_line = Lines(x=stock.datetime, y=stock['out0'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_line2 = Lines(x=stock.datetime, y=stock['out1'], scales={'x': dt_scale, 'y': sc_co2}, colors=[CATEGORY20[(color_id[0] + 1) % len(CATEGORY20)]]) + new_fig = Figure(marks=[new_line, new_line2], axes=[ax_y, ax_y2]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line, new_line2] + add_new_indicator(new_fig) + return figs + +def update_figure(stock, objects): + line = objects[0] + line2 = objects[1] + with line.hold_trait_notifications() as lc, line2.hold_trait_notifications() as lc2: + line.y = stock['out0'] + line.x = stock.datetime + line2.y = stock['out1'] + line2.x = stock.datetime diff --git a/notebook/cuIndicator/viz/ch_oscillator.py b/notebook/cuIndicator/viz/ch_oscillator.py new file mode 100644 index 00000000..e86180af --- /dev/null +++ b/notebook/cuIndicator/viz/ch_oscillator.py @@ -0,0 +1,39 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import chaikin_oscillator as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntRangeSlider(value=[10, 30], + min=3, + max=60, + step=1, + description="Ch Oscillator:", + disabled=False, + continuous_update=False, + orientation='horizontal', + readout=True) + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + widget = para_selector_widgets[0] + return (stock_df["high"], stock_df["low"], stock_df["close"], stock_df["volume"], widget.value[0], widget.value[1]) + +def process_outputs(output, stock_df): + stock_df['out'] = output + stock_df['out'] = stock_df['out'].fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='Ch Osc', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs \ No newline at end of file diff --git a/notebook/cuIndicator/viz/commodity_channel_index.py b/notebook/cuIndicator/viz/commodity_channel_index.py new file mode 100644 index 00000000..535ee413 --- /dev/null +++ b/notebook/cuIndicator/viz/commodity_channel_index.py @@ -0,0 +1,32 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import commodity_channel_index as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntSlider(min=2, max=60, description="Commodity Channel Index") + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + #print ((stock_df["high"],stock_df["low"], stock_df["close"]) + tuple([w.value for w in para_selector_widgets])) + return (stock_df["high"],stock_df["low"], stock_df["close"]) + tuple([w.value for w in para_selector_widgets]) + + +def process_outputs(output,stock_df): + stock_df['out'] = output + stock_df['out'] = output.fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='CCI', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs \ No newline at end of file diff --git a/notebook/cuIndicator/viz/coppock_curve.py b/notebook/cuIndicator/viz/coppock_curve.py new file mode 100644 index 00000000..5abe2ef1 --- /dev/null +++ b/notebook/cuIndicator/viz/coppock_curve.py @@ -0,0 +1,31 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import coppock_curve as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntSlider(min=2, max=60, description="Coppock Curve") + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + return (stock_df["close"],) + tuple([w.value for w in para_selector_widgets]) + +def process_outputs(output,stock_df): + stock_df['out'] = output + stock_df['out'] = output.fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='Coppock Curve', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs + diff --git a/notebook/cuIndicator/viz/donchian_channel.py b/notebook/cuIndicator/viz/donchian_channel.py new file mode 100644 index 00000000..391c94a3 --- /dev/null +++ b/notebook/cuIndicator/viz/donchian_channel.py @@ -0,0 +1,30 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import donchian_channel as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntSlider(min=2, max=60, description="Donchian Channel") + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + return (stock_df["high"], stock_df["low"]) + tuple([w.value for w in para_selector_widgets]) + +def process_outputs(output,stock_df): + stock_df['out'] = output + stock_df['out'] = output.fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='Donchian Channel', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs \ No newline at end of file diff --git a/notebook/cuIndicator/viz/ewa.py b/notebook/cuIndicator/viz/ewa.py new file mode 100644 index 00000000..aa1f6147 --- /dev/null +++ b/notebook/cuIndicator/viz/ewa.py @@ -0,0 +1,25 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Lines +import math + +from gquant.cuindicator import exponential_moving_average as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntSlider(min=2, max=60, description="ewa avg periods") + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + return (stock_df["close"],) + tuple([w.value for w in para_selector_widgets]) + +def process_outputs(output, stock_df): + stock_df['out'] = output + stock_df['out'] = stock_df['out'].fillna(math.inf) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc}, colors=[CATEGORY20[color_id[0]]]) + figs = [line] + f.marks = f.marks + figs + return figs diff --git a/notebook/cuIndicator/viz/force_index.py b/notebook/cuIndicator/viz/force_index.py new file mode 100644 index 00000000..4d56cd5d --- /dev/null +++ b/notebook/cuIndicator/viz/force_index.py @@ -0,0 +1,30 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import force_index as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntSlider(min=2, max=60, description="Force Index") + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + return (stock_df["close"], stock_df["volume"]) + tuple([w.value for w in para_selector_widgets]) + +def process_outputs(output,stock_df): + stock_df['out'] = output + stock_df['out'] = output.fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='Force Index', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs \ No newline at end of file diff --git a/notebook/cuIndicator/viz/kst_oscillator.py b/notebook/cuIndicator/viz/kst_oscillator.py new file mode 100644 index 00000000..6faaef7a --- /dev/null +++ b/notebook/cuIndicator/viz/kst_oscillator.py @@ -0,0 +1,35 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import kst_oscillator as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntSlider(min=2, max=60, description="KST Oscillator") + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + param = [w.value for w in para_selector_widgets] + print (param) + param_grp = [param[0] + i for i in range(8)] + print (param_grp) + return (stock_df["close"],param_grp[0],param_grp[1],param_grp[2],param_grp[3], + param_grp[4],param_grp[5],param_grp[6],param_grp[7]) + +def process_outputs(output,stock_df): + stock_df['out'] = output + stock_df['out'] = output.fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='KST Oscillator',scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs diff --git a/notebook/cuIndicator/viz/ma.py b/notebook/cuIndicator/viz/ma.py new file mode 100644 index 00000000..b8050b6e --- /dev/null +++ b/notebook/cuIndicator/viz/ma.py @@ -0,0 +1,26 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Lines +import math + +from gquant.cuindicator import moving_average as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntSlider(min=2, max=60, description="avg periods") + para_selector_widgets = [para_selector] + + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + return (stock_df["close"],) + tuple([w.value for w in para_selector_widgets]) + +def process_outputs(output, stock_df): + stock_df['out'] = output + stock_df['out'] = stock_df['out'].fillna(math.inf) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc}, colors=[CATEGORY20[color_id[0]]]) + figs = [line] + f.marks = f.marks + figs + return figs diff --git a/notebook/cuIndicator/viz/macd.py b/notebook/cuIndicator/viz/macd.py new file mode 100644 index 00000000..01b2f72a --- /dev/null +++ b/notebook/cuIndicator/viz/macd.py @@ -0,0 +1,49 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import macd as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntRangeSlider(value=[10, 30], + min=3, + max=60, + step=1, + description="MACD:", + disabled=False, + continuous_update=False, + orientation='horizontal', + readout=True) + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + widget = para_selector_widgets[0] + return (stock_df["close"], widget.value[0], widget.value[1]) + +def process_outputs(output, stock_df): + stock_df['out0'] = output.MACD + stock_df['out0'] = stock_df['out0'].fillna(0) + stock_df['out1'] = output.MACDsign + stock_df['out1'] = stock_df['out1'].fillna(0) + stock_df['out2'] = output.MACDdiff + stock_df['out2'] = stock_df['out2'].fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='MACD', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=[stock['out0'], stock['out1'], stock['out2'] ], scales={'x': dt_scale, 'y': sc_co}) # + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs + +def update_figure(stock, objects): + line = objects[0] + with line.hold_trait_notifications(): + line.y = [stock['out0'], stock['out1'], stock['out2']] + line.x = stock.datetime \ No newline at end of file diff --git a/notebook/cuIndicator/viz/mass_index.py b/notebook/cuIndicator/viz/mass_index.py new file mode 100644 index 00000000..4af5aced --- /dev/null +++ b/notebook/cuIndicator/viz/mass_index.py @@ -0,0 +1,39 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import mass_index as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntRangeSlider(value=[10, 30], + min=3, + max=60, + step=1, + description="Mass Index:", + disabled=False, + continuous_update=False, + orientation='horizontal', + readout=True) + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + widget = para_selector_widgets[0] + return (stock_df["high"], stock_df["low"], widget.value[0], widget.value[1]) + +def process_outputs(output, stock_df): + stock_df['out'] = output + stock_df['out'] = stock_df['out'].fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='Mass Index', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs diff --git a/notebook/cuIndicator/viz/momentum.py b/notebook/cuIndicator/viz/momentum.py new file mode 100644 index 00000000..99d298ba --- /dev/null +++ b/notebook/cuIndicator/viz/momentum.py @@ -0,0 +1,30 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import momentum as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntSlider(min=2, max=60, description="Momentum") + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + return (stock_df["close"],) + tuple([w.value for w in para_selector_widgets]) + +def process_outputs(output,stock_df): + stock_df['out'] = output + stock_df['out'] = output.fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='Momentum', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs diff --git a/notebook/cuIndicator/viz/money_flow_index.py b/notebook/cuIndicator/viz/money_flow_index.py new file mode 100644 index 00000000..2d794b30 --- /dev/null +++ b/notebook/cuIndicator/viz/money_flow_index.py @@ -0,0 +1,30 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import money_flow_index as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntSlider(min=2, max=60, description="Money Flow Index") + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + return (stock_df["high"],stock_df["low"], stock_df["close"], stock_df["volume"]) + tuple([w.value for w in para_selector_widgets]) + +def process_outputs(output,stock_df): + stock_df['out'] = output + stock_df['out'] = output.fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='Money Flow Index', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs diff --git a/notebook/cuIndicator/viz/parabolic_sar.py b/notebook/cuIndicator/viz/parabolic_sar.py new file mode 100644 index 00000000..6e39ab70 --- /dev/null +++ b/notebook/cuIndicator/viz/parabolic_sar.py @@ -0,0 +1,80 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import ppsr as indicator_fun + +def get_para_widgets(): + #para_selector = widgets.IntSlider(min=2, max=60, description="Parabolic SAR") + para_selector_widgets = [] + return para_selector_widgets + +def get_parameters(stock_df,para_selector_widgets): + return (stock_df["high"], stock_df["low"], stock_df["close"]) + +def process_outputs(output,stock_df): + stock_df['out0'] = output.PP + stock_df['out0'] = stock_df['out0'].fillna(0) + stock_df['out1'] = output.R1 + stock_df['out1'] = stock_df['out1'].fillna(0) + stock_df['out2'] = output.S1 + stock_df['out2'] = stock_df['out2'].fillna(0) + stock_df['out3'] = output.R2 + stock_df['out3'] = stock_df['out3'].fillna(0) + stock_df['out4'] = output.S2 + stock_df['out4'] = stock_df['out4'].fillna(0) + stock_df['out5'] = output.R3 + stock_df['out5'] = stock_df['out5'].fillna(0) + stock_df['out6'] = output.S3 + stock_df['out6'] = stock_df['out6'].fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + sc_co2 = LinearScale() + sc_co3 = LinearScale() + sc_co4 = LinearScale() + sc_co5 = LinearScale() + sc_co6 = LinearScale() + sc_co7 = LinearScale() + + ax_y = Axis(label='PPSR PP', scale=sc_co, orientation='vertical') + ax_y2 = Axis(label='PPSR R1', scale=sc_co2, orientation='vertical', side='right') + ax_y3 = Axis(label='PPSR S1', scale=sc_co3, orientation='vertical', side='right') + ax_y4 = Axis(label='PPSR R2', scale=sc_co4, orientation='vertical', side='right') + ax_y5 = Axis(label='PPSR S2', scale=sc_co5, orientation='vertical', side='right') + ax_y6 = Axis(label='PPSR R3', scale=sc_co6, orientation='vertical', side='right') + ax_y7 = Axis(label='PPSR S3', scale=sc_co7, orientation='vertical', side='right') + new_line = Lines(x=stock.datetime, y=stock['out0'], scales={'x': dt_scale, 'y': sc_co}, + colors=[CATEGORY20[color_id[0]]]) + new_line2 = Lines(x=stock.datetime, y=stock['out1'], scales={'x': dt_scale, 'y': sc_co2}, + colors=[CATEGORY20[(color_id[0] + 1) % len(CATEGORY20)]]) + new_line3 = Lines(x=stock.datetime, y=stock['out2'], scales={'x': dt_scale, 'y': sc_co3}, + colors=[CATEGORY20[(color_id[0] + 2) % len(CATEGORY20)]]) + new_line4 = Lines(x=stock.datetime, y=stock['out3'], scales={'x': dt_scale, 'y': sc_co4}, + colors=[CATEGORY20[(color_id[0] + 3) % len(CATEGORY20)]]) + new_line5 = Lines(x=stock.datetime, y=stock['out4'], scales={'x': dt_scale, 'y': sc_co5}, + colors=[CATEGORY20[(color_id[0] + 4) % len(CATEGORY20)]]) + new_line6 = Lines(x=stock.datetime, y=stock['out5'], scales={'x': dt_scale, 'y': sc_co6}, + colors=[CATEGORY20[(color_id[0] + 5) % len(CATEGORY20)]]) + new_line7 = Lines(x=stock.datetime, y=stock['out6'], scales={'x': dt_scale, 'y': sc_co7}, + colors=[CATEGORY20[(color_id[0] + 6) % len(CATEGORY20)]]) + + + new_fig = Figure(marks=[new_line, new_line2, new_line3, new_line4, + new_line5, new_line6, new_line7], + axes=[ax_y, ax_y2, ax_y3, ax_y4, ax_y5, ax_y6, ax_y7]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line, new_line2, new_line3, new_line4, new_line5, new_line6, new_line7] + add_new_indicator(new_fig) + return figs + +def update_figure(stock, objects): + line = objects[0] + line2 = objects[1] + with line.hold_trait_notifications() as lc, line2.hold_trait_notifications() as lc2: + line.y = stock['out0'] + line.x = stock.datetime + line2.y = stock['out1'] + line2.x = stock.datetime diff --git a/notebook/cuIndicator/viz/rate_of_change.py b/notebook/cuIndicator/viz/rate_of_change.py new file mode 100644 index 00000000..eb076c95 --- /dev/null +++ b/notebook/cuIndicator/viz/rate_of_change.py @@ -0,0 +1,31 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import rate_of_change as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntSlider(min=2, max=60, description="Rate of Change") + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + return (stock_df["close"],) + tuple([w.value for w in para_selector_widgets]) + +def process_outputs(output,stock_df): + stock_df['out'] = output + stock_df['out'] = output.fillna(0) + print(stock_df['out']) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='Rate of Change', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs \ No newline at end of file diff --git a/notebook/cuIndicator/viz/rsi.py b/notebook/cuIndicator/viz/rsi.py new file mode 100644 index 00000000..af114156 --- /dev/null +++ b/notebook/cuIndicator/viz/rsi.py @@ -0,0 +1,30 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import relative_strength_index as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntSlider(min=2, max=60, description="RSI") + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + return (stock_df["high"], stock_df["low"]) + tuple([w.value for w in para_selector_widgets]) + +def process_outputs(output, stock_df): + stock_df['out'] = output + stock_df['out'] = stock_df['out'].fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='RSI', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs diff --git a/notebook/cuIndicator/viz/stochastic_oscillator_d.py b/notebook/cuIndicator/viz/stochastic_oscillator_d.py new file mode 100644 index 00000000..b64e2211 --- /dev/null +++ b/notebook/cuIndicator/viz/stochastic_oscillator_d.py @@ -0,0 +1,30 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import stochastic_oscillator_d as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntSlider(min=2, max=60, description="Stochastic Oscillator D") + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + return (stock_df["high"],stock_df["low"], stock_df["close"]) + tuple([w.value for w in para_selector_widgets]) + +def process_outputs(output,stock_df): + stock_df['out'] = output + stock_df['out'] = output.fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='Stochastic Oscillator D', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs diff --git a/notebook/cuIndicator/viz/trix.py b/notebook/cuIndicator/viz/trix.py new file mode 100644 index 00000000..7ef40037 --- /dev/null +++ b/notebook/cuIndicator/viz/trix.py @@ -0,0 +1,30 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import exponential_moving_average as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntSlider(min=2, max=60, description="TRIX") + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + return (stock_df["close"],) + tuple([w.value for w in para_selector_widgets]) + +def process_outputs(output, stock_df): + stock_df['out'] = output + stock_df['out'] = stock_df['out'].fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='TRIX', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs \ No newline at end of file diff --git a/notebook/cuIndicator/viz/true_strength_index.py b/notebook/cuIndicator/viz/true_strength_index.py new file mode 100644 index 00000000..6ce39a33 --- /dev/null +++ b/notebook/cuIndicator/viz/true_strength_index.py @@ -0,0 +1,39 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import true_strength_index as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntRangeSlider(value=[10, 30], + min=3, + max=60, + step=1, + description="True Strength Index", + disabled=False, + continuous_update=False, + orientation='horizontal', + readout=True) + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + widget = para_selector_widgets[0] + return (stock_df["close"],widget.value[0], widget.value[1]) + +def process_outputs(output, stock_df): + stock_df['out'] = output + stock_df['out'] = stock_df['out'].fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='True Strength Index', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs \ No newline at end of file diff --git a/notebook/cuIndicator/viz/ultimate_oscillator.py b/notebook/cuIndicator/viz/ultimate_oscillator.py new file mode 100644 index 00000000..4b40252f --- /dev/null +++ b/notebook/cuIndicator/viz/ultimate_oscillator.py @@ -0,0 +1,30 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import ultimate_oscillator as indicator_fun + +def get_para_widgets(): + #para_selector = widgets.IntSlider(min=2, max=60, description="Ultimate Oscillator") + para_selector_widgets = [] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + return (stock_df["high"], stock_df["low"], stock_df["close"]) + +def process_outputs(output,stock_df): + stock_df['out'] = output + stock_df['out'] = output.fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='Ultimate Oscillator', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs \ No newline at end of file diff --git a/notebook/cuIndicator/viz/vortex_indicator.py b/notebook/cuIndicator/viz/vortex_indicator.py new file mode 100644 index 00000000..68d83803 --- /dev/null +++ b/notebook/cuIndicator/viz/vortex_indicator.py @@ -0,0 +1,30 @@ +import ipywidgets as widgets +from bqplot.colorschemes import CATEGORY20 +from bqplot import Axis, Figure, LinearScale, Lines + +from gquant.cuindicator import vortex_indicator as indicator_fun + +def get_para_widgets(): + para_selector = widgets.IntSlider(min=2, max=60, description="Vortex Indicator") + para_selector_widgets = [para_selector] + return para_selector_widgets + +def get_parameters(stock_df, para_selector_widgets): + return (stock_df["high"],stock_df["low"], stock_df["close"]) + tuple([w.value for w in para_selector_widgets]) + +def process_outputs(output,stock_df): + stock_df['out'] = output + stock_df['out'] = output.fillna(0) + return stock_df + +def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, figure_width, add_new_indicator): + sc_co = LinearScale() + ax_y = Axis(label='Vortex Indicator', scale=sc_co, orientation='vertical') + new_line = Lines(x=stock.datetime, y=stock['out'], scales={'x': dt_scale, 'y': sc_co}, colors=[CATEGORY20[color_id[0]]]) + new_fig = Figure(marks=[new_line], axes=[ax_y]) + new_fig.layout.height = indicator_figure_height + new_fig.layout.width = figure_width + figs = [new_line] + # add new figure + add_new_indicator(new_fig) + return figs \ No newline at end of file diff --git a/util/print_env.sh b/util/print_env.sh new file mode 100755 index 00000000..551dca65 --- /dev/null +++ b/util/print_env.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash +# Reports relevant environment information useful for diagnosing and +# debugging gQuant issues. +# Usage: +# "./print_env.sh" - prints to stdout +# "./print_env.sh > env.txt" - prints to file "env.txt" + +print_env() { + echo "**git***" + if [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" == "true" ]; then + git log --decorate -n 1 + echo "**git submodules***" + git submodule status --recursive + else + echo "Not inside a git repository" + fi + echo + + echo "***OS Information***" + cat /etc/*-release + uname -a + echo + + echo "***GPU Information***" + nvidia-smi + echo + + echo "***CPU***" + lscpu + echo + + echo "***CMake***" + which cmake && cmake --version + echo + + echo "***g++***" + which g++ && g++ --version + echo + + echo "***nvcc***" + which nvcc && nvcc --version + echo + + echo "***Python***" + which python && python -c "import sys; print('Python {0}.{1}.{2}'.format(sys.version_info[0], sys.version_info[1], sys.version_info[2]))" + echo + + echo "***Environment Variables***" + + printf '%-32s: %s\n' PATH $PATH + + printf '%-32s: %s\n' LD_LIBRARY_PATH $LD_LIBRARY_PATH + + printf '%-32s: %s\n' NUMBAPRO_NVVM $NUMBAPRO_NVVM + + printf '%-32s: %s\n' NUMBAPRO_LIBDEVICE $NUMBAPRO_LIBDEVICE + + printf '%-32s: %s\n' CONDA_PREFIX $CONDA_PREFIX + + printf '%-32s: %s\n' PYTHON_PATH $PYTHON_PATH + + echo + + + # Print conda packages if conda exists + if type "conda" &> /dev/null; then + echo '***conda packages***' + which conda && conda list + echo + # Print pip packages if pip exists + elif type "pip" &> /dev/null; then + echo "conda not found" + echo "***pip packages***" + which pip && pip list + echo + else + echo "conda not found" + echo "pip not found" + fi +} + +echo "
Click here to see environment details
"
+echo "     "
+print_env | while read -r line; do
+    echo "     $line"
+done
+echo "
"