Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[REVIEW] hot fix for 0.4 release #86

Merged
merged 2 commits into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ dist/
build/
gquant.egg-info/
*.swp
docker/Dockerfile.Rapids
docker/gQuant
18 changes: 11 additions & 7 deletions docker/build.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ esac
echo -e "\nPlease, select your cuda version:\n" \
" - '1' for cuda 9.2\n" \
" - '2' for cuda 10.0\n" \
" - '3' for cuda 10.1.2"
" - '3' for cuda 10.1.2\n" \
" - '4' for cuda 10.2"

read -p "Enter your option and hit return [1]-3: " CUDA_VERSION
read -p "Enter your option and hit return [1]-4: " CUDA_VERSION

RAPIDS_VERSION="0.13"

Expand All @@ -44,6 +45,10 @@ case $CUDA_VERSION in
echo "cuda 10.1.2 selected."
CONTAINER_VER='10.1'
;;
4)
echo "cuda 10.2 selected."
CONTAINER_VER='10.2'
;;
*)
echo "cuda 9.2 selected."
CONTAINER_VER='9.2'
Expand All @@ -60,6 +65,7 @@ cp -r ../task_example ./gQuant
cp ../setup.cfg ./gQuant
cp ../setup.py ./gQuant
cp ../LICENSE ./gQuant
cp ../download_data.sh ./gQuant
rsync -av --progress ../notebooks ./gQuant --exclude data --exclude .cache --exclude many-small --exclude storage --exclude dask-worker-space --exclude __pycache__

