How to fit dash into the rest of the app?

I am trying to make a trading bot which have to do both, accepting inputs from the dashboard AND work with the rest of my trading application (strategies, back testing, trading…) when nothing is happening on the dashboard. Where do I put the rest of the application within Dash… or where do I put Dash within the rest of the application?

Hi @trader007

Dash allows to do anything, you can build your entire application in Dash or share data between Dash and other applications.
Also allows to add external links.
Here is my stock analysis app that is 100% Dash app:
https://companyanalysis.herokuapp.com/

Thanks, Eduardo, but that doesn’t answer the question.
Let’s say I have a loop which will last several seconds or several minutes.
What I couldn’t find anywhere on Internet is:
Where, exactly, I put that loop?
Will dashboard be responsive while my loop is running?
How does Dash dashboard work? Is it a loop on its own and stops everything else while is running thousands of times per second… or works like computer keyboard where you can run anything in “background” and keyboard is checked maybe every 100 milliseconds?
I am missing those basic information.
Or, let’s imagine that you already have a trading bot. How do you incorporate (exactly) a Dash dashboard?
Is it after the run server function… is it a part of Interval function?
I have a crazy idea: Interval function starts every 1000 milliseconds and starts a part of my trading bot as a function triggered by that interval feature, trading boot measures the time ran and returns something within 900 milliseconds and remembers where it stopped within its loop and continues after next trigger (100 ms later). This idea would work, I believe, but is not really practical.
How do you implement a Dash dashboard “around” already existing application (trading bot in this case)?
Please answer this question if you can since I am sure that many people with already working python application want to build a dashboard to monitor and control it - and I couldn’t find an answer anywhere.
Thank you!

To make it even more simple:
This is a dcc.input code from Dash documents:

import dash_core_components as dcc
import dash_html_components as html
import dash
from dash.dependencies import Input, Output

app = dash.Dash(name)

ALLOWED_TYPES = (
“text”, “number”, “password”, “email”, “search”,
“tel”, “url”, “range”, “hidden”,
)

app.layout = html.Div(
[
dcc.Input(
id=“input_{}”.format(),
type=
,
placeholder=“input type {}”.format(_),
)
for _ in ALLOWED_TYPES
]
+ [html.Div(id=“out-all-types”)]
)

@app.callback(
Output(“out-all-types”, “children”),
[Input(“input_{}”.format(_), “value”) for _ in ALLOWED_TYPES],
)
def cb_render(*vals):
return " | ".join((str(val) for val in vals if val))

if name == “main”:
app.run_server(debug=True)

The question:
If you already made a python app which does a very time consuming calculation (for example a loop with a trillion iterations) - how would you combine that app and the Dash dashboard? How will you put together the already existing python app (the loop in this example) and the Dash dashboard?
Am I clear or should I make a more specific question?

Hey Eduardo, is your code for this application on GitHub? Would love to see how you set things up on something this detailed.

Hey @trader007

Sorry I can’t help on your questions, rather because I do not understand your issue or because I do not understand English so much, or because I do not know about trading bot and what kind of loops do you want to run. :thinking: :woozy_face:

Hey @dash-beginner

No, the code is not available, but I can help you in anything you need to know. :grinning:

1 Like

Hey @trader007

I can’t reproduce your code, use the share code option in the message menu:
image

import dash_core_components as dcc
import dash_html_components as html
import dash
from dash.dependencies import Input, Output

app = dash.Dash(__name__)

ALLOWED_TYPES = (
    "text", "number", "password", "email", "search",
    "tel", "url", "range", "hidden",
)


app.layout = html.Div(
    [
        dcc.Input(
            id="input_{}".format(_),
            type=_,
            placeholder="input type {}".format(_),
        )
        for _ in ALLOWED_TYPES
    ]
    + [html.Div(id="out-all-types")]
)


@app.callback(
    Output("out-all-types", "children"),
    [Input("input_{}".format(_), "value") for _ in ALLOWED_TYPES],
)
def cb_render(*vals):
    return " | ".join((str(val) for val in vals if val))


if __name__ == "__main__":
    app.run_server(debug=True)

It is this code: dcc.Input | Dash for Python Documentation | Plotly
You said “I do not know about trading bot”. You are kidding, right? I am sure you made your first trading bot years ago. I would really appreciate if you can help.

Hey @trader007

No kidding, I never used trading bot. I’m old fashioned, or just old. :joy:

I still do not understand what you want to acomplish with tour Dash app, sorry :woozy_face:

You can have your entire python code into a Dash app, just before the app.layout or inside the callbaks.

Hope anyother con help you. :thinking:

Thanks, Eduardo.
All the best!

@Eduardo - I really like your datatable format and their font and header style. Can you share the css or style on how you did it ?

Hi @akiwaga.morgan

I have different datatables in the app.
Please specify wich datatable are you refering to?

Eduardo