2021年1月6日 星期三

打造超人思維 作者:Xdite 心得

 

書名:打造超人思維
作者:Xdite鄭伊廷

這本書提到許多使自己進步的觀念,而幾乎大部分我都非常贊同,並且作者也分享了一些她自己的方法,例如:
  • 極速寫作法
  • 極速讀書法

極速讀書法,主要是知道自己要找什麼知識,而才去看一本書,看完後記下內容,之後打一篇文章理解那些內容,而後解釋給身邊的人聽自己學到的,如此就可以很快的學到想學的知識。

極速寫作法則是相反過程,當一個精通程式的人,被想學程式的人問很多心中的疑問時,這時可能收集30~50個問題,讓精通程式的人去解釋這些問題,那這些問題與解釋整理過後,其實就是一本書。

以及書中提到要如何快速升級自己的人生
作者建議我們換一個工作環境,換到一個符合自己價值觀的環境,否則你待在一個你不喜歡的環境工作,你本身就浪費掉很多時間在對抗那個環境,哪還有時間成長
以及爸媽當年的觀念可能對我們不適用,作者用遊戲的方式比喻,會有人拿舊的攻略去打新的遊戲副本嗎?

作者也建議我們可以玩兩款桌遊遊戲
"現金流" 以及"卡坦島"
現金流可以讓我們體驗更多次的人生,知道怎樣的決策可能會更好
卡坦島可以讓我們學到創業可能會遇到的機率決策情境
並且作者在自己舉辦多次桌遊下發現
從桌遊中可以看出人品
 
作者覺得程式要寫的好,主要是要學習拆解問題的能力,而不是程式本身,畢竟程式其實是一連貫的處理一個問題,其實就是不停的拆解問題,直到這個問題可以被拆解成更小的問題,更小的問題可以解決,那組合起來,就可以解決大的問題

看這本書的過程中,我看得非常迅速,彷彿書中的知識我已經理解,但是卻很少實踐,感覺有點像是道理人人懂,做的人有幾個,而作者就是那個勇於實踐,並且一直成長的人,書中也提到,你必須勇於投資自己,投資可以讓自己提升效率的東西,作者以前幾乎沒存錢,就把錢花在課程上,或是書上,或是好的工具上,使的她可以快速進步,進步到自己想要的樣子,我想光這樣,就是大多數人都做不到的事情了,光出社會還在讀書的人,就少之又少,何況是還會拿自己賺的錢,去學習一切可以讓自己進步的東西,這種精神值得仿效!!

書中還有寫很多關於人生升級的觀念,實在是整本書都是精華,這本書非常推薦大家去購買來閱讀!!

2021目標

 https://pandas.pydata.org/pandas-docs/stable/user_guide/10min.html

Pandas 十分鐘系列

https://www.youtube.com/watch?v=1PC3etgLwVc&list=PLXO45tsB95cIRP5gCi8AlYwQ1uFO2aQBw

莫烦Python

https://www.sololearn.com/learning/1073

Sololearn

https://www.happycoder.org/2016/12/31/python101-tutorial/

Python 101 快速入門教學

https://www.udemy.com/course/pythonforbeginnersintro/

Udemy免費教學

https://www.coursera.org/professional-certificates/google-it-automation

Coursera 平台 google 開的課程

https://hahow.in/ur/5a8f537044a1e4001eee4277

用 Python 理財:打造小資族選股策略

2021目標是學完以上課程

然後用anki紀錄知識點

並且記錄在medium上

然後改善優化選股

以及看完年初買的七本書

看看如何以上全部知識點交叉應用

持續個兩年,看看會怎樣發酵~~







2019年3月26日 星期二

有買房有投資 對比 沒買房只投資,到底退休時會差多少呢?


我們的參數是基於



60.00


26

8.00

2.20

0.70

55

0.70

7.00

1000

300

40

2.50

