人人爽天天爽夜夜爽qc-人人爽天天爽夜夜爽曰-人人天天爱天天做天天摸-人人天天夜夜-色网站在线-色网站在线看

您現(xiàn)在的位置:程序化交易>> 期貨公式>> 交易開(kāi)拓者(TB)>> 開(kāi)拓者知識(shí)>>正文內(nèi)容

請(qǐng)問(wèn)這個(gè)策略有偷價(jià)或者未來(lái)函數(shù)行為嗎?回測(cè)效果很好 [開(kāi)拓者 TB]

  • 咨詢(xún)內(nèi)容: import pandas as pd
    import numpy as np

    def init(context):
        context.s1 = '000001.XSHG'
        context.max_num_stocks = 40
        context.days = 0
        context.period_days = 1
        context.relative_strength_6m = {}

    def period_passed(context):
        return context.days % context.period_days == 0
       
    def before_trading(context):
        context.days += 1
        if not period_passed(context):
            return
       
        dofilter(context)
        update_universe(context.fundamental_df.columns.values)

    def dofilter(context):
       
        fundamental_df = get_fundamentals(
            query(fundamentals.eod_derivative_indicator.market_cap)
            .order_by(fundamentals.eod_derivative_indicator.market_cap.asc())
            .limit(context.max_num_stocks)
        )
       
        #Update context
        context.stocks = [stock for stock in fundamental_df]
        context.fundamental_df = fundamental_df
       
    def rebalance(context, bar_dict):
       
        for stock in context.portfolio.positions:
            if stock not in context.fundamental_df:
                order_target_percent(stock, 0)
                
        context.stocks = [stock for stock in context.stocks
                          if stock in bar_dict and bar_dict[stock].is_trading and context.relative_strength_6m[stock] <-0.5]
       
        if len(context.stocks) == 0:
            return
       
        weight = 1.0/len(context.stocks)
       
        for stock in context.stocks:
            order_target_percent(stock, weight)
       
    def handle_bar(context, bar_dict):
       
        his = history(10, '1d', 'close')['000001.XSHG']
       
        if period_passed(context):
            if his[9]/his[8]< 0.97:
                if len(context.portfolio.positions)>0:
                    for stock in context.portfolio.positions.keys():
                        order_target_percent(stock, 0)
                return
       
        if not period_passed(context):
            return
       
        compute_relative_strength(context,bar_dict)
        rebalance(context, bar_dict)
       
    def compute_relative_strength(context,bar_dict):
       
        prices = history (150, '1d', 'close')

        #過(guò)去六個(gè)月的價(jià)格變化率
        pct_change = (prices.ix[149] - prices.ix[19]) / prices.ix[19]
        #print(prices.ix[19])
        #print(pct_change)
        priceofbase = history (150, '1d', 'close')[context.s1]
        pct_changeforbase = (priceofbase.ix[149] - priceofbase.ix[19]) / priceofbase.ix[19]
        pct_change = pct_change - pct_changeforbase
        print(pct_change.index)
        print(bar_dict)
        if pct_changeforbase != 0:
            pct_change = pct_change / abs(pct_changeforbase)
        context.relative_strength_6m = pct_change

     

  • TB技術(shù)人員: 你這個(gè)代碼都不是TB的,怎么回測(cè)的?

     

  • TB客服: 本帖最后由 bahuang 于 2016-2-26 08:40 編輯

    這里也有人用python

 

有思路,想編寫(xiě)各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友

可聯(lián)系技術(shù)人員 QQ: 511411198  點(diǎn)擊這里給我發(fā)消息進(jìn)行 有償 編寫(xiě)!不貴!點(diǎn)擊查看價(jià)格!


【字體: 】【打印文章】【查看評(píng)論

相關(guān)文章

    沒(méi)有相關(guān)內(nèi)容
主站蜘蛛池模板: 成 人 免 费 黄 色 | 日韩伦理中文字幕 | 午夜免费观看_视频在线观看 | 好吊色青青青国产在线播放 | 羞羞羞网站 | 欧美日皮| 高清色黄毛片一级毛片 | 欧美人成片免费看视频不卡 | 国产在线精品一区二区不卡 | 日韩欧美综合在线二区三区 | 最近中文字幕完整国语 | 男人趴在女人身上曰皮免费 | 波多野结衣视频一区二区 | 成人午夜免费视频免费看 | 亚洲视频免 | 亚洲日本中文字幕天堂网 | 成人a毛片高清视频 | 亚洲成年人网址 | 国产在线麻豆波多野结衣 | www久久只有这里有精品 | 欧美成人精品在线 | 久久天天躁夜夜躁狠狠85台湾 | 国产91精品久久久久999 | 精品色综合 | 青青草国产97免久久费观看 | 亚洲天堂aa | 国产精品视频二区不卡 | 久久77| 视频一区二区欧美日韩在线 | tom影院亚洲国产一区二区 | 黄a一级| 欧美亚洲综合另类 | 国产碰碰 | 免费国产高清精品一区在线 | 日韩天天摸天天澡天天爽视频 | 免费九九视频 | 久久久精品视频直接观看 | 国产视频福利 | 日日干日日插 | 一级毛片www | 在线www|