diff --git "a/347円254円25410円347円253円240円357円274円232円Ricequant345円233円236円346円265円213円351円200円211円350円202円241円345円210円206円346円236円220円345円256円236円346円210円230円/1_simple_demo.txt" "b/347円254円25410円347円253円240円357円274円232円Ricequant345円233円236円346円265円213円351円200円211円350円202円241円345円210円206円346円236円220円345円256円236円346円210円230円/1_simple_demo.py" similarity index 60% rename from "347円254円25410円347円253円240円357円274円232円Ricequant345円233円236円346円265円213円351円200円211円350円202円241円345円210円206円346円236円220円345円256円236円346円210円230円/1_simple_demo.txt" rename to "347円254円25410円347円253円240円357円274円232円Ricequant345円233円236円346円265円213円351円200円211円350円202円241円345円210円206円346円236円220円345円256円236円346円210円230円/1_simple_demo.py" index 094d811..96279e8 100644 --- "a/347円254円25410円347円253円240円357円274円232円Ricequant345円233円236円346円265円213円351円200円211円350円202円241円345円210円206円346円236円220円345円256円236円346円210円230円/1_simple_demo.txt" +++ "b/347円254円25410円347円253円240円357円274円232円Ricequant345円233円236円346円265円213円351円200円211円350円202円241円345円210円206円346円236円220円345円256円236円346円210円230円/1_simple_demo.py" @@ -1,14 +1,14 @@ -# 辛參徭失import厘断峠岬屶隔議及眉圭python庁翠?曳泌pandas、numpy吉。 +# ?櫆札???訓import???篁サ抗?佀?壩?????膃コ?????python罔≦??鐚?罸?絋?pandas???numpy膈???? -# 壓宸倖圭隈嶄園亟販採議兜兵晒貸辞。context斤嵆繍氏壓低議麻隈貨待議販採圭隈岻寂恂勧弓。 +# ?????筝??号??筝下?????篁私????????紮??????肢?????context絲壕院絨?篌????篏????膊?羈?膈???ョ??篁私????号??箙???翫??篌??????? def init(context): - # 壓context嶄隠贋畠蕉延楚 - context.hs300 = index_components("殺侮300") + # ???context筝TEL??絖????絮??????? + context.hs300 = index_components("羃?訓300") scheduler.run_monthly(filter_data,tradingday=1) - # 糞扮嬉咫晩崗 + # 絎???倶????井?ュ?? # logger.info("RunInfo: {}".format(context.run_info)) -# before_trading緩痕方氏壓耽爺貨待住叟蝕兵念瓜距喘?輝爺峪氏瓜距喘匯肝 +# before_trading罩ゅ?醇?遺?????罸鎀ñ????ヤ困???綣?紮????茴?????Ǎ??綵?紊ïÜ??茴??????筝?罨? def before_trading(context): """ context.fundamentals_df = get_fundamentals(query( @@ -38,16 +38,16 @@ def filter_data(context, bar_dict): context.hs300_10 = context.fundamentals_df.T.index -# 低僉夲議屬発議方象厚仟繍氏乾窟緩粁貸辞?箭泌晩賜蛍嶝煽雰方象俳頭賜宀頁糞扮方象俳頭厚仟 +# 篏??????ñ??莚???悟????井?勖?贋?医??篌?茹???罩ゆ侊??肢??鐚?箴?絋???ユ????????????兊?井????????????????????倶?井?????????贋?? def handle_bar(context, bar_dict): - # 蝕兵園亟低議麼勣議麻隈貸辞 + # 綣?紮?膽????篏????筝肢?????膊?羈???肢?? - # bar_dict[order_book_id] 辛參鎮欺蝶倖屬発議bar佚連 - # context.portfolio 辛參鎮欺孖壓議誘彿怏栽佚連 + # bar_dict[order_book_id] ?櫆札??水?井??筝?????悟??bar篆≧?? + # context.portfolio ?櫆札??水?亥ー????????莎?膸????篆≧?? - # 聞喘order_shares(id_or_ins, amount)圭隈序佩鯛汽 + # 篏睡??order_shares(id_or_ins, amount)??号??菴?茵???遵?? - # TODO: 蝕兵園亟低議麻隈杏? + # TODO: 綣?紮?膽????篏????膊?羈???э?? # order_shares(context.s1, 1000) if len(context.portfolio.positions.keys()) !=0 : for stock in context.portfolio.positions.keys(): @@ -59,6 +59,6 @@ def handle_bar(context, bar_dict): -# after_trading痕方氏壓耽爺住叟潤崩朔瓜距喘?輝爺峪氏瓜距喘匯肝 +# after_trading??醇?遺?????罸鎀î困???膸???????茴?????Ǎ??綵?紊ïÜ??茴??????筝?罨? def after_trading(context): pass diff --git "a/347円254円25412円347円253円240円357円274円232円345円233円240円345円255円220円347円255円226円347円225円245円351円200円211円350円202円241円345円256円236円344円276円213円/2_345円233円240円345円255円220円347円255円226円347円225円245円.txt" "b/347円254円25412円347円253円240円357円274円232円345円233円240円345円255円220円347円255円226円347円225円245円351円200円211円350円202円241円345円256円236円344円276円213円/2_345円233円240円345円255円220円347円255円226円347円225円245円.py" similarity index 75% rename from "347円254円25412円347円253円240円357円274円232円345円233円240円345円255円220円347円255円226円347円225円245円351円200円211円350円202円241円345円256円236円344円276円213円/2_345円233円240円345円255円220円347円255円226円347円225円245円.txt" rename to "347円254円25412円347円253円240円357円274円232円345円233円240円345円255円220円347円255円226円347円225円245円351円200円211円350円202円241円345円256円236円344円276円213円/2_345円233円240円345円255円220円347円255円226円347円225円245円.py" index ffe970c..7779f07 100644 --- "a/347円254円25412円347円253円240円357円274円232円345円233円240円345円255円220円347円255円226円347円225円245円351円200円211円350円202円241円345円256円236円344円276円213円/2_345円233円240円345円255円220円347円255円226円347円225円245円.txt" +++ "b/347円254円25412円347円253円240円357円274円232円345円233円240円345円255円220円347円255円226円347円225円245円351円200円211円350円202円241円345円256円236円344円276円213円/2_345円233円240円345円255円220円347円255円226円347円225円245円.py" @@ -7,12 +7,12 @@ def init(context): scheduler.run_monthly(rebalance,1) def rebalance(context, bar_dict): - # 遍枠狛陀渠音?勣議紘同 + # 薤????菴?羯ゆ??筝???活???????∞エ stocks = filter_paused(all_instruments(type='CS').order_book_id) stocks = filter_st(stocks) stocks = filter_new(stocks) - #臥儂?勣議峺炎 + #??ヨ哆??活??????????? fundamental_df = get_fundamentals( query( fundamentals.eod_derivative_indicator.pb_ratio, @@ -22,29 +22,29 @@ def rebalance(context, bar_dict): ) ).T.dropna() - #圓侃尖荷恬?1.3sigma 2.standard 3.neutral + #蘂?紊???????篏?鐚?1.3sigma 2.standard 3.neutral no_extreme = filter_3sigma(fundamental_df['pb_ratio']) pb_ratio_standard = standard(no_extreme) pb_ratio_neutral = neutral(pb_ratio_standard,fundamental_df['market_cap']) - #児噐咀徨斤学徨恂標僉 + #??坂?????絖?絲号??絖????膈???? q = pb_ratio_neutral.quantile(0.2) storck_list = pb_ratio_neutral[pb_ratio_neutral <= q].index context.storck_list = storck_list - #鎮欺返戦嗤議 + #??水?井??????????? context.last_main_symbol = context.portfolio.positions - #評渠音壓輝念咀徨僉嶄議学徨嶄議紘同 + #??????筝????綵???????絖????筝下??羆?絖?筝下????∞エ context.detele = set(context.last_main_symbol).difference(context.storck_list) if len(context.detele) != 0: - print ('距花') + print ('莪?篁?') for stock in context.detele: order_target_percent(stock,0) for stock in context.storck_list: order_target_percent(stock,1/len(context.storck_list)) -# 肇自峙荷恬 +# ?サ?????惹??篏? def filter_3sigma(series,n=3): mean = series.mean() std = series.mean() @@ -52,42 +52,42 @@ def filter_3sigma(series,n=3): min_range = mean - n*std return np.clip(series,min_range,max_range) -# 炎彈晒荷恬 +# ????????????篏? def standard(series): mean = series.mean() std = series.mean() return (series - mean)/std -# 嶄來晒荷恬 +# 筝中?у?????篏? def neutral(factor,market_cap): y = factor x = market_cap result = sm.OLS(y.astype(float),x.astype(float)).fit() return result.resid -# 登僅頁倦唯兎 +# ??ゆ?中????????? def filter_paused(stock_list): return [stock for stock in stock_list if not is_suspended(stock)] -#登僅頁倦ST紘 +#??ゆ?中????ST??? def filter_st(stock_list): return [stock for stock in stock_list if not is_st_stock(stock)] -#登僅頁倦頁仟紘 +#??ゆ?中?????壩?域?? def filter_new(stock_list): return [stock for stock in stock_list if instruments(stock).days_from_listed()>= 180] -# before_trading緩痕方氏壓耽爺住叟蝕兵念瓜距喘?輝爺峪氏瓜距喘匯肝 +# before_trading罩ゅ?醇?遺?????罸鎀î困???綣?紮????茴?????Ǎ??綵?紊ïÜ??茴??????筝?罨? def before_trading(context): pass -# 低僉夲議屬発議方象厚仟繍氏乾窟緩粁貸辞?箭泌晩賜蛍嶝煽雰方象俳頭賜宀頁糞扮方象俳頭厚仟 +# 篏??????ñ??莚???悟????井?勖?贋?医??篌?茹???罩ゆ侊??肢??鐚?箴?絋???ユ????????????兊?井????????????????????倶?井?????????贋?? def handle_bar(context, bar_dict): pass -# after_trading痕方氏壓耽爺住叟潤崩朔瓜距喘?輝爺峪氏瓜距喘匯肝 +# after_trading??醇?遺?????罸鎀î困???膸???????茴?????Ǎ??綵?紊ïÜ??茴??????筝?罨? def after_trading(context): pass diff --git "a/347円254円25414円347円253円240円357円274円232円345円233円240円345円255円220円346円211円223円345円210円206円351円200円211円350円202円241円345円256円236円346円210円230円/3_345円233円240円345円255円220円346円211円223円345円210円206円351円200円211円350円202円241円.txt" "b/347円254円25414円347円253円240円357円274円232円345円233円240円345円255円220円346円211円223円345円210円206円351円200円211円350円202円241円345円256円236円346円210円230円/3_345円233円240円345円255円220円346円211円223円345円210円206円351円200円211円350円202円241円.py" similarity index 57% rename from "347円254円25414円347円253円240円357円274円232円345円233円240円345円255円220円346円211円223円345円210円206円351円200円211円350円202円241円345円256円236円346円210円230円/3_345円233円240円345円255円220円346円211円223円345円210円206円351円200円211円350円202円241円.txt" rename to "347円254円25414円347円253円240円357円274円232円345円233円240円345円255円220円346円211円223円345円210円206円351円200円211円350円202円241円345円256円236円346円210円230円/3_345円233円240円345円255円220円346円211円223円345円210円206円351円200円211円350円202円241円.py" index 72fb4a7..22a3053 100644 --- "a/347円254円25414円347円253円240円357円274円232円345円233円240円345円255円220円346円211円223円345円210円206円351円200円211円350円202円241円345円256円236円346円210円230円/3_345円233円240円345円255円220円346円211円223円345円210円206円351円200円211円350円202円241円.txt" +++ "b/347円254円25414円347円253円240円357円274円232円345円233円240円345円255円220円346円211円223円345円210円206円351円200円211円350円202円241円345円256円236円346円210円230円/3_345円233円240円345円255円220円346円211円223円345円210円206円351円200円211円350円202円241円.py" @@ -1,13 +1,13 @@ -# 辛參徭失import厘断峠岬屶隔議及眉圭python庁翠?曳泌pandas、numpy吉。 +# ?櫆札???訓import???篁サ抗?佀?壩?????膃コ?????python罔≦??鐚?罸?絋?pandas???numpy膈???? -# 壓宸倖圭隈嶄園亟販採議兜兵晒貸辞。context斤嵆繍氏壓低議麻隈貨待議販採圭隈岻寂恂勧弓。 +# ?????筝??号??筝下?????篁私????????紮??????肢?????context絲壕院絨?篌????篏????膊?羈?膈???ョ??篁私????号??箙???翫??篌??????? import numpy as np import pandas as pd def init(context): - # 壓context嶄隠贋畠蕉延楚 - # 糞扮嬉咫晩崗 + # ???context筝TEL??絖????絮??????? + # 絎???倶????井?ュ?? # logger.info("RunInfo: {}".format(context.run_info)) - context.stocks = index_components('殺侮300') + context.stocks = index_components('羃?訓300') context.lastrank = [] scheduler.run_monthly(rebalance,1) @@ -39,49 +39,49 @@ def get_holdings(context): def get_stocks(context): fundamental_df_up = get_fundamentals(query( - fundamentals.financial_indicator.diluted_earnings_per_share, #耽紘辺吩EPS 埆互埆挫 - fundamentals.financial_indicator.return_on_equity,# 昌彿恢辺吩楕 埆互埆挫 - fundamentals.financial_indicator.return_on_invested_capital,#昌彿恢指烏楕?埆互埆挫 + fundamentals.financial_indicator.diluted_earnings_per_share, #罸???≧?句??EPS 莇?蕭?莇?絅? + fundamentals.financial_indicator.return_on_equity,# ???莎?篋ф?句????? 莇?蕭?莇?絅? + fundamentals.financial_indicator.return_on_invested_capital,#???莎?篋у????ョ??鐚?莇?蕭?莇?絅? ).filter(fundamentals.income_statement.stockcode.in_(context.stocks))).T fundamental_df_down = get_fundamentals(query( - fundamentals.financial_indicator.debt_to_asset_ratio, #彿恢減娥楕 埆詰埆挫 - fundamentals.eod_derivative_indicator.pb_ratio,# pb 埆詰埆挫 - fundamentals.eod_derivative_indicator.market_cap,#偏峙 + fundamentals.financial_indicator.debt_to_asset_ratio, #莎?篋ц????榊?? 莇?篏?莇?絅? + fundamentals.eod_derivative_indicator.pb_ratio,# pb 莇?篏?莇?絅? + fundamentals.eod_derivative_indicator.market_cap,#絽???? ).filter(fundamentals.income_statement.stockcode.in_(context.stocks))).T - for fator in fundamental_df_up.columns.tolist(): #斤埆互埆挫序佩嬉蛍 + for fator in fundamental_df_up.columns.tolist(): #絲壕??蕭?莇?絅処??茵??????? fundamental_df_up.sort_values(by=fator,inplace=True) fundamental_df_up[fator] = np.linspace(1,len(fundamental_df_up),len(fundamental_df_up)) - for fator in fundamental_df_down.columns.tolist(): #斤埆詰埆挫序佩嬉蛍 + for fator in fundamental_df_down.columns.tolist(): #絲壕??篏?莇?絅処??茵??????? fundamental_df_down.sort_values(by=fator,inplace=True) fundamental_df_down[fator] = np.linspace(len(fundamental_df_up),1,len(fundamental_df_up)) - # 憧俊 + # ??惹・ fundamental_df_rank = fundamental_df_down.join(fundamental_df_up) fundamental_df_rank['score'] = np.zeros([len(fundamental_df_rank),1]) - #柴麻悳蛍旺電會 + #莅∞????糸??綛倶??綺? fundamental_df_rank = fundamental_df_rank.cumsum(axis=1).sort_values(by='score',ascending=False) rank = fundamental_df_rank.score return rank.index.tolist()[:10] -# before_trading緩痕方氏壓耽爺貨待住叟蝕兵念瓜距喘?輝爺峪氏瓜距喘匯肝 +# before_trading罩ゅ?醇?遺?????罸鎀ñ????ヤ困???綣?紮????茴?????Ǎ??綵?紊ïÜ??茴??????筝?罨? def before_trading(context): pass -# 低僉夲議屬発議方象厚仟繍氏乾窟緩粁貸辞?箭泌晩賜蛍嶝煽雰方象俳頭賜宀頁糞扮方象俳頭厚仟 +# 篏??????ñ??莚???悟????井?勖?贋?医??篌?茹???罩ゆ侊??肢??鐚?箴?絋???ユ????????????兊?井????????????????????倶?井?????????贋?? def handle_bar(context, bar_dict): - # 蝕兵園亟低議麼勣議麻隈貸辞 + # 綣?紮?膽????篏????筝肢?????膊?羈???肢?? - # bar_dict[order_book_id] 辛參鎮欺蝶倖屬発議bar佚連 - # context.portfolio 辛參鎮欺孖壓議誘彿怏栽佚連 + # bar_dict[order_book_id] ?櫆札??水?井??筝?????悟??bar篆≧?? + # context.portfolio ?櫆札??水?亥ー????????莎?膸????篆≧?? - # 聞喘order_shares(id_or_ins, amount)圭隈序佩鯛汽 + # 篏睡??order_shares(id_or_ins, amount)??号??菴?茵???遵?? - # TODO: 蝕兵園亟低議麻隈杏? + # TODO: 綣?紮?膽????篏????膊?羈???э?? #order_shares(context.s1, 1000) pass -# after_trading痕方氏壓耽爺住叟潤崩朔瓜距喘?輝爺峪氏瓜距喘匯肝 +# after_trading??醇?遺?????罸鎀î困???膸???????茴?????Ǎ??綵?紊ïÜ??茴??????筝?罨? def after_trading(context): pass