Files
armandarmand/task1/task1-ticket1/helloworld/browser/hello-formatting/Main.bas
louiscklaw 8719fe58b8 update,
2025-02-01 01:59:56 +08:00

100 lines
2.9 KiB
QBasic

Attribute VB_Name = "Main"
Option Explicit
Dim rowc, cc, columnC As Integer
Dim last_row As Integer
Dim i As Integer
Dim stock_code As Integer
Dim temp As Variant
Dim etnet_temp As Variant
Sub main()
' On Error GoTo eh
WriteStatus.run "init config"
Config.init
WriteStatus.run "init config done"
' find last row
last_row = GetLastRow.run(11)
'last_row = 23
Debug.Print last_row
For i = ROW_START To last_row
stock_code = CInt(ReadStockCode.run(i))
If (stock_code > -1) Then
temp = FetchAaStock.run(stock_code)
etnet_temp = FetchEtnet.run(stock_code)
' WriteStatus.run "updateing stock code " & CStr(stock_code) & "..."
' WriteStockName.run i, CStr(temp(IDX_STOCK_NAME))
Write_10DayMovingAverage.run i, CStr(etnet_temp(IDX_10_DAY_MOVING_AVERAGE))
Write_20DayMovingAverage.run i, CStr(etnet_temp(IDX_20_DAY_MOVING_AVERAGE))
Write_50DayMovingAverage.run i, CStr(etnet_temp(IDX_50_DAY_MOVING_AVERAGE))
Write_100DayMovingAverage.run i, CStr(etnet_temp(IDX_100_DAY_MOVING_AVERAGE))
Write_250DayMovingAverage.run i, CStr(etnet_temp(IDX_250_DAY_MOVING_AVERAGE))
WriteRsi_10.run i, CStr(temp(IDX_RSI_10))
WriteRsi_14.run i, CStr(temp(IDX_RSI_14))
WriteRsi_20.run i, CStr(temp(IDX_RSI_20))
WriteMACD_8_17Days.run i, CStr(temp(IDX_MACD_8_17_DAYS))
WriteMACD_12_25Days.run i, CStr(temp(IDX_MACD_12_25_DAYS))
WriteEarningsPerShare.run i, CStr(etnet_temp(IDX_EARNINGS_PER_SHARE))
WriteFundFlow.run i, CStr(temp(IDX_FUND_FLOW))
WritePERatioExpected.run i, CStr(temp(IDX_P_E_RATIO_EXPECTED))
WriteShortSellingAmountRatio.run i, CStr(temp(IDX_SHORT_SELLING_AMOUNT_RATIO_))
' WriteStockCode.run i, CStr(temp(IDX_STOCK_CODE))
WriteStockPrice.run i, CStr(temp(IDX_STOCK_PRICE))
WriteYield.run i, CStr(temp(IDX_YIELD))
WriteStockName.run i, CStr(temp(IDX_STOCK_NAME))
'calculation
' D-E
Write_10SMA_diff_20SMA.run i, CStr(etnet_temp(IDX_10_DAY_MOVING_AVERAGE) - etnet_temp(IDX_20_DAY_MOVING_AVERAGE))
' E-F
Write_20SMA_diff_50SMA.run i, CStr(etnet_temp(IDX_20_DAY_MOVING_AVERAGE) - etnet_temp(IDX_50_DAY_MOVING_AVERAGE))
' F-G
Write_50SMA_diff_100SMA.run i, CStr(etnet_temp(IDX_50_DAY_MOVING_AVERAGE) - etnet_temp(IDX_100_DAY_MOVING_AVERAGE))
' Q-R
Write_RSI10_diff_RSI14.run i, CStr(temp(IDX_RSI_10) - temp(IDX_RSI_14))
' Q-S
Write_RSI10_diff_RSI20.run i, CStr(temp(IDX_RSI_10) - temp(IDX_RSI_20))
HighlightRow.run i
WriteStatus.run "update stock code " & CStr(stock_code) & " done"
Else
WriteStockName.run i, CStr("stock code is empty")
End If
Next i
' debug.print test
WriteStatus.run "update all stock code done"
Done:
Worksheets(TARGET_SHEET).Columns("A:AZ").EntireColumn.AutoFit
Worksheets(TARGET_SHEET).Rows("11:9999").EntireRow.AutoFit
Debug.Print "hello done"
Exit Sub
eh:
Debug.Print "hello error"
End Sub