Exemple #1
0
 def __init__(self):
     self.insdustry_quote = base.load_industryquote_xlsx()
     self.nav = base.load_nav_csv()
     self.records = base.load_records_csv()
     self.current_date = time
     self.trading_day_df = base.load_trading_day_csv()
     self.quote = base.load_quote_csv()
Exemple #2
0
def top_nav_portcode(n):
    df = base.load_nav_csv()
    nav = df.groupby(
        ['PortCode'])['Nav'].apply(lambda x: x.iloc[-1]).reset_index(name='Q')
    nav = nav.sort_values(by=['Q'], ascending=False)
    names = nav.head(n)['PortCode'].tolist()

    return names
Exemple #3
0
def check_portcodes_detial(portcodes):
    df = base.load_nav_csv()
    tmp1 = df[df['PortCode'] == portcodes[0]][['NavDate', 'Nav']]
    for p in portcodes[1:]:
        tmp2 = df[df['PortCode'] == p][['NavDate', 'Nav']]
        tmp1 = pd.merge(tmp1, tmp2, on=['NavDate'], how='left')
    tmp1.reset_index(['NavDate'])
    portcodes.insert(0, 'NavDate')
    tmp1.columns = portcodes
    return tmp1
Exemple #4
0
def test_Update_IR_rank():
    records = base.load_records_csv()
    industry_quote = base.load_industryquote_xlsx()
    nav = base.load_nav_csv()
    quote = base.load_quote_csv()
    IR_rank = base.load_irweek_csv()

    date = '2017-01-06'
    df_records = records[records.Updated <= date]
    df_ind_quote = industry_quote[industry_quote.TradingDay <= date]
    df_nav = nav[nav.NavDate <= date]
    df_quote = quote[quote.TradingDay <= date]

    Update_IR_rank(date, df_records, df_ind_quote, df_nav, df_quote, IR_rank)
Exemple #5
0
    def __init__(self, train_window, test_window):
        self.portcodes = ['ZH010630']
        data = base.load_certain_states_csv()
        self.states = data.drop(data.index[:40]).round(0)
        self.nav = base.load_nav_csv()
        self.count = 1
        self.phase = 'Train'
        self.train_window = train_window
        self.test_window = test_window
        self.done = False

        print("################## INIT ENV ####################")
        print("PortCodes: ", self.portcodes)
        print("Start Date: ", self.states.iloc[0, 0])
        print("################################################")
Exemple #6
0
Fichier : env.py Projet : wcm95/RL
    def __init__(self, train_window, test_window):
        self.portcodes = ['ZH010630']
        self.port_num = len(self.portcodes)
        s1 = base.load_states_csv()
        s1.iloc[:, 1:] = preprocessing.scale(s1.iloc[:, 1:])
        self.s1 = s1.drop(s1.index[:40])
        self.nav = base.load_nav_csv()
        self.count = 1
        self.action_space = np.zeros(self.port_num + 1, )
        self.observation_space = np.zeros(2, )
        self.current_reward = 0
        self.phase = 'Train'
        self.train_window = train_window
        self.test_window = test_window
        self.done = False

        print("################## INIT ENV ####################")
        print("PortCodes: ", self.portcodes)
        print("Start Date: ", self.s1.iloc[0, 0])
        print("################################################")
Exemple #7
0
import numpy as np
import pandas as pd
import base

quote = base.load_quote_csv()
industry = base.load_industry_csv()
records = base.load_records_csv()
nav = base.load_nav_csv()
industry_quote = base.load_industryquote_xlsx()

# get year-month info
nav_copy = nav.copy()
nav_copy.NavDate = nav_copy.NavDate.apply(lambda x: str(x)[:7])
# monthly nav ratio
nav_month_ratio = nav_copy.groupby([
    'PortCode', 'NavDate'
]).apply(lambda x: (x.Nav.values[-1] - x.Nav.values[0]) / x.Nav.values[0])
nav_month_ratio = pd.DataFrame(nav_month_ratio)
nav_month_ratio.columns = ['Ratio']

# For each portcode and every month, get the secucodes.
records_month = records.copy()
records_month.Updated = records_month.Updated.apply(lambda x: str(x)[:7])
records_month = records_month.groupby(['PortCode',
                                       'Updated']).apply(lambda x: x.SecuCode)
records_month = pd.DataFrame(records_month)

# get monthly ratio
quote_copy = quote.copy()
quote_copy.TradingDay = quote_copy.TradingDay.apply(lambda x: str(x)[:7])
quote_copy = quote_copy.groupby(['SecuCode', 'TradingDay']).apply(
Exemple #8
0
def check_portcode_detial(portcode):
    df = base.load_nav_csv()
    df = df[df['PortCode'] == portcode]
    return df