標籤

2023年4月1日 星期六

用python寫一支可以取得5秒加權指數歷史資料的程式

用python寫一支可以取得5秒加權指數歷史資料的程式 


import requests

import pandas as pd

import os


# 這個函數用來判斷要不要跳過某一行

def skip_rows(row):

    return row.startswith("說明:") or row.startswith("民國")


def download_taiex_csv(date):

    print(date+"下載轉換中")

     url = f'https://www.twse.com.tw/exchangeReport/MI_5MINS_INDEX?response=csv&date={date}&type=csv'

    response = requests.get(url)

    tmpfilename = f'tmp{date}.csv'

    with open(tmpfilename, 'w') as f:

        f.write(response.text)


     try:

        df = pd.read_csv(tmpfilename, skiprows=1)

    except ValueError:

        print(f'No data available for {date}')

    else:

        

        df = df[['時間', '發行量加權股價指數']]

        df.rename(columns={'發行量加權股價指數': '加權指數'}, inplace=True)

        df['時間'] = df['時間'].apply(lambda x: x.replace('=', '').replace('"', ''))

        df['時間'] = pd.to_datetime(df['時間'], errors='coerce')

        df['時間'] = df['時間'].dt.strftime('%H:%M:%S')

        df['加權指數'] = df['加權指數'].str.replace(',', '').astype(float)

        df = df.dropna(subset=['時間'])

        print(df.head())

        # 儲存為CSV檔案

        df.to_csv('taiex_%s.csv' % date, index=False)

    

    os.remove(tmpfilename)


# 主程式

start_date = '20230329'

end_date = '20230401'


for date in pd.date_range(start_date, end_date):

    download_taiex_csv(date.strftime('%Y%m%d'))


2023年3月26日 星期日

2023年3月16日 星期四

android上架後,下載的app icon為何變成內建小綠人,解決方法

 android上架後,下載的app icon為何變成內建小綠人,解決方法

不知道從哪個版本開始,android studio 把app icon 區分debug/release

據說是有助於開發人員識別


解決方法就是在res , 新建 image asset時

選好圖片的下一步,左上角會有選項顯示debug

這時去把這選項改為main就好了


2023年3月8日 星期三

Soup your photo 's privacy policy

Soup your photo 's  privacy policy

Soup uses cameras and photo albums, which are only for the user's own operation and use, and will not do any collection and sharing, nor upload to the Internet.


Soup has tandem mobile ads using Google's admob

iOS app 上架新增時,未出現套件識別碼的解決方法

 有可能是app沒有用到特別權限,所以xcode 未幫你註冊套件識別碼

這時只需要在xcode project -> target-> signing&Capabilities

隨意先新增一項,等xcode幫你註冊完成,再把這項刪掉就可以了

2023年2月19日 星期日

將chatGPT及Google Vision API應用在天地股票投資機器人(line)

將chatGPT及Google Vision API應用在天地股票投資機器人(line)

主要是把圖片內的文字轉出來,再請openai,幫我做標題


2023年2月5日 星期日

AI神修復殘破老照片,連打馬賽克的照片都能解碼

模糊照片可以修復成清晰

古老殘破的舊照片翻新

連打馬賽克(薄碼)的人臉都能修補出無碼

https://huggingface.co/spaces/sczhou/CodeFormer