コード例 #1
0
ファイル: app.py プロジェクト: hanbinggary/flask_easytrader
def getminline(stockno):
    
    conn = sqlite3API.get_conn('stock.db')
    sql_tid='select dataTime,lastPrice from t_399006 limit 100'
   
    info_tid=sqlite3API.fetchmany(conn,sql_tid)
    
    info_tid=sqlite3API.fetchmany(conn,sql_tid)
    info_x = []
    info_y = []
    
    for info in info_tid:
        info_x.append(info[0])
        info_y.append(info[1])
    
    return str({"x":info_x,"y":info_y})
コード例 #2
0
def getAllPositionFromSqlite():

    conn = sqlite3API.get_conn('stock.db')

    sql_tid = '''
        select mairu_dongjie,jiaoyi_shichang,maichu_dongjie,shijia,shizhi,chengbenjia,yingkui,tangqian_chicang,yingkui_bili,gudong_daima,gufen_yue,gufen_keyong,code,name from chicang ;
        '''
    info_tid = sqlite3API.fetchmany(conn, sql_tid)
    #    print(info_tid)
    list_dic = []
    #    dic = dict()
    for info_temp in info_tid:
        temp_item = {
            '买入冻结': info_temp[0],
            '交易市场': info_temp[1],
            '卖出冻结': info_temp[2],
            '参考市价': info_temp[3],
            '参考市值': info_temp[4],
            '参考成本价': info_temp[5],
            '参考盈亏': info_temp[6],
            '当前持仓': info_temp[7],
            '盈亏比例(%)': info_temp[8],
            '股东代码': info_temp[9],
            '股份余额': info_temp[10],
            '股份可用': info_temp[11],
            '证券代码': info_temp[12],
            '证券名称': info_temp[13]
        }
        #        dic[info_temp[12]]=temp_item
        #        print(temp_item)
        list_dic.append(temp_item)
    return list_dic
コード例 #3
0
def checkTraderNone(code_position):
    conn = sqlite3API.get_conn('stock.db')

    sql_tid = '''
        select gufen_keyong from chicang where code = '%s';
        '''
    info_tid = sqlite3API.fetchmany(conn, sql_tid % code_position)
    if info_tid and info_tid[0][0] > 0:
        return True
    else:
        return False
コード例 #4
0
def checkFadingJiari(str_time=str(datetime.datetime.now())[:10]):
    conn = sqlite3API.get_conn('stock.db')

    sql_tid = '''
        select isOpen from trade_calender where calendarDate = '%s';
        '''
    info_tid = sqlite3API.fetchmany(conn, sql_tid % str_time)
    if info_tid and info_tid[0][0] == 1:
        return True
    else:
        return False
コード例 #5
0
def getKeyongGufen(code):
    conn = sqlite3API.get_conn('stock.db')

    sql_tid = '''
        select gufen_keyong from chicang 
        where code = '%s' ;
        '''
    info_tid = sqlite3API.fetchmany(conn, sql_tid % code)
    if info_tid and len(info_tid) > 0:
        return info_tid[0][0]
    else:
        return 0
コード例 #6
0
def checkExistsCode(code):
    conn = sqlite3API.get_conn('stock.db')

    sql_tid = '''
        select code from chicang 
        where code = '%s' ;
        '''
    info_tid = sqlite3API.fetchmany(conn, sql_tid % code)
    if info_tid and len(info_tid) > 0:
        return True
    else:
        return False
コード例 #7
0
def bisi_reply_mulit(userid='marx88', total=1):

    #    mysql = mysqlAPI('test')
    #    info_tid = mysql.select_mysql('select id from bisi_discuz where reply_num > 40 order by RAND() limit ' + str(total))
    #    info_content = mysql.select_mysql('select content from reply_content order by RAND() limit ' + str(total*3))
    #    mysql.close_mysql()

    sql_tid = 'select id,title from bisi_discuz where reply_num > 10 order by RANDOM() limit ' + str(
        total)
    sql_content = 'select content from reply_content order by RANDOM() limit ' + str(
        total * 3)

    conn = sqlite3API.get_conn(DB_FILE_PATH)
    info_tid = sqlite3API.fetchmany(conn, sql_tid)
    info_content = sqlite3API.fetchmany(conn, sql_content)
    data = userid
    info_user = sqlite3API.fetchone(
        conn, "select url,user,password from master where user=?", data)
    url = info_user[0]
    user = info_user[1]
    password = info_user[2]
    #    print (password)
    discuz = DiscuzAPI(url, user, password)
    discuz.login()
    discuz.sign()
    #访问他人空间得2金钱
    discuz.access()
    #发记录
    discuz.speak(msg=str(random.randint(0, 10000)))

    total = len(info_content)

    for tid in info_tid:
        #        print(info_content[random.randint(0,total-1)][0])
        msg = info_content[random.randint(0, total - 1)][0]
        try:
            discuz.reply(tid[0], msg='%s,%s' % (tid[1], msg))
        except:
            pass
        time.sleep(random.randint(65, 70))
