Support Board
Date/Time: Tue, 25 Feb 2025 10:28:19 +0000
[User Discussion] - create .scid files
View Count: 2830
[2014-06-12 00:52:01] |
maxpi - Posts: 181 |
How do we write a struct to a file? I read the info at http://www.sierrachart.com/index.php?l=doc/doc_IntradayDataFileFormat.html#FeedSierraChartData but I can't see how exactly to write the struct fields to a file.. |
[2014-06-12 21:32:07] |
norvik - Posts: 22 |
This functions I use in my mfc application. sChart is like s_IntradayRecord type, but for some reasons, I use only int values. BOOL CMainWindow::OnInitDialog()
{ __super::OnInitDialog(); memset(&sChart,0,sizeof(SierraChart)); return TRUE; } void CMainWindow::CreateSCDataFile() { strncpy (s_header.FileTypeUniqueHeaderID, "SCID", 4); header.HeaderSize = sizeof(IntradayHeader); header.RecordSize = sizeof(SierraChart); header.Version = 1; header.Unused1 = 0; header.UTCStartIndex = 0; char Reserve[36]; memset (header.Reserve, 0, sizeof(header.Reserve)); char *filename = "C:\\SierraChart\\Data\\6RVM4-CME.scid"; myFile.open(filename, ios::in | ios::out | ios::binary | ios::trunc); myFile.write ((char*) &header, sizeof IntradayHeader); } void CMainWindow::WriteTickDataToSCFile(int price,int volume,int numberoftrades,int value1,int value2) { double varTime; SYSTEMTIME sysTime; GetSystemTime(&sysTime); SystemTimeToVariantTime(&sysTime, &varTime); sChart.sierraTime = varTime; sChart.sierraOpen = price; sChart.sierraLow = price; sChart.sierraHigh =price; sChart.sierraClose = price; sChart.NumTrades = numberoftrades; sChart.TotalVolume = volume; sChart.AskVolume = value2; sChart.BidVolume = value1; myFile.write((char*) &sChart, sizeof sChart); } void CMainWindow::OnDestroy() { myFile.close(); __super::OnDestroy(); } |
[2014-06-22 17:12:58] |
ganz - Posts: 1048 |
maxpi hi in case you prefer more simple solution #!/usr/bin/python import struct filename = 'my1chart.scid' datetime = 41800 price = 1.3535 volume = 1 output = open(filename, 'wb') header = b'SCID8\x00\x00\x00(\x00\x00\x00\x01\x00' output.write(header) for i in range(21): output.write(b'\x00\x00') record = struct.pack('d4f4L', datetime, price, price, price, price, volume, volume, volume, volume) output.write(record) output.close() biblio: https://docs.python.org/2/library/struct.html http://gebloggendings.files.wordpress.com/2012/07/struct.pdf Date Time Of Last Edit: 2014-06-22 17:17:25
|
[2014-07-02 18:08:41] |
ganz - Posts: 1048 |
maxpi this is another simple way using Lua local lib = require"struct" local unpack = unpack or table.unpack function fromhex(str) return (str:gsub('..', function (cc) return string.char(tonumber(cc, 16)) end)) end local hBinaryOutput = assert(io.open("./test.scid", "wb")) if (hBinaryOutput) then header = fromhex("5343494438000000280000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000") hBinaryOutput:write(header) local vol = 5 local price = 250 local dt = 41822.125 record = lib.pack("dffffLLLL", dt, price, price, price, price, vol, vol, vol, vol) hBinaryOutput:write(record) hBinaryOutput:close() end http://www.inf.puc-rio.br/~roberto/struct/ Date Time Of Last Edit: 2014-07-02 18:09:01
|
[2021-04-10 17:46:01] |
User719206 - Posts: 93 |
hello , Actually i have a software developed in java that allow me to create a txt file to import intraday data in Sierra, I would like to get it in real time, I saw that i need to use a Scid file, is there a way to get the code that put trades in real time with java? Thanks for your answer :) |
To post a message in this thread, you need to log in with your Sierra Chart account: