Beispiel #1
0
def show_stats():
    from get_currency_info import get_24, find_actives

    ticker = request.form['ticker']

    if ticker.upper() in find_actives():
        mean, stdev, min, max = get_24(ticker)
        return jsonify(stdev=stdev, mean=mean, min=min, max=max)

    else:
        return jsonify(mean='Ticker not found', stdev='', min='', max='')
Beispiel #2
0
def show_graph():
    from plotly.offline import plot
    from get_currency_info import make_chart, find_actives

    ticker = request.args.get('ticker')

    if ticker != None:
        if ticker.upper() in find_actives():
            data = make_chart(ticker)
            my_plot = plot(data, output_type="div", show_link=False)

        else:
            my_plot = 'Ticker not found'
    else:
        my_plot = 'Ticker not found'
    return render_template('graph.html', my_plot=my_plot)
Beispiel #3
0
def trade():
    from get_currency_info import find_actives
    ticker_list = [
        '<option value="{}"></option>'.format(ticker)
        for ticker in find_actives()
    ]

    #all currencies that didn't cause problems with algorith
    good_list = ['BTC', 'DASH', 'ETH', 'LTC', 'NXT', 'SC', 'XMR', 'XRP']

    cb_string = '<input type = "checkbox" name = "optimize" value="{0}">{0}<br>'
    opt_list = [cb_string.format(ticker) for ticker in good_list]

    return render_template('trade.html',
                           ticker_list=ticker_list,
                           opt_list=opt_list)
def preview_trade():
    from get_currency_info import get_current, find_actives
    
    ticker = request.form['ticker']
    trade_type = request.form['type']
    shares = request.form['shares']
    
    if ticker.upper() in find_actives():
        cur = get_current(ticker, trade_type)
        if test_inputs(cur, shares):
            cur_format = "${:,.2f}".format(cur)
            tot = cur * float(shares)
            tot_format = "${:,.2f}".format(tot)
            return (jsonify(current = cur_format, total = tot_format))
        else:
            return jsonify(current = 'Problem with order size or ticker', total = '') 
    
    else:
        return jsonify(current = 'Ticker not found', total = '')
def executeTrade():
    from get_currency_info import get_current, find_actives
    
    ticker = request.form['ticker'].upper()
    trade_type = request.form['type']
    shares = request.form['shares']
    
    if ticker in find_actives(): #test front end input
        price = get_current(ticker, trade_type)
        if test_inputs(price, shares): #test front end input
            account.evalTransaction(trade_type, float(shares), price, ticker, my_db, my_pl, my_blotter)
            if account.message == 'Success': #test business logic
                return jsonify(message = 'Order Success! {}@${:,.2f}'.format(ticker, price))
            
            else: 
                return(jsonify(message = account.message))
        else:
            return jsonify(message = 'Problem with order size or ticker') 
            
    else:
        return(jsonify(message = 'Ticker not found'))
def trade():
    from get_currency_info import find_actives
    ticker_list = ['<option value="{}"></option>'.format(ticker) for ticker in find_actives()]
    return render_template('trade.html', ticker_list = ticker_list)