Beispiel #1
0
def render_content(tab):
    # tab 1 is bets constructor
    if tab == 'tab-1':
        # left side of first tab
        return html.Div([
            html.Br(),
            html.H5('User balance: ' + str(rpc_connection.getinfo()['balance']) + " " + AC_NAME),
            html.Div(id='output-container-button',
                     children='Enter values and press submit', style={'marginBottom': 5, 'marginTop': 5, 'font-size': '16px'}),
            dcc.Input(
                placeholder='Input bet amount...',
                type='text',
                value='',
                id='betamount_text',
                style={'marginBottom': 10, 'marginTop': 10}
            ),
            html.Br(),
            dcc.Input(
                placeholder='Input leverage...',
                type='text',
                value='',
                id='leverage_text',
                style={'marginBottom': 10, 'marginTop': 10}
            ),
            html.Br(),
            dcc.Input(
                placeholder='Input synthetic...',
                type='text',
                value='',
                id='synthetic_text',
                style={'marginBottom': 15, 'marginTop': 10}
            ),
            html.Br(),
            html.Button('Open position', id='button', style={'marginBottom': 25})], style={'width': '50%', 'float': 'left'}),\
                  html.Div([html.Div(id='daemon_ouptut',
                     children='Daemon output print', style={'marginBottom': 10, 'marginTop': 15})], style={'width': '50%', 'float': 'right'})
    # tab 2 displaying active positions with possibility to add leverage or close it
    elif tab == 'tab-2':
        visualization_lib.create_csv_with_bets(rpc_connection, "open")
        df3 = pd.read_csv('betlist.csv')
        return html.Div([
            html.H5('User balance: ' +
                    str(rpc_connection.getinfo()['balance']) + " " + AC_NAME),
            dash_table.DataTable(
                id='table',
                columns=[{
                    "name": i,
                    "id": i
                } for i in df3.columns],
                data=df3.to_dict("rows"),
                sorting=True,
                row_selectable='single',
                selected_rows=[],
                style_cell={
                    'minWidth': '0px',
                    'maxWidth': '240px',
                    'whiteSpace': 'normal'
                },
                css=[{
                    'selector':
                    '.dash-cell div.dash-cell-value',
                    'rule':
                    'display: inline; white-space: inherit; overflow: inherit; text-overflow: inherit;'
                }],
                pagination_settings={
                    'current_page': 0,
                    'page_size': PAGE_SIZE,
                }),
            html.H5("Select position to add funding or close it"),
            html.Div(id='position-select-container',
                     children='',
                     style={
                         'marginBottom': 10,
                         'marginTop': 15
                     }),
            dcc.Input(placeholder='Input funding...',
                      type='text',
                      value='',
                      id='funding_text',
                      style={
                          'marginBottom': 10,
                          'marginTop': 10
                      }),
            html.Button('Add funding', id='funding-button'),
            html.Button('Cashout position',
                        id='close-button',
                        style={'marginBottom': 100}),
            html.Div(id='position-closing-output',
                     style={
                         'width': '50%',
                         'float': 'right'
                     }),
            html.Div([
                html.Div(id='daemon_ouptut2',
                         children='Daemon output print',
                         style={
                             'marginBottom': 10,
                             'marginTop': 15
                         })
            ],
                     style={
                         'width': '50%',
                         'float': 'right'
                     })
        ])
    # tab 3 displaying bet history (closed bets)
    elif tab == 'tab-3':
        visualization_lib.create_csv_with_bets(rpc_connection, "closed")
        df4 = pd.read_csv('betlist_history.csv')
        return html.Div([
            dash_table.DataTable(
                id='table_history',
                columns=[{
                    "name": i,
                    "id": i
                } for i in df4.columns],
                data=df4.to_dict("rows"),
                sorting=True,
                selected_rows=[],
                style_cell={
                    'minWidth': '0px',
                    'maxWidth': '320px',
                    'whiteSpace': 'normal'
                },
                css=[{
                    'selector':
                    '.dash-cell div.dash-cell-value',
                    'rule':
                    'display: inline; white-space: inherit; overflow: inherit; text-overflow: inherit;'
                }],
                pagination_settings={
                    'current_page': 0,
                    'page_size': PAGE_SIZE,
                })
        ])
Beispiel #2
0
from lib import tuilib, visualization_lib
from os import listdir
from os.path import isfile, join

AC_NAME = "CFEKBET1"
# connection to assetchain
rpc_connection = tuilib.def_credentials(AC_NAME)

server = flask.Flask('app')
server.secret_key = os.environ.get('secret_key', 'secret')

# pre-creating needed csv files on user side
visualization_lib.create_prices_csv(rpc_connection, "300")
visualization_lib.create_delayed_prices_csv(rpc_connection, "155")
visualization_lib.create_csv_with_bets(rpc_connection, "open")
visualization_lib.create_csv_with_bets(rpc_connection, "closed")

# pre-creating tickers for graph
pair_names = visualization_lib.get_pairs_names(rpc_connection)
options_arg = []
for pair in pair_names:
    pair_arg = {}
    pair_arg['label'] = pair
    pair_arg['value'] = pair
    options_arg.append(pair_arg)

user_args = []
graphs_files_list = [
    f for f in listdir('usergraphs') if isfile(join('usergraphs', f))
]