elthariel commited on
Commit
6fd3d8b
·
verified ·
1 Parent(s): 70ff65b

feat: Initial commit of the dataset(s)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # histdata_fx_1m .gitignore
2
+
3
+ *.zip
README.md ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: unknown
3
+ task_categories:
4
+ - tabular-regression
5
+ tags:
6
+ - finance
7
+ - forex
8
+ pretty_name: Forex historical data, 1 minute
9
+ size_categories:
10
+ - 10M<n<100M
11
+ ---
12
+ # HistData FX 1m
13
+
14
+ This is an export in the parquet format of the histdata.com dataset, which
15
+ contains mostly Forex market tickers data.
16
+
17
+ For each symbol, 2 files are provided:
18
+ - `ticks.parquet` contains the ticker (ohlc) data
19
+ - `gaps.parquet` contains the reported time gaps
20
+
21
+ The timestamps are converted from the original EST timezone to UTC.
22
+
23
+ ## Ticks
24
+
25
+ The `ticks.parquet` files have the following schema:
26
+
27
+ ``` python
28
+ {
29
+ 'ts': pl.Datetime,
30
+ 'open': pl.Float64,
31
+ 'high': pl.Float64,
32
+ 'low': pl.Float64,
33
+ 'close': pl.Float64,
34
+ 'volume': pl.UInt64,
35
+ }
36
+ ```
37
+
38
+ ## Gaps
39
+
40
+ The `gaps.parquet` files have the following schema:
41
+
42
+ ``` python
43
+ {
44
+ # The gap duration
45
+ 'length': pl.UInt64,
46
+ # The timestamp of the gap start converted to UTC.
47
+ 'start': pl.Datetime,
48
+ # The timestamp of the gap end converted to UTC.
49
+ 'end': pl.Datetime,
50
+ }
51
+ ```
52
+
53
+ ## Original dataset.
54
+
55
+ The original dataset can be found at [HistData.com](http://www.histdata.com/)
56
+ and the data was downloaded using [this
57
+ tool](https://github.com/philipperemy/FX-1-Minute-Data)
58
+
59
+ ## Updating the dataset
60
+
61
+ The dataset can be updated using tools from the following repo:
62
+ https://github.com/elthariel/FX-1-Minute-Data
63
+
64
+ `FX_DATA_OUTPUT=path_to_this_repo python path/to/download_all_fx_data.py`
65
+
66
+ > The data of the current year is downloaded per-month, but the older years are
67
+ > downloaded per-year. So you'll need to clean some extra files if you run the
68
+ > script in a new year, with something like:
69
+ > `rm */DAT_ASCII_*_M1_2024??.zip`
70
+
71
+ Then you need to process the individual files into the concatenated per-symbol
72
+ datasets
73
+
74
+ `cd path_to_this_repo && python datafux.py extract .`
75
+
76
+
77
+ ## License
78
+
79
+ The license is unclear. histdata.com has the copyright and provides the data for
80
+ free, but do not explicitly provide a license for it. So I *think* this is OK to
81
+ upload this, and for you to download it and train stuff on it, but this isn't a
82
+ certainty and I provide no legal guarantees whatsoever.
83
+
84
+ If you're the owner of histdata.com and would like me to remove this data.
85
+ Please reach out and I'll oblige.
audcad/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c1580bc222f1e8b9052e69a195cd69384d48564281f00db35d40b6fc943fe238
3
+ size 1003472
audcad/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4958909b4005bf0bbaf10a67d589092f4e44737ed2ba8034a5a7f22312221ce9
3
+ size 62807836
audchf/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:007b31df35ba354169484e42eeeb6d228b48b67b6952f1acc1af5d3d18247eeb
3
+ size 651820
audchf/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:acf96dfea0df266928338845d67b01659efb101a71bec255378c15556ba5d3a5
3
+ size 61543722
audjpy/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8a27dc7fd315bf5f604d0fa953e423c8e916ed8ef0a72ac3b58ba0590fe4cf34
3
+ size 2526181
audjpy/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:468ae2afdf3ddbd9996a7a74a1132ca74c495257d80d67197cb1f33a35584bbc
3
+ size 72173334
audnzd/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9159c6ba6a256829f3ee6c57f1f34c44ae0f291bc65341f9f467b41c8f3f8eb6
3
+ size 797208
audnzd/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ad40bc3ce939c6778dc83cda2033f1fdae683709cbe791c44a8b143096865b04
3
+ size 63306566
audusd/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb5775db17d64c3f1b12d3fad921379f3f7b301b71c1e00a9f5dd4586a252ffd
3
+ size 5933194
audusd/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6b3499624285f29130fbd597af7f26259ccb5a0890bed795d491b77ca1e8faae
3
+ size 72891920
auxaud/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ebd60bab86fa2b22ef68f0c41a97a26672f3583790152ea7f95f87c07e3e9d7b
3
+ size 5622336
auxaud/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4189e291a6314ff1a5b2aa95a69302dd46103b0541cf5f4c1a6425d8d5353634
3
+ size 34465246
bcousd/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2d51d6204f19b37e108c14387e20e2cba6e2bc79c322c11b2e47eefac0df740e
3
+ size 3083456
bcousd/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e644fcfd79440bac930245cec92004f3a38fa25c55e764500619f6cbcaa65d53
3
+ size 38545043
cadchf/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d609fdc6c462002f09c523d2c53babd5e6ae50f97accbc26001d2b8e0d87dd7c
3
+ size 1172433
cadchf/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:24c7f2813f99fb65cc4f50c99aa362a4a463b2810d8204a50bcd439822d75ab8
3
+ size 59754364
cadjpy/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb7160a60b0c4fbc868abf578c1b8df2dab438f6ecc52236a0223cff5b7c8b47
3
+ size 1092094
cadjpy/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:161a8cdb86890af7db847463a69aa8c493127b1aff1f981724a0249c08a1984d
3
+ size 64512496
chfjpy/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b4aeead2653f71bf5be807ea7c377b5393f2492fddeb974f535c4e203702c246
3
+ size 2385873
chfjpy/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:842aa4edcf06a95a5bc71c8a4d58dd99fdc918ba06a62e62983e2705c4925c58
3
+ size 75019563
datafux.py ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #! /usr/bin/env python3
2
+
3
+ import os, glob, re
4
+ import datetime as dt
5
+
6
+ import click
7
+ import zipfile as zf
8
+ import polars as pl
9
+
10
+ GAP_RE = re.compile('Gap of (\\d+)s found between (\\d+) and (\\d+)')
11
+ CSV_SCHEMA = {
12
+ 'ts': pl.String,
13
+ 'open': pl.Float64,
14
+ 'high': pl.Float64,
15
+ 'low': pl.Float64,
16
+ 'close': pl.Float64,
17
+ 'volume': pl.UInt64,
18
+ }
19
+
20
+ @click.group
21
+ def cli():
22
+ pass
23
+
24
+ @click.argument('folder')
25
+ @click.option('--only', '-o', multiple=True)
26
+ @click.option('--exclude', '-e', multiple=True)
27
+ @cli.command()
28
+ def extract(folder, only, exclude):
29
+ pairs = []
30
+
31
+ for entry in os.scandir(folder):
32
+ if entry.is_dir() and len(entry.name) == 6:
33
+ pairs.append(entry.path)
34
+
35
+ for pair in pairs:
36
+ name = os.path.basename(pair)
37
+ if len(only) > 0 and name not in only:
38
+ continue
39
+ if len(exclude) > 0 and name in exclude:
40
+ continue
41
+
42
+ print(f"Processing {name}:")
43
+ gaps, ticks = _extract_and_concatenate_pair(pair)
44
+
45
+ gaps_path = os.path.join(pair, 'gaps.parquet')
46
+ print(f" - Writing {gaps_path}")
47
+ gaps.write_parquet(gaps_path)
48
+
49
+ ticks_path = os.path.join(pair, 'ticks.parquet')
50
+ print(f" - Writing {ticks_path}")
51
+ ticks.write_parquet(ticks_path)
52
+
53
+ # breakpoint()
54
+
55
+
56
+ def _parse_gaps(lines):
57
+ "Parse the status report to extract gaps"
58
+ data = []
59
+
60
+ for line in lines:
61
+ line = line.decode('utf-8').strip()
62
+
63
+ if line == '':
64
+ continue
65
+ if 'HistData.com' in line or 'File:' in line or 'tick interval' in line:
66
+ continue
67
+
68
+ md = GAP_RE.match(line)
69
+ if md:
70
+ data.append([int(md[1]), md[2], md[3]])
71
+ else:
72
+ print(f"Unable to parse line: {line}")
73
+
74
+ gaps = pl.DataFrame(
75
+ schema={"length": pl.UInt64, "start": pl.String, "end": pl.String},
76
+ data=data,
77
+ orient='row'
78
+ ).with_columns(
79
+ pl.col("start").str.to_datetime(
80
+ "%Y%m%d%H%M%S"
81
+ ).dt.replace_time_zone('EST').dt.convert_time_zone('UTC')
82
+ ).with_columns(
83
+ pl.col("end").str.to_datetime(
84
+ "%Y%m%d%H%M%S"
85
+ ).dt.replace_time_zone('EST').dt.convert_time_zone('UTC')
86
+ )
87
+ return gaps
88
+
89
+
90
+ @click.argument('folder')
91
+ @click.option('--only', '-o', multiple=True)
92
+ @click.option('--exclude', '-e', multiple=True)
93
+ @cli.command()
94
+ def merge(folder, only, exclude):
95
+
96
+ for kind in ['ticks', 'gaps']:
97
+ print(f'Processing {kind} files: ')
98
+ files = glob.glob(os.path.join(folder, '*', f'{kind}.parquet'))
99
+ dataframes = []
100
+
101
+ for file in files:
102
+ print(f" - {file}")
103
+ name = os.path.basename(os.path.dirname(file))
104
+ df = pl.read_parquet(file).with_columns(symbols=pl.lit(name))
105
+ dataframes.append(df)
106
+
107
+ result = pl.concat(dataframes)
108
+ dest = os.path.join(folder, f'all_{kind}.parquet')
109
+ print(f'-> Writing merged file to {dest}')
110
+ result.write_parquet(dest)
111
+
112
+
113
+ def _extract_and_concatenate_pair(path, name=None):
114
+ if name is None:
115
+ name = os.path.basename(path)
116
+
117
+ gaps = []
118
+ ticks = []
119
+
120
+ zipfiles = glob.glob(os.path.join(path, "*.zip"))
121
+ for zipfile in zipfiles:
122
+ with zf.ZipFile(zipfile) as archive:
123
+ for entry in archive.namelist():
124
+ # This is the status report, let's parse it
125
+ if entry.endswith(".txt"):
126
+ with archive.open(entry) as txt_file:
127
+ lines = txt_file.readlines()
128
+ gaps.append(_parse_gaps(lines))
129
+
130
+ # This is the CSV with the ticker data
131
+ elif entry.endswith(".csv"):
132
+ with archive.open(entry) as csv_file:
133
+ ticks.append(pl.read_csv(
134
+ csv_file,
135
+ has_header=False,
136
+ separator=";",
137
+ ignore_errors=True,
138
+ schema=CSV_SCHEMA,
139
+ ))
140
+ else:
141
+ print(f"Unknown file {entry} in {zipfile}")
142
+
143
+ gaps = pl.concat(gaps).sort(by="start", descending=False)
144
+ ticks = pl.concat(ticks).with_columns(
145
+ pl.col("ts").str.to_datetime(
146
+ "%Y%m%d %H%M%S"
147
+ ).dt.replace_time_zone('EST').dt.convert_time_zone('UTC')
148
+ ).sort(by="ts", descending=False)
149
+
150
+ # breakpoint()
151
+
152
+ return gaps, ticks
153
+
154
+ if __name__ == '__main__':
155
+ cli()
etxeur/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d6f2749e1df0535e22e88deff12287c0e55f8aec686698d1c7ea8865e7ed0c23
3
+ size 3032485
etxeur/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2118053dee1af7f6aeaafac4b8a655875aabf75b1f57dd81d118a24d9ea98e40
3
+ size 8326205
euraud/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ed9402e0a7bc3e8367c3b987326a2a991ea36e039221df5c18c106154a504427
3
+ size 1664675
euraud/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cea8d8d61ccd64a9048604ccdc4395dc30adadff2da1184f77d6a3d19f369f21
3
+ size 85050782
eurcad/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:203ddf242be2c5f7cd45702d7034eeaa809eb973c81b989d8eb9690c282459a1
3
+ size 919147
eurcad/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:580d3f667988d963683735d89956d27ca2420ab99bc2de89e20779e1a12ee961
3
+ size 69613494
eurchf/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6ba98af620ca3cfd8fbb347cb99539042850129e9b44ee58206f1094188329a0
3
+ size 5717175
eurchf/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4fc257011931deed8f17ea85a8976c9fc9a3fa0b25a164bb49d9373ab30337f0
3
+ size 66095930
eurczk/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ba35650a93c751f1a071a52cca42b1b7cf8e5d6cb4e06a8ecce47d2e7db2f77f
3
+ size 6696235
eurczk/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7bb24f36de4c8a7482fc4a71b0389df8d9186f8bba18eab22b40a85150f66ba6
3
+ size 34567526
eurdkk/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:50134a8dcd9ad7691e2d4e0419f3a72fd59ca2abef30c7305bdd294cfcb26908
3
+ size 8897807
eurdkk/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0be5ae2c2c62eb1e751f8d4e1e9e564535629720ecf3c920183195c3b7170b5e
3
+ size 22057114
eurgbp/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:df18b9ffcc76741492b3f85028ba182d99aaa68da7b9c0d7697773d1ed244a71
3
+ size 5694646
eurgbp/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9f5bfc4a098a84dad65fa8560c7d483a8c21c7a83dcc0650fdd975a363513ad2
3
+ size 66874108
eurhuf/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c35ce5b001661810b49c330ad3f1deeb25290bb781f3e69ac41fc2a586c4aa9
3
+ size 4789920
eurhuf/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a6f5e4f02996918dd34475bef83a2ac8cf5301305a00290a7ba814ec6ca41379
3
+ size 37788687
eurjpy/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3f10698b5ff6c95fe6ad799f3572f8550557116fad79ef981210511d149a54a1
3
+ size 2218676
eurjpy/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6f5fb1f4801918a8361db08468fb8f963a725ee0fd82636dc1ddf228f3cade7d
3
+ size 78945965
eurnok/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:18465b9fa559eeef3df448b525e80672dd41e973004bb8783ae3089178d5f41b
3
+ size 3927793
eurnok/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bfeb9d5db1a10712f8f3358db2629d1797b45ae8a1f7b2aa6d0a3cf89a8e4dc4
3
+ size 79520010
eurnzd/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ecdebcdc9298e37e60bdea25726ba459c376225bfc161d9b7b7dbfb244300299
3
+ size 472382
eurnzd/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8b57820b258b12017e12f9256f2936262ed2cda61dd59998d4e941f7df7bcf3f
3
+ size 71964291
eurpln/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cbcc325936530370c69d4b9cc9183e993b697690cf22a6824d0a02fd09322b5b
3
+ size 5268552
eurpln/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:215831c72c1c4e8799cd9e7bf3f4b2ecde05ed41ed1f4231ee4e8086623eaecf
3
+ size 51864403
eursek/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a32e043bb7836cff0d5a440638e0cb5fc4f2ddedd227df0750c4a0e3d63979f1
3
+ size 4015680
eursek/ticks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d5e7511d7bdb6fa375270aefc4301439f622c5176f9c3141d6163496a45f61ac
3
+ size 78311413
eurtry/gaps.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:056b0f65e2429c056d65d332a2418f472a0fc49434e1afb0b3ddf9902f0eff81
3
+ size 1307550