Ejemplo n.º 1
0
import tushare as ts
import tradeTime as tt
import time

#remain_time_to_trade=tt.get_remain_time_to_trade()
#print(remain_time_to_trade)
interval = 60
is_fist_run = True
while True:
    #"""
    remain_time_to_trade = tt.get_remain_time_to_trade()
    if remain_time_to_trade >= interval:
        time.sleep(remain_time_to_trade)
    else:
        if is_fist_run:
            time.sleep(60 - time.time() % 60)
            is_fist_run = False
        else:
            print(time.ctime())
            try:
                df = ts.get_today_all()
            except:
                continue
            print(df)
            if df.empty:
                time.sleep(interval)
                continue
            df_1 = df[(df.trade < df.open * 0.995) & (df.changepercent > 1.5) &
                      (df.high < df.settlement * 1.1)]
            print(df_1)
            print(time.ctime())
Ejemplo n.º 2
0
import tushare as ts
import tradeTime as tt
import time


#remain_time_to_trade=tt.get_remain_time_to_trade()
#print(remain_time_to_trade)
interval=60
is_fist_run=True
while True:
    #"""
    remain_time_to_trade=tt.get_remain_time_to_trade()
    if remain_time_to_trade>=interval:
        time.sleep(remain_time_to_trade)
    else:
        if is_fist_run:
            time.sleep(60-time.time()%60)
            is_fist_run=False
        else:
            print(time.ctime())
            try:
                df=ts.get_today_all()
            except:
                continue
            print(df)
            if df.empty:
                time.sleep(interval)
                continue
            df_1=df[(df.trade<df.open*0.995) & (df.changepercent>1.5) & (df.high<df.settlement*1.1)]
            print(df_1)
            print(time.ctime())
Ejemplo n.º 3
0
                    """更新指数csv数据"""
                    pds.update_codes_from_YH(
                        indexs=["sh", "sz", "zxb", "cyb", "hs300", "sh50"],
                        realtime_update=False,
                        dest_dir="C:/hist/day/data/",
                        force_update_from_YH=True,
                    )
                    print("update count %s at: " % updated_date_count, datetime.datetime.now())
                    """历史数据回测"""
                    mybt.back_test(k_num=date_str, given_codes=[], except_stocks=except_stock, type="stock")
                    mybt.back_test(
                        k_num=date_str, given_codes=["sh", "sz", "zxb", "cyb", "hs300", "sh50"], type="index"
                    )
                    """更新持仓信息到数据库"""
                    # stock_sql.update_sql_position(users={'36005':{'broker':'yh','json':'yh.json'},'38736':{'broker':'yh','json':'yh1.json'}})
                    stock_sql.update_sql_position(users={"account": "36005", "broker": "yh", "json": "yh.json"})
                    stock_sql.update_sql_position(users={"account": "38736", "broker": "yh", "json": "yh1.json"})
                    """更新指数历史数据到数据库"""
                    stock_sql.update_sql_index(
                        index_list=["sh", "sz", "zxb", "cyb", "hs300", "sh50"], force_update=False
                    )
                    sleep_seconds = tt.get_remain_time_to_trade()
                else:
                    pass
                    # sleep_seconds = tt.get_remain_time_to_trade()
        else:
            sleep_seconds = tt.get_remain_time_to_trade()
        print("Going to sleep %s seconds." % sleep_seconds)
        time.sleep(sleep_seconds)
        print("Slept %s seconds." % sleep_seconds)
Ejemplo n.º 4
0
                                   given_codes=[
                                       'sh', 'sz', 'zxb', 'cyb', 'hs300',
                                       'sh50'
                                   ],
                                   type='index')
                    """更新持仓信息到数据库"""
                    #stock_sql.update_sql_position(users={'36005':{'broker':'yh','json':'yh.json'},'38736':{'broker':'yh','json':'yh1.json'}})
                    stock_sql.update_sql_position(users={
                        'account': '36005',
                        'broker': 'yh',
                        'json': 'yh.json'
                    })
                    stock_sql.update_sql_position(users={
                        'account': '38736',
                        'broker': 'yh',
                        'json': 'yh1.json'
                    })
                    """更新指数历史数据到数据库"""
                    stock_sql.update_sql_index(
                        index_list=['sh', 'sz', 'zxb', 'cyb', 'hs300', 'sh50'],
                        force_update=False)
                    sleep_seconds = tt.get_remain_time_to_trade()
                else:
                    pass
                    #sleep_seconds = tt.get_remain_time_to_trade()
        else:
            sleep_seconds = tt.get_remain_time_to_trade()
        print('Going to sleep %s seconds.' % sleep_seconds)
        time.sleep(sleep_seconds)
        print('Slept %s seconds.' % sleep_seconds)