forex_data_aggregator 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- forex_data/__init__.py +92 -0
- forex_data/config/__init__.py +20 -0
- forex_data/config/config_file.py +89 -0
- forex_data/data_management/__init__.py +84 -0
- forex_data/data_management/common.py +1773 -0
- forex_data/data_management/database.py +1322 -0
- forex_data/data_management/historicaldata.py +1262 -0
- forex_data/data_management/realtimedata.py +993 -0
- forex_data_aggregator-0.1.2.dist-info/LICENSE +21 -0
- forex_data_aggregator-0.1.2.dist-info/METADATA +562 -0
- forex_data_aggregator-0.1.2.dist-info/RECORD +12 -0
- forex_data_aggregator-0.1.2.dist-info/WHEEL +4 -0
forex_data/__init__.py
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Created on Sun Jul 17 17:07:39 2022
|
|
4
|
+
|
|
5
|
+
@author: fiora
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from .config import (
|
|
9
|
+
read_config_file,
|
|
10
|
+
read_config_string,
|
|
11
|
+
read_config_folder
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
from . import config as config_module
|
|
15
|
+
from . import data_management as data_management_module
|
|
16
|
+
|
|
17
|
+
from .data_management import (
|
|
18
|
+
common,
|
|
19
|
+
HistoricalManagerDB,
|
|
20
|
+
RealtimeManager,
|
|
21
|
+
YEARS,
|
|
22
|
+
MONTHS,
|
|
23
|
+
TICK_TIMEFRAME,
|
|
24
|
+
BASE_DATA_COLUMN_NAME,
|
|
25
|
+
DATA_FILE_COLUMN_INDEX,
|
|
26
|
+
DEFAULT_PATHS,
|
|
27
|
+
SQL_COMPARISON_OPERATORS,
|
|
28
|
+
SQL_CONDITION_AGGREGATION_MODES,
|
|
29
|
+
empty_dataframe,
|
|
30
|
+
is_empty_dataframe,
|
|
31
|
+
shape_dataframe,
|
|
32
|
+
get_dataframe_column,
|
|
33
|
+
get_dataframe_row,
|
|
34
|
+
get_dataframe_element,
|
|
35
|
+
get_attrs_names,
|
|
36
|
+
any_date_to_datetime64,
|
|
37
|
+
get_db_key_elements,
|
|
38
|
+
check_timeframe_str,
|
|
39
|
+
DatabaseConnector,
|
|
40
|
+
DuckDBConnector,
|
|
41
|
+
LocalDBConnector,
|
|
42
|
+
validator_list_timeframe,
|
|
43
|
+
concat_data,
|
|
44
|
+
validator_dir_path,
|
|
45
|
+
TickerNotFoundError,
|
|
46
|
+
TickerDataNotFoundError,
|
|
47
|
+
TickerDataBadTypeException,
|
|
48
|
+
TickerDataInvalidException,
|
|
49
|
+
get_histdata_tickers,
|
|
50
|
+
POLARS_DTYPE_DICT
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
__all__ = [
|
|
54
|
+
'config_module',
|
|
55
|
+
'data_management_module',
|
|
56
|
+
'read_config_file',
|
|
57
|
+
'read_config_string',
|
|
58
|
+
'read_config_folder',
|
|
59
|
+
'common',
|
|
60
|
+
'HistoricalManagerDB',
|
|
61
|
+
'RealtimeManager',
|
|
62
|
+
'YEARS',
|
|
63
|
+
'MONTHS',
|
|
64
|
+
'TICK_TIMEFRAME',
|
|
65
|
+
'BASE_DATA_COLUMN_NAME',
|
|
66
|
+
'DATA_FILE_COLUMN_INDEX',
|
|
67
|
+
'DEFAULT_PATHS',
|
|
68
|
+
'SQL_COMPARISON_OPERATORS',
|
|
69
|
+
'SQL_CONDITION_AGGREGATION_MODES',
|
|
70
|
+
'empty_dataframe',
|
|
71
|
+
'is_empty_dataframe',
|
|
72
|
+
'shape_dataframe',
|
|
73
|
+
'get_dataframe_column',
|
|
74
|
+
'get_dataframe_row',
|
|
75
|
+
'get_dataframe_element',
|
|
76
|
+
'get_attrs_names',
|
|
77
|
+
'any_date_to_datetime64',
|
|
78
|
+
'get_db_key_elements',
|
|
79
|
+
'check_timeframe_str',
|
|
80
|
+
'DatabaseConnector',
|
|
81
|
+
'DuckDBConnector',
|
|
82
|
+
'LocalDBConnector',
|
|
83
|
+
'validator_list_timeframe',
|
|
84
|
+
'concat_data',
|
|
85
|
+
'validator_dir_path',
|
|
86
|
+
'TickerNotFoundError',
|
|
87
|
+
'TickerDataNotFoundError',
|
|
88
|
+
'TickerDataBadTypeException',
|
|
89
|
+
'TickerDataInvalidException',
|
|
90
|
+
'get_histdata_tickers',
|
|
91
|
+
'POLARS_DTYPE_DICT'
|
|
92
|
+
]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Created on Sat Jan 7 18:25:50 2023
|
|
4
|
+
|
|
5
|
+
@author: fiora
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
'config_file',
|
|
10
|
+
'read_config_file',
|
|
11
|
+
'read_config_string',
|
|
12
|
+
'read_config_folder'
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
from . import config_file
|
|
16
|
+
from .config_file import (
|
|
17
|
+
read_config_file,
|
|
18
|
+
read_config_string,
|
|
19
|
+
read_config_folder
|
|
20
|
+
)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Created on Sat Jan 7 18:27:09 2023
|
|
4
|
+
|
|
5
|
+
@author: fiora
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import yaml
|
|
9
|
+
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Any, Dict, Optional, Union
|
|
12
|
+
|
|
13
|
+
from loguru import logger
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
appconfig_folder = Path(__file__).parent.parent.parent / 'appconfig'
|
|
17
|
+
|
|
18
|
+
# search for config file
|
|
19
|
+
|
|
20
|
+
appconfig_filepath = list(appconfig_folder.glob('*appconfig.yaml'))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def read_config_file(config_file: str) -> Dict[str, Any]:
|
|
24
|
+
|
|
25
|
+
# assert compliant filepath
|
|
26
|
+
filepath = Path(config_file)
|
|
27
|
+
|
|
28
|
+
if not (
|
|
29
|
+
filepath.exists()
|
|
30
|
+
and filepath.is_file()
|
|
31
|
+
and filepath.suffix == '.yaml'
|
|
32
|
+
):
|
|
33
|
+
|
|
34
|
+
logger.error(f'invalid config .yaml file: {config_file}')
|
|
35
|
+
exit(0)
|
|
36
|
+
|
|
37
|
+
with open(filepath) as stream:
|
|
38
|
+
|
|
39
|
+
try:
|
|
40
|
+
|
|
41
|
+
data: Dict[str, Any] = yaml.safe_load(stream)
|
|
42
|
+
|
|
43
|
+
except yaml.YAMLError as e:
|
|
44
|
+
|
|
45
|
+
logger.error('error loading yaml config data from '
|
|
46
|
+
f'{str(filepath)}: {e}')
|
|
47
|
+
raise
|
|
48
|
+
|
|
49
|
+
return data
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def read_config_string(config_str: str) -> Dict[str, Any]:
|
|
53
|
+
|
|
54
|
+
# open and read .yaml configuration file as a string
|
|
55
|
+
try:
|
|
56
|
+
|
|
57
|
+
data: Dict[str, Any] = yaml.safe_load(config_str)
|
|
58
|
+
|
|
59
|
+
except yaml.YAMLError as e:
|
|
60
|
+
|
|
61
|
+
logger.error('error loading yaml config data from '
|
|
62
|
+
f'{config_str}: {e}')
|
|
63
|
+
raise
|
|
64
|
+
|
|
65
|
+
return data
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def read_config_folder(
|
|
69
|
+
folder_path: Optional[Union[str, Path]] = None,
|
|
70
|
+
file_pattern: str = 'appconfig.yaml') -> Path:
|
|
71
|
+
|
|
72
|
+
if folder_path and (
|
|
73
|
+
Path(folder_path).exists()
|
|
74
|
+
and Path(folder_path).is_dir()
|
|
75
|
+
):
|
|
76
|
+
|
|
77
|
+
config_filepath = list(Path(folder_path).glob('*' + file_pattern))
|
|
78
|
+
|
|
79
|
+
if config_filepath:
|
|
80
|
+
|
|
81
|
+
return config_filepath[0]
|
|
82
|
+
|
|
83
|
+
else:
|
|
84
|
+
|
|
85
|
+
return Path()
|
|
86
|
+
|
|
87
|
+
else:
|
|
88
|
+
|
|
89
|
+
return Path()
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Created on Sat Jul 16 01:31:35 2022
|
|
4
|
+
|
|
5
|
+
@author: fiora
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
'common',
|
|
10
|
+
'HistoricalManagerDB',
|
|
11
|
+
'RealtimeManager',
|
|
12
|
+
'YEARS',
|
|
13
|
+
'MONTHS',
|
|
14
|
+
'TICK_TIMEFRAME',
|
|
15
|
+
'BASE_DATA_COLUMN_NAME',
|
|
16
|
+
'DATA_FILE_COLUMN_INDEX',
|
|
17
|
+
'DEFAULT_PATHS',
|
|
18
|
+
'SQL_COMPARISON_OPERATORS',
|
|
19
|
+
'SQL_CONDITION_AGGREGATION_MODES',
|
|
20
|
+
'empty_dataframe',
|
|
21
|
+
'is_empty_dataframe',
|
|
22
|
+
'shape_dataframe',
|
|
23
|
+
'get_dataframe_column',
|
|
24
|
+
'get_dataframe_row',
|
|
25
|
+
'get_dataframe_element',
|
|
26
|
+
'get_attrs_names',
|
|
27
|
+
'any_date_to_datetime64',
|
|
28
|
+
'get_db_key_elements',
|
|
29
|
+
'check_timeframe_str',
|
|
30
|
+
'DatabaseConnector',
|
|
31
|
+
'DuckDBConnector',
|
|
32
|
+
'LocalDBConnector',
|
|
33
|
+
'validator_list_timeframe',
|
|
34
|
+
'concat_data',
|
|
35
|
+
'validator_dir_path',
|
|
36
|
+
'TickerNotFoundError',
|
|
37
|
+
'TickerDataNotFoundError',
|
|
38
|
+
'TickerDataBadTypeException',
|
|
39
|
+
'TickerDataInvalidException',
|
|
40
|
+
'get_histdata_tickers',
|
|
41
|
+
'POLARS_DTYPE_DICT'
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
from . import common
|
|
45
|
+
|
|
46
|
+
from .common import (
|
|
47
|
+
YEARS,
|
|
48
|
+
MONTHS,
|
|
49
|
+
TICK_TIMEFRAME,
|
|
50
|
+
BASE_DATA_COLUMN_NAME,
|
|
51
|
+
DATA_FILE_COLUMN_INDEX,
|
|
52
|
+
DEFAULT_PATHS,
|
|
53
|
+
SQL_COMPARISON_OPERATORS,
|
|
54
|
+
SQL_CONDITION_AGGREGATION_MODES,
|
|
55
|
+
empty_dataframe,
|
|
56
|
+
is_empty_dataframe,
|
|
57
|
+
shape_dataframe,
|
|
58
|
+
get_dataframe_column,
|
|
59
|
+
get_dataframe_row,
|
|
60
|
+
get_dataframe_element,
|
|
61
|
+
get_attrs_names,
|
|
62
|
+
any_date_to_datetime64,
|
|
63
|
+
get_db_key_elements,
|
|
64
|
+
check_timeframe_str,
|
|
65
|
+
validator_list_timeframe,
|
|
66
|
+
concat_data,
|
|
67
|
+
validator_dir_path,
|
|
68
|
+
TickerNotFoundError,
|
|
69
|
+
TickerDataNotFoundError,
|
|
70
|
+
TickerDataBadTypeException,
|
|
71
|
+
TickerDataInvalidException,
|
|
72
|
+
get_histdata_tickers,
|
|
73
|
+
POLARS_DTYPE_DICT
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
from .database import (
|
|
77
|
+
DatabaseConnector,
|
|
78
|
+
DuckDBConnector,
|
|
79
|
+
LocalDBConnector
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
from .historicaldata import HistoricalManagerDB
|
|
83
|
+
|
|
84
|
+
from .realtimedata import RealtimeManager
|