|
GET數據轉換完整版,可以在D盤自動生成文件夾DATA,自動生成ㄖ線\分時線
數據轉換完整版,可以在D盤自動生成文件夾DATA,自動生成ㄖ線\分時線
_Barpos := BARPOS;
_Year := YEAR;
_Month := MONTH;
_Day := DAY;
_Datatype := DATATYPE;
_Marketlabel := MARKETLABEL;
_StkName := STKLABEL;
_Open := OPEN;
_High := HIGH;
_Low := LOW;
_Close := CLOSE;
_Vol := VOL;
_Amount := AMOUNT;
<%
Dim Marketlabels,Stknames,Datatypes,Opens,Highs,Lows,Closes,Vols,Amounts,Years,Months,Days
Barposes = ffl.vardata("_Barpos")
Years = ffl.vardata("_Year")
Months = ffl.vardata("_Month")
Days = ffl.vardata("_Day")
Datatypes = ffl.vardata("_Datatype")
Marketlabels = ffl.vardata("_Marketlabel")
Stknames = ffl.vardata("_Stkname")
Opens = ffl.vardata("_Open")
Highs = ffl.vardata("_High")
Lows = ffl.vardata("_Low")
Closes = ffl.vardata("_Close")
Vols = ffl.vardata("_Vol")
Amounts = ffl.vardata("_Amount")
If ReportFolderStatus("D:\Data") = 0 Then CreatFolder()
SelectCreatAsciiDataType(Datatypes)
Function SelectCreatAsciiDataType(Types)
Select Case Types
Case 0
Case 1
Case 2
Call CreateAsciiDataMin("05min","W")
Case 3
Call CreateAsciiDataMin("15min","SW")
Case 4
Call CreateAsciiDataMin("30min","SS")
Case 5
Call CreateAsciiDataMin("60min","M")
Case 6
Call CreateAsciiDataDayes()
Case 7
Case 8
Case 9
Case 10
Case 11
Case Else
End Select
End Function
Function CreateAsciiDataMin(FolderName,DataName)
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateTrue = -1,TristateFalse = 0,TristateUseDefault = -2
Dim Fso,FileName,TextStream,LineData,ArrayLast,LastDate,AforeDate,AforeYear,AforeMonth,AforeDay
Set Fso = CreateObject("Scripting.FileSystemObject")
FileName = "D:\Data\" & FolderName & "\" & DataName & StkNames & ".TXT"
Set TextStream = Fso.OpenTextFile(FileName, ForWriting, True)
ArrayLast = Ubound(Barposes)
LastDate = Years(ArrayLast) & "-" & Months(ArrayLast) & "-" & Days(ArrayLast)
For i = 0 To ArrayLast
AforeDate = DateAdd("d",(i-ArrayLast),LastDate)
AforeYear = Year(AforeDate)
AforeMonth = Month(AforeDate)
If Len(AforeMonth) = 1 Then AforeMonth = "0" & AforeMonth
AforeDay = Day(AforeDate)
If Len(AforeDay) = 1 Then AforeDay = "0" & AforeDay
Opens(i) = FormatNumber(Opens(i),3,,,TristateFalse)
Highs(i) = FormatNumber(Highs(i),3,,,TristateFalse)
Lows(i) = FormatNumber(Lows(i),3,,,TristateFalse)
Closes(i) = FormatNumber(Closes(i),3,,,TristateFalse)
Vols(i) = FormatNumber(Vols(i),3,,,TristateFalse)
Amounts(i) = FormatNumber(Amounts(i),3,,,TristateFalse)
LineData = AforeMonth &"/" & AforeDay &"/" & AforeYear& ", " & Opens(i) & ", " & Highs(i) & ", " & Lows(i) & ", " & Closes(i) & ", " & Vols(i) & ", " & Amounts(i)
TextStream.WriteLine LineData
Next
TextStream.Close
End Function
Function CreateAsciiDataDayes()
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateTrue = -1,TristateFalse = 0,TristateUseDefault = -2
Dim i,Fso,FileName,TextStream,LineData,AforeLast,ArrayLast
Set Fso = CreateObject("Scripting.FileSystemObject")
FileName = "D:\Data\Dayes\" & "A" & StkNames & ".TXT"
IF ReportFileStatus(FileName) = 0 Then
Set TextStream = Fso.OpenTextFile(FileName,ForWriting,True)
ArrayLast = Ubound(Barposes)
For i = 0 To ArrayLast
If Len(Months(i)) = 1 Then Months(i) = "0" & Months(i)
If Len(Days(i)) = 1 Then Days(i) = "0" & Days(i)
Opens(i) = FormatNumber(Opens(i),3,,,TristateFalse)
Highs(i) = FormatNumber(Highs(i),3,,,TristateFalse)
Lows(i) = FormatNumber(Lows(i),3,,,TristateFalse)
Closes(i) = FormatNumber(Closes(i),3,,,TristateFalse)
Vols(i) = FormatNumber(Vols(i),3,,,TristateFalse)
Amounts(i) = FormatNumber(Amounts(i),3,,,TristateFalse)
LineData = Months(i) &"/" & Days(i) & "/" & Years(i) & ", " & Opens(i) & ", " & Highs(i) & ", " & Lows(i) & ", " & Closes(i) & ", " & Vols(i) & ", " & Amounts(i)
TextStream.WriteLine LineData
Next
TextStream.Close
ElseIf ReportFileStatus(FileName) = 1 Then
AforeLast = 0
Set TextStream = Fso.OpenTextFile(FileName, ForReading, False)
Do Until TextStream.AtEndOfStream = True
TextStream.ReadLine
AforeLast = AforeLast+1
Loop
TextStream.Close
Set TextStream = Fso.OpenTextFile(FileName,ForAppending,False)
ArrayLast = Ubound(Barposes)
For i = AforeLast To ArrayLast
If Len(Months(i)) = 1 Then Months(i) = "0" & Months(i)
If Len(Days(i)) = 1 Then Days(i) = "0" & Days(i)
Opens(i) = FormatNumber(Opens(i),3,,,TristateFalse)
Highs(i) = FormatNumber(Highs(i),3,,,TristateFalse)
Lows(i) = FormatNumber(Lows(i),3,,,TristateFalse)
Closes(i) = FormatNumber(Closes(i),3,,,TristateFalse)
Vols(i) = FormatNumber(Vols(i),3,,,TristateFalse)
Amounts(i) = FormatNumber(Amounts(i),3,,,TristateFalse)
LineData = Months(i) & "/" & Days(i) &"/" & Years(i) & ", " & Opens(i) & ", " & Highs(i) & ", " & Lows(i) & ", " & Closes(i) & ", " & Vols(i) & ", " & Amounts(i)
TextStream.WriteLine LineData
Next
TextStream.Close
End If
End Function
Function ReportFileStatus(Filespec)
Dim Fso, Status
Set Fso = CreateObject("Scripting.FileSystemObject")
If (Fso.FileExists(Filespec)) Then
Status = 1
Else
Status = 0
End If
ReportFileStatus = Status
End Function
Function ReportFolderStatus(FolderDir)
Dim Fso, Status
Set Fso = CreateObject("Scripting.FileSystemObject")
If (Fso.FolderExists(FolderDir)) Then
Status = 1
Else
Status = 0
End If
ReportFolderStatus = Status
End Function
Function CreatFolder()
Dim Fso
Set Fso = CreateObject("Scripting.FileSystemObject")
Dim Folder
Set Folder = Fso.CreateFolder("D:\Data")
Set Folder = Fso.CreateFolder("D:\Data\Dayes")
Set Folder = Fso.CreateFolder("D:\Data\60min")
Set Folder = Fso.CreateFolder("D:\Data\30min")
Set Folder = Fso.CreateFolder("D:\Data\15min")
Set Folder = Fso.CreateFolder("D:\Data\05min")
End Function
%>
0; |
|