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

您現在的位置:程序化交易>> 期貨公式>> 交易開拓者(TB)>> 開拓者知識>>正文內容

請問這個策略有偷價或者未來函數行為嗎?回測效果很好 [開拓者 TB]

  • 咨詢內容: 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')

        #過去六個月的價格變化率
        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技術人員: 你這個代碼都不是TB的,怎么回測的?

     

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

    這里也有人用python

 

有思路,想編寫各種指標公式,程序化交易模型,選股公式,預警公式的朋友

可聯系技術人員 QQ: 511411198  點擊這里給我發消息進行 有償 編寫!不貴!點擊查看價格!


【字體: 】【打印文章】【查看評論

相關文章

    沒有相關內容
主站蜘蛛池模板: 91国自产精品中文字幕亚洲 | 丁香六月 久久久 | 精品久久久久久中文字幕202o | 国产免费爽爽视频免费可以看 | 怡红院美国十次成人影院 | 噜噜噜噜天天狠狠 | 成人精品一区二区www | 免费又黄又硬又大爽日本 | 欧美成人精品免费播放 | 国产精品成人观看视频国产奇米 | 欧美日韩在线观看精品 | 免费国产成人高清在线观看麻豆 | 一级黄色片片 | 婷婷亚洲综合五月天在线 | 精品午夜一区二区三区在线观看 | 欧美视频一区二区三区在线观看 | 亚洲欧美人成网站综合在线 | 日日噜噜夜夜狠狠久久丁香七 | 国产又色又爽又黄 | 1024手机在线播放 | 在线亚洲精品国产成人二区 | 看免费毛片天天看 | 看黄网站在线播放 | 欧美成在线观看 | 视色视色| 午夜私人影院在线观看 视频 | 午夜影院男女 | 亚洲无线码一区二区三区 | 亚洲精品午夜 | 香蕉一级视频 | 精品在线视频播放 | 国产福利麻豆精品一区 | 亚洲黄色免费观看 | 国产成人综合日韩精品无 | 欧美变态口味重另类牲 | 成人观看免费大片在线观看 | 国产三级网站 | 精品国产一区二区三区麻豆小说 | 日韩1页| 高清中文字幕免费观在线 | 亚洲国产三级 |