大伊人青草狠狠久久-大伊香蕉精品视频在线-大伊香蕉精品一区视频在线-大伊香蕉在线精品不卡视频-大伊香蕉在线精品视频75-大伊香蕉在线精品视频人碰人

您現在的位置:程序化交易>> 期貨公式>> 交易開拓者(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  點擊這里給我發消息進行 有償 編寫!不貴!點擊查看價格!


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

相關文章

    沒有相關內容
主站蜘蛛池模板: 欧美日韩三级 | 久久99精品久久久久久水蜜桃 | 毛片天天看| 一二三区无线码2021 | 成人亚洲欧美日韩中文字幕 | 亚洲国产日韩在线一区 | 国产成人综合亚洲动漫在线 | 看日本黄色录像 | 韩国女主播一区二区三区视频 | 欧美 日本 国产 | 狠狠狠地啪香蕉 | 亚洲精品美女久久久久 | 免费一区二区三区免费视频 | 亚洲视频免费在线看 | 一本久道热中字伊人 | 青青青国产在线 | 国产综合另类小说色区色噜噜 | 成人国产视频在线观看 | 天天干天天爱天天操 | 成人免费视频在线观看 | 亚洲+自拍+色综合图区一 | 久久精品久久精品 | 久久天天躁狠狠躁夜夜躁 | 欧美另类亚洲 | 在线看日本a毛片 | 日本毛片网 | 久久青草精品一区二区三区 | 伊人第一页 | 久久成年视频 | 国产一区二区三区成人久久片 | 婷婷综合激情 | 色综合五月婷婷 | 成 人 a v免费视频 | 亚洲精品视频在线观看免费 | 婷婷在线视频 | 亚洲精品久久久久久下一站 | 99国产精品九九视频免费看 | 羞羞视频免费在线观看 | 99国产精品久久久久久久成人热 | 国产一级成人毛片 | 精品免费在线视频 |