gquant_ver=$(grep version gQuant/setup.py | sed "s/^.*version='\([^;]*\)'.*/\1/")
Expand All @@ -84,15 +90,13 @@ RUN source activate rapids \
&& cd /rapids/gQuant \
&& pip install .
RUN source activate rapids \
&& conda install -y -c conda-forge dask-labextension recommonmark numpydoc sphinx_rtd_theme pudb \
python-graphviz bqplot=0.11.5 nodejs=11.11.0 jupyterlab=0.35.4 ipywidgets=7.4.2 pytables mkl numexpr \
pydot
&& conda install -y -c conda-forge python-graphviz bqplot nodejs ipywidgets pytables mkl numexpr pydot
#
# required set up
#
RUN source activate rapids \
&& jupyter labextension install @jupyter-widgets/jupyterlab-manager@0.38.1 --no-build \
&& jupyter labextension install bqplot@0.4.5 --no-build \
&& jupyter labextension install @jupyter-widgets/jupyterlab-manager --no-build \
&& jupyter labextension install bqplot --no-build \
&& mkdir /.local /.jupyter /.config /.cupy \
&& chmod 777 /.local /.jupyter /.config /.cupy
RUN source activate rapids \
Expand Down
8 changes: 4 additions & 4 deletions notebooks/02_single_stock_trade.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "82c116c664634180af16d211f382ba01",
"model_id": "bef20587c5a94adbae804f78392f53b7",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -220,7 +220,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c5841ae2258049d3aa706ba3622d98b5",
"model_id": "80e2670f612249d3ae3bb8957f34f9fd",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -252,7 +252,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "19571440a1564ccd9e167e534fd9704d",
"model_id": "ddef9aedb65e4bf4af3380b1e0209f27",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -342,5 +342,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
36 changes: 18 additions & 18 deletions notebooks/04_portfolio_trade.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -266,27 +266,27 @@
"output_type": "stream",
"text": [
"id:sort process time:0.144s\n",
"id:add_return process time:1.137s\n",
"id:add_indicator process time:0.041s\n",
"id:volume_mean process time:0.112s\n",
"id:rename_mean_volume process time:0.001s\n",
"id:left_merge_mean_volume process time:2.703s\n",
"id:max_returns process time:0.025s\n",
"id:add_return process time:0.401s\n",
"id:add_indicator process time:0.046s\n",
"id:volume_mean process time:0.106s\n",
"id:rename_mean_volume process time:0.002s\n",
"id:left_merge_mean_volume process time:0.026s\n",
"id:max_returns process time:0.022s\n",
"id:rename_max_return process time:0.001s\n",
"id:left_merge_max_return process time:0.027s\n",
"id:left_merge_max_return process time:0.038s\n",
"id:min_returns process time:0.022s\n",
"id:rename_min_return process time:0.001s\n",
"id:left_merge_min_return process time:0.041s\n",
"id:filter_value process time:0.344s\n",
"id:drop_columns process time:0.012s\n",
"id:sort_2 process time:0.060s\n",
"id:exp_strategy process time:0.940s\n",
"id:backtest process time:0.043s\n",
"id:portfolio_opt process time:0.040s\n",
"id:left_merge_min_return process time:0.037s\n",
"id:filter_value process time:0.323s\n",
"id:drop_columns process time:0.009s\n",
"id:sort_2 process time:0.049s\n",
"id:exp_strategy process time:0.936s\n",
"id:backtest process time:0.038s\n",
"id:portfolio_opt process time:0.039s\n",
"id:sharpe_ratio process time:0.001s\n",
"id:cumlative_return process time:2.090s\n",
"CPU times: user 7.89 s, sys: 2.1 s, total: 9.99 s\n",
"Wall time: 10.2 s\n"
"id:cumlative_return process time:2.063s\n",
"CPU times: user 5.36 s, sys: 1.09 s, total: 6.45 s\n",
"Wall time: 6.6 s\n"
]
}
],
Expand Down Expand Up @@ -351,7 +351,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b1889a24e21e4f3e9ef987deba9dee7a",
"model_id": "b7479ffb4ae24389b92e15aa48847969",
"version_major": 2,
"version_minor": 0
},
Expand Down
16 changes: 7 additions & 9 deletions notebooks/cuIndicator/indicator_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,13 @@
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"scrolled": false
},
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "771fb5e210dd4dd190e9bba55600e5ce",
"model_id": "f3a3621fc2104f31b96493bbe902121c",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -406,13 +404,13 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "03d106aeb75a404db845c85ae4fadee3",
"model_id": "dd37ad79dadd4362a1266fda125ee788",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -452,9 +450,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
"version": "3.6.10"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
48 changes: 34 additions & 14 deletions notebooks/cuIndicator/rsi_perf.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
"source": [
"all_stock = gendata(2, 1) \n",
"df = cudf.DataFrame.from_pandas(all_stock)\n",
"df['Dte'] = df['Dte'].astype('datetime64[ms]')\n",
"ids = all_stock.Sm_id.unique()\n",
"list_stocks = { 'stock%d' % (i) : i for i in ids}\n",
"\n",
Expand Down Expand Up @@ -206,7 +207,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -239,11 +240,11 @@
" UpI = np.zeros(len(df))\n",
" DoI = np.zeros(len(df))\n",
" updown_movement(df['High'].values, df['Low'].values, UpI, DoI)\n",
" UpI = pd.Series(UpI, nan_as_null=False)\n",
" DoI = pd.Series(DoI, nan_as_null=False)\n",
" PosDI = pd.Series(UpI.ewm(span=n, min_periods=n).mean(), nan_as_null=False)\n",
" NegDI = pd.Series(DoI.ewm(span=n, min_periods=n).mean(), nan_as_null=False)\n",
" RSI = pd.Series(PosDI / (PosDI + NegDI), name='RSI', nan_as_null=False)\n",
" UpI = pd.Series(UpI)\n",
" DoI = pd.Series(DoI)\n",
" PosDI = pd.Series(UpI.ewm(span=n, min_periods=n).mean())\n",
" NegDI = pd.Series(DoI.ewm(span=n, min_periods=n).mean())\n",
" RSI = pd.Series(PosDI / (PosDI + NegDI), name='RSI')\n",
" df = df.join(RSI)\n",
" return df\n",
"\n",
Expand All @@ -264,7 +265,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -314,7 +315,7 @@
" :param n: time steps to do EWM average\n",
" :return: Relative Strength Index in cudf.Series\n",
" \"\"\"\n",
" UpI, DoI = upDownMove(high_ar.to_gpu_array(), low_ar.to_gpu_array())\n",
" UpI, DoI = upDownMove(high_arr.to_gpu_array(), low_arr.to_gpu_array())\n",
" UpI_s = shift(UpI, 1)\n",
" UpI_s[0] = 0\n",
" DoI_s = shift(DoI, 1)\n",
Expand All @@ -336,13 +337,13 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "436b8844c8d34ed99713c596661240d3",
"model_id": "ebc595e4f7854d299f2b6fbd43f0ad94",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -577,10 +578,14 @@
"\n",
"def stock_selection(*stock):\n",
" if add_stock_selector.value is None:\n",
" with out:\n",
" print('here')\n",
" return\n",
" f, year_selector, stock_selector, indicator_selector, para_selectors = get_figure(add_stock_selector.value, df)\n",
" vbox = w.children[1]\n",
" vbox.children += (widgets.HBox([f, widgets.VBox([year_selector, stock_selector, indicator_selector, para_selectors])]),) \n",
" with out:\n",
" print(widgets)\n",
" year_selectors.append(year_selector)\n",
" update_range()\n",
" add_stock_selector.value = None\n",
Expand Down Expand Up @@ -623,9 +628,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 15,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ef7aeb5f807c4854a8b553a2b0db8dac",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output(layout=Layout(border='1px solid black'), outputs=({'name': 'stdout', 'text': \"<module 'ipywidgets' from…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"out\n"
]
Expand Down Expand Up @@ -654,9 +674,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
"version": "3.6.10"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
8 changes: 5 additions & 3 deletions notebooks/cuIndicator/viz/accumulation_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ def get_para_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):
def process_outputs(output, stock_df):
output.index = stock_df.index

stock_df['out'] = output
stock_df['out'] = output.fillna(0)
return stock_df
Expand All @@ -23,8 +25,8 @@ def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, fig
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
new_fig.layout.width = figure_width
figs = [new_line]
# add new figure
add_new_indicator(new_fig)
return figs
return figs
8 changes: 5 additions & 3 deletions notebooks/cuIndicator/viz/admi.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ def get_para_widgets():
continuous_update=False,
orientation='horizontal',
readout=True)
para_selector_widgets = [para_selector]
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):
output.index = stock_df.index

stock_df['out'] = output
stock_df['out'] = stock_df['out'].fillna(0)
return stock_df
Expand All @@ -32,8 +34,8 @@ def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, fig
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
new_fig.layout.width = figure_width
figs = [new_line]
# add new figure
add_new_indicator(new_fig)
add_new_indicator(new_fig)
return figs
8 changes: 5 additions & 3 deletions notebooks/cuIndicator/viz/average_true_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ def get_para_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):
def process_outputs(output, stock_df):
output.index = stock_df.index

stock_df['out'] = output
stock_df['out'] = output.fillna(0)
return stock_df
Expand All @@ -23,8 +25,8 @@ def create_figure(stock, dt_scale, sc, color_id, f, indicator_figure_height, fig
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
new_fig.layout.width = figure_width
figs = [new_line]
# add new figure
add_new_indicator(new_fig)
return figs
return figs
Loading