Esempio n. 1
0
def use_ma(dss):
    dates = get_trading_dates(dss)
    preday = dates[-2]
    today = dates[-1]
    print(today)
    #pfFile = dss + 'csv/hold.csv'
    b1 = Book(dss)

    codes = []
    for tactic in b1.tactic_List:
        if tactic.tacticName == 'boll':
            for hold in tactic.hold_Array:
                code = hold[0]
                codes.append(code)

    codes += hit_ma(dss, today)

    r = []
    symbols = set(codes)
    print(symbols)
    for vtSymbol in symbols:
        df = ts.get_realtime_quotes(vtSymbol)
        name = df.at[0, 'name']
        r.append([vtSymbol, 1, 0.01, '0.00003', 0, 0.01, name])
    df = pd.DataFrame(r,
                      columns=[
                          'vtSymbol', 'size', 'priceTick',
                          'variableCommission', 'fixedCommission', 'slippage',
                          'name'
                      ])
    filename = dss + 'csv/setting_stk_boll' + '.csv'
    df.to_csv(filename, index=False)

    return r
Esempio n. 2
0
def signal_run(dss):
    all_dates = get_trading_dates(dss)
    date = all_dates[-1]

    #print(codes)
    r1 = calc_signal_buy(dss, date)
    r2 = calc_signal_sell(dss, date)
    df = pd.DataFrame(r1 + r2, columns=['date', 'code', 'stratege'])
    filename = dss + 'csv/signal_macd.csv'
    df.to_csv(filename, index=False, mode='a', header=None)
    return r1 + r2
Esempio n. 3
0
def up_run(dss):
    all_dates = get_trading_dates(dss)
    begin_date = all_dates[-1]
    end_date = all_dates[-1]

    begin_date = '2019-06-26'
    end_date = '2019-06-28'

    codes = get_stk_codes(dss)

    # codes = ['002454','300433','002570','300136','002273','300073']
    #print(codes)
    r = signal_k_pattern(dss, codes, begin_date, end_date)
    df = pd.DataFrame(r, columns=['date', 'code', 'strategy', 'expire'])
    #filename = dss + 'csv/bottle.csv'
    filename = 'a1.csv'
    df.to_csv(filename, index=False, mode='a', header=None)
Esempio n. 4
0
def run_price_signal():
    try:
        now = datetime.datetime.now()
        weekday = int(now.strftime('%w'))
        if 2 <= weekday <= 6:
            dates = get_trading_dates(dss)
            today = dates[-1]
            arr = price_signal(dss, today)
            r = []
            for a in arr:
                r.append(str(a))
            #print(str(r))
            send_email(dss, 'price_signal', '\n'.join(r))

    except Exception as e:
        s = traceback.format_exc()
        to_log(s)
Esempio n. 5
0
def down_daily_run(dss):
    listfile = os.listdir(dss + 'daily')
    listfile.sort(reverse=True)

    lastday = listfile[0][:10]
    print(lastday)
    dates = get_trading_dates(dss, lastday)
    dates.pop(0)  #担心daily数据更新不及时
    #dates = ['2019-04-01']

    for today in dates:
        fss = dss + 'daily/' + today + '_stk_all.csv'
        try:
            if os.path.exists(fss):
                print('exist', today)
            else:
                df = ts.get_day_all(today)
                df.to_csv(fss, index=False, encoding='gbk')
                print('got ', today)
        except:
            print('error ', today)
Esempio n. 6
0
    r = []
    for i, row in df1.iterrows():
        # print(row.code, row['name'], row.p_change)
        if be_bottom(row.code, day):
            df2 = pro.concept_detail(ts_code=get_ts_code(row.code))
            concept = str(df2.concept_name.tolist())
            r.append([day, row.code, row['name'], row.p_change, concept])

            # 拷贝数据文件到下载目录,以备下载。windows下一定要用\\
            ins = 'copy ' + get_dss(
            ) + 'hfq\\' + row.code + '.csv ' + 'C:\\Users\\Administrator\\Downloads\\' + row.code + '_' + row[
                'name'] + '.csv '
            print(ins)
            os.system(ins)
        #break
    df = pd.DataFrame(r, columns=['date', 'code', 'name', 'change', 'concept'])
    fn = get_dss() + 'csv/price_signal.csv'
    df.to_csv(fn, index=False, mode='a')

    return r


if __name__ == '__main__':
    dates = get_trading_dates(get_dss())
    #preday = dates[-2]
    today = dates[-1]
    print(today)
    r = price_signal(get_dss(), today)
    print(r)