Securities companies handle pure gold (ETFs), and the stock code 1540 is as small as about 6000 yen per stock. There is a so-called "dollar cost averaging method" in which these stocks are bought by diversifying over time rather than buying them all at once. Some people will save daily, while others will save weekly or monthly. Here, we will focus on weekly data and explore which day of the week is best.
However, it is up to you to make the decision. And this article isn't about investing, it's about how the writer knows how to handle weekly data. Again, don't forget that investing is at your own risk.
Let's prepare the data. In my case, I got the data for 160 days and prepared it by using replacement. Since I wanted more days of the week, I imported it into Excel once, added a day of the week column using a function, and created the following csv data "junkin.csv".
Day of the week,Date and time,Open price,High price,Low price,closing price,Volume,調整後closing price*
2020-1-6,5220,5260,5200,5250,135951,5250
Same as below, arranged in ascending order by date
Import csv data. Some imports are unnecessary
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn import datasets
plt.style.use('ggplot') #Magic
junkin = pd.read_csv("junkin.csv") #Read csv data
junkin.head() #Take a look at the overview
You can skip here as you won't use it later. Check the number of lines and type. It can be seen that the date and time were actually character type as well as 160 days. For the time being, add a column converted to date and time type.
n = len(junkin)
n
junkin['date'] = pd.to_datetime(junkin['Date and time'], format='%Y/%m/%d')
junkin.dtypes
Compared to the previous day, that is, the closing price on the current day-the closing price on the previous day is calculated and given as a column. Check the head 3 lines with .head (3).
junkin['The day before ratio'] = junkin['closing price'].diff()
junkin.head(3)
Extract Monday rows.
mon = junkin.query('Day of the week.str.endswith("Month")', engine='python')
mon.head(3)
Let's take a look at the summary statistics focused on Monday. The same applies from Tuesday to Friday.
mon.describe()
It is up to you to determine the calculated and output summary statistics. In order to judge "which day of the week you buy pure gold" that I personally stated, would you compare the average value from the previous day? You may try increasing the amount of data a little more.
・ Import csv data -Conversion to date type ・ Extraction of specific rows
Recommended Posts