Auto get stock price macro-(3)-

EN

Auto get stock price macro

Regarding the macro that automatically gets the stock price In the previous article, I introduced the following step 2, so in this article I’ll explain step 3 and subsequent steps.

Actually, that function is most important.

  1. Acquire all stock prices in your portfolio (like a list of stocks you own) with Excel VBA. (so-called scraping)
  2. Reshape information got by 1. In order to accumulate logs.
  3. Use the task scheduler to set to do 1. and 2. at a fixed time every day. ←The most Important

Step 3

In order to automatically updates, I use Task Scheduler.

Set excel that defines macro to start at the specified time.

When click Create Task, the setting screen will appear as shown below.
On the General tab, set the following.
・Decide the task name appropriately
・Check Execute only when the user is logged on (R)
・Check to execute with the highest privilege (I)

Next, decide on the trigger.
Set the date and time when I want to execute the macro from new.
In this case, since it is only necessary to grasp the stock price on weekdays, set the macro to be executed from Monday to Friday.
After that, you can create a trigger by checking Enabled (B) and clicking OK.

Then, it is necessary to specify the operation (macro execution) to be actually performed.
Set as follows from the new operation tab.

①Enter the absolute path where excel.exe is stored.
In my case, it looks like the following.
C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE

②Location of the file to be executed by excel. ⇒ Enter the storage location of the macro created this time.
For example, I think it will look like the following.
C:\Users\username\Desktop\SBI\SBI.xlsm

That’s all for the settings.
Now click the OK button again and it will be added to the scheduler.
Excel that defines the macro starts up at the specified time.

However, this only launches excel.

It is necessary to set to execute the macro when excel is launched.

Again, we need to double-click ThisWorkbook from VBA in excel and add the following code in it.

Private Sub Workbook_Open()

    Call StockPriceMonitoring   '株価更新

End Sub

Now when excel is launched, the macro will be started automatically.

That is all for the automatic setting of macros.

The task scheduler is very convenient, so if there are other processes that I want to finish automatically, I want to actively use it.

From the first “Auto get stock price macro-(1)-” to this article, I was able to create a macro that allows me to grasp the stock price I hold without doing anything.

However, the functions are still limited. After that, there is still something I want to do, such as creating a macro for automatic trading with reference to EPS (earnings per share) and PER (price earnings ratio), and so on.

Let’s create it slowly.

Thank you for reading to the end!!

コメント

タイトルとURLをコピーしました