20



  • 早點買房跟晚點買房的差異?

  • 透過跑程式,我們得知,如果你在很年輕就買房,到最後退休時,可能資金會差距很大,以下我們比較,30歲,40歲,50歲買房,退休會差距多少錢

    img
    img
    房貸究竟付快一點好,還是慢一點好呢?透過以下的比較,我們可以瞭解到,能付越少,越好,最後的錢會越多
    img
    img
    • 假如買房的話,房屋貸款年限究竟該長該短?透過以下的圖,我們可以知道,貸款年數,越長越好!!
    img
    img
    • 每個月多省下2000元拿來投資(開銷少一點),有很大的差別嗎?透過下圖,我們可以得知,如果你每月省2000元,退休時,你會多一百多萬,對於整體而言,大概是多3%,這個我覺得開心就好,畢竟人生只有一次,我們應該理財,也應該享受
    img
    img


    2019年3月25日 星期一

    Python 程式抓取 股票 策略

    股價淨值比 < 1 ,但要分散風險,因為即使它的股價淨值比低,但是也有可能是因為公司表現不好,而股價迅速下滑

    KD值

    最近三個月的月營收的平均 > 該家公司12個月的月營收平均

    中型股波動 較 大型股波動 大,但我們除了獲利,我們還要安全,所以

    自由現金流量(公司能自由運用的錢)  = 營業現金收入(賣東西賺的錢) - 投資現金流出 (更新設備擴建廠房等)

    自由現金流量我們希望可以大於0,代表公司財務狀況比較安全

    營業利益成長率 = (當期的營業利益 - 去年同期的營業利益) x 100% / 去年同期的營業利益

    我們希望營業利益成長率 是 正的,代表公司比去年更賺錢

    但即使這樣,我們想要公司跟公司比,於是我們看

    股東權益報酬率(ROE) = 本期淨利/股東權利

    ROE高 -> 小資本 賺很多
    ROE低 -> 大資本 但不會賺錢

    但即使roe高,股價太誇張了呢 ,於是我們再看

    市值營收比(PSR - PRICE TO SALE RATIO) = 市值/月營收

    PSR 高 - 市值(股價)太高,營收太少
    PSR低  - 市值(股價)低,營收高

    在配合有(上漲趨勢,可能有大戶)RSV 下去投資

    2019年3月19日 星期二

    python os#path #write #close time#sleep

    import time
    import os

    #if no directory called andrew_course9
    if 'andrew_course9' not in os.listdir():
        #create andrew_course9 directory
        os.mkdir('andrew_course9')
    #stock_id   
    sid = ['1101','2330']

    for s in sid:
        res = requests.get('website')
        res.encoding = 'big5'
        #set up save address , ex:andrew_course9\1101.html
        path = os.path.join('andrew_course9',s+'.html')
        #open the file ,write in ,then close
        f = open(path,'w',encoding='utf-8')
        f.write(res.text)
        f.close()
       
        print(s)
        #pause 20 sec , to prevent website does not let you catch data
        time.sleep(20)

    ********************************************************************************

    dfs = []
    #for every stock
    for s in sid:
        #get the file from directory
        path = os.path.join('andrew_course9', s + '.html')
       
        dfs.append(pd.read_html(path,encoding = 'utf-8'))
       

    dfs[1][1].head(10)

    *********************************************************************************

    python dataframe#read row and column#.iloc #.loc #dropna #set_index #how to check pandas version #how to save CSV and read #how to read and save sqlit3

    import requests
    from io import StringIO
    import pandas as pd

    url = 'website'
    r = requests.get(url)
    #let it can read chinese
    r.encoding = 'big5'

    dfs = pd.read_html(StringIO(r.text))
    #get the first table of html
    df = dfs[0]

    # in [:,:10],before comma it indicate to row id,after comma,it indicates columns id
    df = df.iloc[:,:10]
    # we can get the row which first column is '公司代號'
    column_name = df[df[0]=='公司代號']
    # select any row of column_name as column 's name' (because in here,all the row is the same)
    df.columns = column_name.iloc[0]
    df['當月營收'] = pd.to_numeric(df['當月營收'],errors = 'coerce')
    # delect row under 當月營收 which shows NaN by using   .dropna 
    df = df.dropna(subset=['當月營收'])
    # 刪除「公司代號」中出現「合計」的行數,其中「~」是否定的意思
    #delect df['公司代號'] which shows 合計 ,and ~ means "not"
    df = df.loc[~(df['公司代號']=='合計')]

    df = df.set_index(['公司代號','公司名稱'])
    df = df.apply(pd.to_numeric)
    #df.head()


    **********************************************************************
    #check pandas version
    pd.__version__

    **********************************************************************
    df.to_csv('test.csv',encoding='utf_8_sig')

    df = pd.read_csv('test.csv',index_col=['公司代號','公司名稱'])

    **********************************************************************
    import sqlite3

    conn = sqlite3.connect('test.sqlite3')
    df.to_sql('monthly_report', conn, if_exists='replace')


    df = pd.read_sql('select * from monthly_report', conn, index_col=['公司代號','公司名稱'])
    df.head()
    ********************************************************************** 

    2019年3月17日 星期日

    Python #crawling爬蟲 #save as a file as csv or html 存檔 #sqllite3 #dataframe.astype(str) #rename #remove column which is NaN# set index #lambda無名氏函數 no name function #pandas type to number轉數字 #date.strftime #list(filter)

    import requests #think it as a browser
    import pandas as pd

    res = requests.get("website address") #inside the () you can put the website link

    res.text # it will show the word you can not understand

    res.encoding = 'utf-8' #utf-8 ,so we can read chinese word

    res.text
    # save the file
    f = open('andrew_file.html','w',encoding = 'utf-8')
    f.write(res.text)
    f.close()

    #we need to use pandas to read html as dataframe

    df = pd.read_html('andrew_file.html')

    print(df[1])

    ***************************************************************************
    import requests #think it as a browser
    import pandas as pd

    res = requests.get("website address") #inside the () you can put the website link

    res.text # it will show the word you can not understand

    res.encoding = 'utf-8' #utf-8 ,so we can read chinese word

    res.text
    # save the file
    f = open('andrew_file.html','w',encoding = 'utf-8')
    f.write(res.text)
    f.close()

    #we need to use pandas to read html as dataframe

    df = pd.read_html('andrew_file.html')

    print(df[1])
    *********************************************************************
    #We also can directly let it be as dataframe , and no need to save
    from io import StringIO
    #StringIo make res.text like a file
    dfs = pd.read_html(StringIO(res.text))
    dfs[3]

    *********************************************************************
    import requests
    import pandas as pd
    from io import StringIO

    response = requests.get('website address')

    #df1 = pd.read_csv(StringIO(response.text))
    #want to save as df , but fail , it show ParserError: Error tokenizing data. C error: Expected 6 fields in line 159, saw 17
    #different row on the file


    lines = response.text.split('\n')
    lines[159]

    newlines = []
    #use for loop to organize the data
    #we use ", to seperate ,the reason is we are afraid we meet the string like this '  "你",   ",好,",   "嗎",'
    for line in lines:
        if len(line.split('",')) == 17:
            newlines.append(line)
         
    print("original line count = ")
    print(len(lines))
    print("after process line count = " )
    print(len(newlines))

    j = '\n'
    s = j.join(newlines)
    s.replace('=','')

    df = pd.read_csv(StringIO(s))
    #only show first 5 row
    df.head()

    #but now ,they looks like number , but they are string
    #and we dont want ","
    #we dont want Unnamed16

    #change all the content into string
    df = df.astype(str)
    #lambda is like a function ,but it make definition simple
    #applymap is to excute funtion
    df = df.applymap(lambda s:s.replace(',',''))

    df = df.set_index('證券代號')
    #change sting into number
    df = df.apply(lambda s: pd.to_numeric(s,errors = 'coerce' ))

    # to delect no use columns
    # axis=1 is to check every columns
    # how='all'  means if all is nan ,then it will act
    # (this also works) df = df[df.columns[df.isnull().sum() != len(df)]]
    df.dropna(axis = 1 ,how = 'all',inplace = True)

    df.head()

    *********************************************************************
    #how to write red bar of stock
    #length of red bar,1 means no up no down
    #<1 means stock closing price is lower(stock price fall)
    #>1 means stock closing price is larger(stock price rise)
    close_open = df['收盤價']/df['開盤價']
    close_open.head(5)
    *********************************************************************
    #select stock which closing price is larger 5% than opening price
    df[close_open > 1.05]
    *********************************************************************
    #save as csv file , so that we can open by excel
    df.to_csv('daily_price.csv',encoding = "utf_8_sig")

    #read file ,and assign "證卷代號" as index
    df = pd.read_csv('daily_price.csv',index_col = ['證券代號'])

    df.head()

    *********************************************************************
    #save to sqllite3

    import sqlite3
    conn = sqlite3.connect('test.sqlite3')
    df.to_sql('daily_price',conn,if_exists='replace')

    #read the file

    df = pd.read_sql('Select * from daily_price',conn,index_col = ["證券代號"])

    df.head()

    *********************************************************************

    *********************************************************************
    import pandas as pd
    import requests
    from io import StringIO

    def crawl_price(date):
        #change date into string
        datestr = date.strftime('%y%m%d')
       
        r = requests.post('website part1' + datestr + 'website part2')
       
        content = r.text.replace('=','')
       
        lines = content.split('\n')
        #delect row which columns <=10
        lines = list(filter(lambda l:len(l.split('",')) > 10, lines))
        #connect all the lines with \n
        content = "\n".join(lines)
       
        if content == '':
            return None
       
        df = pd.read_csv(StringIO(content))
       
        df = df.astype(str)
        df = df.apply(lambda s:s.str.replace(',',''))
       
        df['date'] = pd.to_datetime(date)
        #change the name of columns
        df = df.rename(columns={'證券代號':'stock_id'})
        df = df.set_index(['stock_id','date'])
        #df = df.set_index('stock_id')
        # turn all the content of table into number , coerce means the content will be NaN if it is fail to translate
        df = df.apply(lambda s:pd.to_numeric(s,errors = 'coerce'))
        #delect the columns which is no need
        df = df[df.columns[df.isnull().all()==False]]
       
        return df
       
       
    import datetime
    crawl_price(datetime.datetime(2019,3,18))


    *********************************************************************

    )