Support Board
Date/Time: Sun, 24 Nov 2024 10:56:21 +0000
SCID Format
View Count: 13536
[2013-04-19 04:02:01] |
Kiwi - Posts: 375 |
I am writing an SCID to ASCII TSV converter in Python. Its mainly for testing purposes but I'll make it available for others who want it. My question is about the SCID format. Is it still the same as describe in this page? http://www.sierrachart.com/index.php?l=doc/doc_IntradayDataFileFormat.html http://i.imgur.com/NKG8zmF.png If I'm reading it right the least significant digit of the header size seems to be first (as does the lsd for the record size if I've got it right). However the header and record sizes (0x38 and 0x28 do seem right). Is the spec current thanks? |
[2013-04-19 04:15:43] |
Sierra Chart Engineering - Posts: 104368 |
The documentation is up-to-date and correct. On Intel computers, these are known as Little endian. And that is how the data will be stored in the file. Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
[2013-04-19 05:20:46] |
Kiwi - Posts: 375 |
Thanks. I will do a python converter (to yours or a specified timezone/dst) initially for cli. This can be used by Python, R or other programs to generate TSV files for testing. A little later I'll adapt it to GUI with easygui. Code will be public for anyone who wants it. I'd ask that improvements also be published. |
[2013-04-20 22:59:04] |
Kiwi - Posts: 375 |
It turns out that SCID is easy to understand and relatively easy to convert. I'm posting the code because your choice of date format is the major issue. This one spits out a date and a time field in excel format (first part is days since the end of 1899 and the part after the decimal point is current time divided by 24 hours in seconds (86400)). It also includes code to convert time to Python datetime format (deserialize). It takes arguments in the form: python SCID_to_TSV <filename> <time zone adjustment>
It will output the same filename but with a .tsv extension instead of .scid. Time zone adjustment is called with nothing or 0 for UTC, l for local time, and a number for offset from UTC. It does the conversion of a 10.1Mbyte scid to a 265,529 line tsv file in 1.8 seconds on an i5 system. I've stopped development on this version because I'm planning to use Pandas Dataframes for analysis so I'm simply creating a Python module to interact with Sierra Chart. import csv
import sys import numpy as np import struct from time import ctime from datetime import date, datetime, time, timedelta # import ipdb # import ipdb; ipdb.set_trace(); ## *** ## def deserialize(excelDateAndTime): date_tok = int(excelDateAndTime) time_tok = round(86400*(excelDateAndTime - date_tok)) d = date(1899, 12, 30) + timedelta(date_tok) t = time(*helper(time_tok, (24, 60, 60, 1000000))) return datetime.combine(d, t) def helper(factor, units): factor /= 86399.99 result = list() for unit in units: value, factor = divmod(factor * unit, 1) result.append(int(value)) result[3] = int(0) return result def excelTimeAdjust(date_and_time, tzAdjust): return date_and_time + tzAdjust.seconds/86400.0 def getRecords(filename, fileoutput, tzvar): """ Read in records from SierraChart .scid data filename """ sizeHeader = 0x38 sizeRecord = 0x28 if tzvar == 99999: tzAdjust = datetime.fromtimestamp(0) - datetime.utcfromtimestamp(0) else: tzAdjust = timedelta(hours=tzvar) trueTime2 = 0 header = ('Date', 'Time', 'O', 'H', 'L', 'C', 'V', 'T') ftsv = open(fileoutput, 'w') fileout = csv.writer(ftsv, delimiter='\t') with open(filename, 'rb') as fscid: fscid.read(sizeHeader) # discard header fileout.writerow(header) for i in xrange(300000): data = fscid.read(sizeRecord) if data != "": dataRow = struct.unpack('d4f4I', data) adjustedTime = d[0] + tzAdjust.seconds/86400.0 outrow = (str(adjustedTime), str(adjustedTime), str(dataRow[1]), str(dataRow[2]), str(dataRow[3]), str(dataRow[4]), str(dataRow[5]), str(dataRow[6])) fileout.writerow(outrow) else: break return if __name__ == '__main__': """ Takes a SierraChart scid file (input argument 1) and converts it to a tab separated file (tsv) Timezone conversion can follow the users local timezone, or a specified integer (input l or an integer but if the default filename is being used, "" must be specified for the filename) """ filename = '/home/john/zRamdisk/SierraChart/Data/HSI-201303-HKFE-TD.scid' tzvar = 0 if len(sys.argv) > 1: if len(sys.argv[1]): filename = sys.argv[1] if len(sys.argv) > 2 and len(sys.argv[2]): print sys.argv[2], type(sys.argv[2]) if sys.argv[2] == 'l': tzvar = 99999 print tzvar, type(tzvar) else: tzvar = float(sys.argv[2]) print tzvar, type(tzvar) fileoutput = filename[:-4] + 'tsv' getRecords(filename, fileoutput, tzvar) Date Time Of Last Edit: 2013-04-21 03:50:55
|
[2013-04-20 23:25:08] |
Sierra Chart Engineering - Posts: 104368 |
From documentation: These double precision Date-Time values have the type name SCDateTime in Sierra Chart. Sierra Chart provides the /ACS_Source/SCDateTime.h file with various functions for working with these Date-Time values. You can assign these double precision date-Time values to a SCDateTime object type and access all of the member functions for working with these Date-Time values.
Maybe this will be helpful. Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing Date Time Of Last Edit: 2013-04-20 23:25:26
|
[2015-11-02 01:34:47] |
ganz - Posts: 1048 |
SC Support Were there any changes regarding DateTime format for *.scid last 6-9 months or so? |
[2015-11-02 02:07:55] |
Sierra Chart Engineering - Posts: 104368 |
The general format has not changed, but in the case of tick by tick data, the fractional part of the value does contain milliseconds. Later on it will contain microseconds and the milliseconds will be the actual exchange reported milliseconds. However none of this, should cause any trouble when reading or writing scid files. Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
[2016-04-30 09:41:29] |
User17477 - Posts: 65 |
Hi, Appreciate any help as I'm a complete Python newbie but would like to start running some basic tests over my ES data. How do I use this script? Is this easier than exporting the tick data? many thanks |
[2020-10-29 18:04:43] |
User681150 - Posts: 62 |
hi Kiwi, i know its been a while... i was wondering if you have an updated version of this script to convert the .scid to csv... thanks |
[2020-10-29 20:52:51] |
Sierra Chart Engineering - Posts: 104368 |
You can do this within Sierra Chart. Refer to: Edit Menu: Edit >> Export Intraday Data to Text file Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
[2020-12-17 15:45:26] |
User681150 - Posts: 62 |
but the point of a script is to do conversion of intraday files without needing to open and run a command in SC, is there anyway Engineering can create this conversion script either in python or C
|
[2020-12-17 18:10:25] |
Sierra Chart Engineering - Posts: 104368 |
You can certainly write your own. The file format is documented here: Intraday Data File Format Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
To post a message in this thread, you need to log in with your Sierra Chart account: