python stock interface strategy!

thumbnail

1- Read position information:

(1) Simply store in dic first, the time is in reverse order, just reverse in the construction time_list

(2) str,int conversion int(''.join(str1.split('-'))

2- Read the closing price:

After taking out the data conversion format:

df_close_f = df_close.pivot(index='time',columns='stock code',values='CLOSE')

Take the weighted closing price of tb_object_1425, the code is omitted

3- Calculate the stock-side yield:

(1) df.pct_change(1) Calculate the yield of stocks and bonds

(2) Calculate with np.dot(df_r,df_pos) matrix to get the stock-side return

(3) Use matrix calculation to achieve alignment data s_index = df_pos['stock code'] \ df_r = df_r.loc[:,s_index]

Or use a custom function ircp.ORDER_LIST(): df = df.set_index(target_columns) \ df = df.loc[s_index,:] \ df = df.reset_index()

4- Running strategy:

(1) Gradually build positions np.linspace(0,0.8,len(xxx)

(2) Under the non-full position, it is considered to invest in a currency fund

(3) series is the addition and subtraction of the corresponding position. Dataframe and series operations. Add, .sub, .div and complex operations can be converted into arrays for conversion. Pay attention to whether to transpose after conversion.

5- Strategy Judgment:

(1) Maximum drawdown

(2) Real income

(3) Benchmark

(4) Winning rate

(5) Average annualized rate of return

Latest Programming News and Information | GeekBar

Related Posts