Support Board
Date/Time: Sat, 23 Nov 2024 15:27:18 +0000
Post From: Python for Sierra Chart
[2024-02-19 23:15:07] |
User150671 - Posts: 69 |
Handling of the SCDateTime data is the hardest part, as it cleverly countains both timestamp and trade count information in a single 64 bit integer, so I use some string methods and regex to extract the desired information.
I was not tracking that it contains any trade count info whatsoever ref: Intraday Data File Format: DateTime I have following functions for converting sierra time integers: # takes a sierra Time and returns it as a dt.datetime def unSierraTime(timeint): exceldate = -2209161600.0 timeint = timeint/1000000 delta = timeint + exceldate delta = dt.datetime.fromtimestamp(delta).replace(tzinfo=dt.timezone.utc) return delta # Takes a Pandas TimeStamp or a datetime index and turns it into a sierra time integer def sierraTime(dtg): excelDate = (pd.to_datetime('1899-12-30')).tz_localize(tz="utc") delta = dtg - excelDate if type(dtg) == pd._libs.tslibs.timestamps.Timestamp: delta = int(delta.total_seconds()*1000000) else: delta = (delta.total_seconds()*1000000).astype('int64') return delta |