コード例 #8
0
def selectSqliteTest():
    conn = sqlite3API.get_conn('stock.db')
    sql_tid = 'select dataTime,lastPrice from t_399006 limit 100'

    info_tid = sqlite3API.fetchmany(conn, sql_tid)
    info_x = []
    info_y = []

    for info in info_tid:
        info_x.append(info[0])
        info_y.append(info[1])

    print(info_x, info_y)
コード例 #9
0
def getCixinCode():
    conn = sqlite3API.get_conn('stock.db')

    sql_tid = '''
        select code from stock_info 
        where substr(stock_info.timeToMarket,1,4) || '-' || substr(stock_info.timeToMarket,5,2) || '-' || substr(stock_info.timeToMarket,7,2) > date('now','-300 days') 
        --and substr(code,1,1) != '3' ;
        '''
    info_tid = sqlite3API.fetchmany(conn, sql_tid)
    stock_list = []
    for info_temp in info_tid:
        stock_list.append(info_temp[0])

    return stock_list
コード例 #10
0
def getPositionHuatai():

    conn = sqlite3API.get_conn('stock.db')

    sql_tid='''
        select * from position ;
        '''
    info_tid=sqlite3API.fetchmany(conn,sql_tid)
    
    dic = dict()

    for info_temp in info_tid:
        dic[info_temp[0]] = [info_temp[1],info_temp[2],info_temp[3],info_temp[4],info_temp[5]]

    return dic
コード例 #11
0
def getPosition():

    conn = sqlite3API.get_conn('stock.db')

    sql_tid = '''
        select code,gufen_keyong from chicang ;
        '''
    info_tid = sqlite3API.fetchmany(conn, sql_tid)
    #    print(info_tid)
    dic = dict()
    stock_list = []
    for info_temp in info_tid:
        dic[info_temp[0]] = str(info_temp[1])
        stock_list.append(info_temp[0])
#    print('OK' if '6013192' in dic.keys() else '')
#    print(dic.keys())
    return dic
コード例 #12
0
def test_sqlite():

    stock_list = [
        '002858', '603041', '002857', '603388', '603178', '002816', '603031',
        '603701', '603991', '002806', '603319', '002796', '603090', '603038',
        '603990', '603029', '002800', '603908', '002810', '002837', '002835',
        '603738', '002805', '603960', '603266', '603037', '603819', '603633',
        '603887', '002856', '603033', '603663', '002830', '603637', '603089',
        '603032', '002808'
    ]
    conn = sqlite3API.get_conn('stock.db')
    sql_tid = "select code,timeToMarket from stock_info where code in ('" + "','".join(
        stock_list) + "')"
    info_tid = sqlite3API.fetchmany(conn, sql_tid)
    print(type(info_tid))
    print(info_tid)
    dic = dict()
    for info_temp in info_tid:
        dic[info_temp[0]] = info_temp[1]
    print(dic)
コード例 #13
0
def gettimeToMarket():

    conn = sqlite3API.get_conn('stock.db')
    #sql_tid ="select code,timeToMarket from stock_info where code in ('" + "','".join(stock_list) + "')"
    sql_tid = '''
        select stock_info.code,stock_info.timeToMarket from liutong_from_qq 
        inner join stock_info on
        liutong_from_qq.code = stock_info.code
        where liutong_from_qq.liutong<13 and substr(liutong_from_qq.code,1,1) != '3' 
        and substr(stock_info.timeToMarket,1,4) || '-' || substr(stock_info.timeToMarket,5,2) || '-' || substr(stock_info.timeToMarket,7,2) > date('now','-270 days')
        order by liutong_from_qq.liutong 
        limit 40;
        '''
    info_tid = sqlite3API.fetchmany(conn, sql_tid)
    dic = dict()
    stock_list = []
    for info_temp in info_tid:
        dic[info_temp[0]] = str(info_temp[1])
        stock_list.append(info_temp[0])

    return dic, stock_list
コード例 #14
0
def getPositionHistory():

    conn = sqlite3API.get_conn('stock.db')

    sql_tid='''
        select * from position_history ;
        '''
    info_tid=sqlite3API.fetchmany(conn,sql_tid)
    
    dic = dict()

    for info_temp in info_tid:
        dic[info_temp[0]] = [info_temp[1],info_temp[2],info_temp[3],info_temp[4],info_temp[5],info_temp[6]]
        dic[info_temp[0]] = {
            'name':info_temp[1],
            'num':info_temp[2],
            'start_price':info_temp[3],
            'start_time':info_temp[4],
            'end_price':info_temp[5],
            'end_time':info_temp[6],
            'bizhong':info_temp[7]
        }
    return dic