def main():
    form=cgi.FieldStorage()
    username = None    

    if form.getvalue("user_name") != None:
        username=form.getvalue("user_name")

    adao=Algorithms_dao()
    lst = adao.select_all_algorithms(username)
    
    d = {}
    d['User'] = {}
    d['User'] = 0
    d['All'] = {}
    d['All'] = 1
    d['Algorithms'] = {}
    d['Algorithms'] = 2

    if lst:
        for i in range(len(lst)):
            d[lst[i].get_algo_name()] = {}
            d[lst[i].get_algo_name()] = int(lst[i].get_algo_id()) 

    print json.dumps(d)
from history_dao import History_dao
from company_dao import Company_dao
from algorithms_dao import Algorithms_dao
from transaction_dao import Transaction_dao

print "Content-Type: text/html\r\n\r\n"

form = cgi.FieldStorage()

if form.getvalue("username") != None:
    username = form.getvalue("username")
#username='******'

hdao = History_dao()
cdao = Company_dao()
adao = Algorithms_dao()
tdao = Transaction_dao()
result = []
profit = 0
stock_model_dict = {}
stock_ask_dict = {}
volume_dict = {}
distinct_stocks = hdao.get_distinct_traded_stocks(username)
algorithm_details_list = hdao.get_algorithm_buy_sell_volume(
    username
)  #len(result) =  number of algo_ids list of algorithm details models
symbols_string = ""

if distinct_stocks:
    for i in range(len(distinct_stocks)):
        symbols_string += "'" + distinct_stocks[i].get_name() + "',"
Exemplo n.º 3
0
#!/usr/bin/python

import cgi, datetime, sys, LINK_HEADERS
import simplejson as json
from decimal import *
sys.path.insert(0, str(LINK_HEADERS.DAO_LINK))
from algorithms_dao import Algorithms_dao

print "Content-Type: text/html\r\n\r\n"

form = cgi.FieldStorage()

a = Algorithms_dao()

if form.getvalue("user_name") != None:
    username = form.getvalue("user_name")


def main():
    d = {}
    d['User'] = {}
    d['User'] = 0
    d['All'] = {}
    d['All'] = 1
    d['Algorithms'] = {}
    d['Algorithms'] = 2

    lst = a.select_all_algorithms(username)

    if lst:
        for i in range(len(lst)):
from history_dao import History_dao
from company_dao import Company_dao
from algorithms_dao import Algorithms_dao
from transaction_dao import Transaction_dao

print "Content-Type: text/html\r\n\r\n"

form = cgi.FieldStorage()

if form.getvalue("username") != None:
    username = form.getvalue("username")
#username='******'

hdao = History_dao()
cdao = Company_dao()
adao = Algorithms_dao()
tdao = Transaction_dao() 
result=[]
profit=0
stock_model_dict={}
stock_ask_dict={}    
volume_dict={}
distinct_stocks=hdao.get_distinct_traded_stocks(username)
algorithm_details_list = hdao.get_algorithm_buy_sell_volume(username) #len(result) =  number of algo_ids list of algorithm details models
symbols_string=""

if distinct_stocks:
    for i in range(len(distinct_stocks)):
        symbols_string+="'" + distinct_stocks[i].get_name() + "',"
    symbols_string=symbols_string[:-1]
    stock_ask=cdao.get_ask_comp(symbols_string) #list of company models
Exemplo n.º 5
0
#!/usr/bin/python

import cgi, datetime, sys, LINK_HEADERS
import simplejson as json
sys.path.insert(0, str(LINK_HEADERS.DAO_LINK))
#from transaction_dao import Transaction_dao
from history_dao import History_dao
from algorithms_dao import Algorithms_dao

hdao = History_dao()
adao = Algorithms_dao()

print "Content-Type: text/html\r\n\r\n"


def get_all(username):
    result = hdao.get_all_volume_per_day(username)
    lst = []
    if result:
        for day in result:
            lst.append([day.get_date(), day.get_volume()])
        return {"name": "All", "data": lst}
    return False


def get_all_algos(username):
    result = hdao.get_all_algorithms_volume_per_day(username)
    lst = []
    if result:
        for day in result:
            lst.append([day.get_date(), day.get_volume()])