Esempio n. 1
0
def update_graph(selected_dropdown_value, user_dropdown_value):
    # TODO: there is a not comfortable moment: when choosing user graph in dropdown - cant back to not user one (it's because of this check)
    # so have to clear user graph selection by cross
    if user_dropdown_value is not None and "_user" in user_dropdown_value:
        df = pd.read_csv(sys.path[0] + '/usergraphs/' + user_dropdown_value)
        #print(df['pair'])
        dff = df[df['pair'] == user_dropdown_value[:-5]]
        #print(dff)
    else:
        visualization_lib.create_prices_csv(rpc_connection, "300")
        visualization_lib.create_delayed_prices_csv(rpc_connection, "155")
        df = pd.read_csv('prices.csv')
        df2 = pd.read_csv('delayed_prices.csv')
        dff = df[df['pair'] == selected_dropdown_value]
        dff2 = df2[df2['pair'] == selected_dropdown_value]
    return {
        'data': [
            {
                'x': dff.date,
                'y': dff.price1,
                'line': {
                    'width': 3,
                    'shape': 'spline'
                }
            },
            {
                'x': dff.date,
                'y': dff.price2,
                'line': {
                    'width': 3,
                    'shape': 'spline'
                }
            },
            {
                'x': dff.date,
                'y': dff.price3,
                'line': {
                    'width': 3,
                    'shape': 'spline'
                }
            },
            # {
            #     'x': dff2.date,
            #     'y': dff.price3,
            #     'line': {
            #         'width': 3,
            #         'shape': 'spline'
            #     }
            # }
        ],
        'layout': {
            'margin': {
                'l': 30,
                'r': 20,
                'b': 30,
                #'t': 20
            },
            'title': 'Prices provided by Komodo PricesCC trustless oracle'
        }
    }
Esempio n. 2
0
import os, sys

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))