jgtcore 0.1.0__tar.gz

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.
jgtcore-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Guillaume Descoteaux-Isabelle
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
jgtcore-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,109 @@
1
+ Metadata-Version: 2.1
2
+ Name: jgtcore
3
+ Version: 0.1.0
4
+ Summary: Core library for JGT utilities - configuration, settings, and utility functions
5
+ Author-email: Guillaume Isabelle <jgi@jgwill.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/jgwill/jgtcore
8
+ Project-URL: Bug Tracker, https://github.com/jgwill/jgtcore/issues
9
+ Project-URL: Documentation, https://github.com/jgwill/jgtcore#readme
10
+ Project-URL: Source Code, https://github.com/jgwill/jgtcore
11
+ Keywords: configuration,settings,utilities,jgt
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.7
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Requires-Python: >=3.7
21
+ Description-Content-Type: text/markdown
22
+ Provides-Extra: dev
23
+ License-File: LICENSE
24
+
25
+ # jgtcore
26
+
27
+ Core library for JGT utilities - configuration, settings, and utility functions.
28
+
29
+ This is a pure Python library extracted from `jgtutils` to provide clean programmatic access to JGT configuration and settings without CLI dependencies.
30
+
31
+ ## Installation
32
+
33
+ ```bash
34
+ pip install jgtcore
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ ### Simple Configuration Access
40
+ ```python
41
+ import jgtcore
42
+
43
+ # Load configuration
44
+ config = jgtcore.get_config()
45
+ demo_config = jgtcore.get_config(demo=True)
46
+
47
+ # Get specific config values
48
+ user_id = jgtcore.get_config_value('user_id')
49
+ quotes_count = jgtcore.get_config_value('quotes_count', 1000)
50
+ ```
51
+
52
+ ### Settings Management
53
+ ```python
54
+ import jgtcore
55
+
56
+ # Get all settings
57
+ settings = jgtcore.get_settings()
58
+
59
+ # Get specific setting with default
60
+ instrument = jgtcore.get_setting('instrument', 'EUR/USD')
61
+ timeframes = jgtcore.get_setting('_timeframes', 'D1')
62
+ ```
63
+
64
+ ### Environment Setup
65
+ ```python
66
+ import jgtcore
67
+
68
+ # One-call environment setup
69
+ config, settings = jgtcore.setup_environment(demo=True)
70
+
71
+ # Check demo mode
72
+ if jgtcore.is_demo_mode():
73
+ print("Running in demo mode")
74
+ ```
75
+
76
+ ### Advanced Usage
77
+ ```python
78
+ from jgtcore import readconfig, load_settings
79
+
80
+ # Load with specific options
81
+ config = readconfig(demo=True, export_env=True)
82
+ settings = load_settings(custom_path="/path/to/settings.json")
83
+ ```
84
+
85
+ ## Configuration Files
86
+
87
+ - **config.json**: Trading credentials and connection settings
88
+ - **settings.json**: Application settings and preferences
89
+
90
+ See `examples/` directory for sample configuration files.
91
+
92
+ ## File Locations
93
+
94
+ ### config.json lookup order:
95
+ 1. Current directory: `config.json`
96
+ 2. User home: `~/.jgt/config.json`
97
+ 3. System: `/etc/jgt/config.json`
98
+ 4. Environment variables: `JGT_CONFIG`, `JGT_CONFIG_PATH`
99
+
100
+ ### settings.json lookup order:
101
+ 1. System: `/etc/jgt/settings.json`
102
+ 2. User home: `~/.jgt/settings.json`
103
+ 3. Current directory: `.jgt/settings.json`
104
+ 4. YAML variants: `jgt.yml`, `_config.yml`
105
+ 5. Environment variables: `JGT_SETTINGS`
106
+
107
+ ## License
108
+
109
+ MIT License
@@ -0,0 +1,85 @@
1
+ # jgtcore
2
+
3
+ Core library for JGT utilities - configuration, settings, and utility functions.
4
+
5
+ This is a pure Python library extracted from `jgtutils` to provide clean programmatic access to JGT configuration and settings without CLI dependencies.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install jgtcore
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ### Simple Configuration Access
16
+ ```python
17
+ import jgtcore
18
+
19
+ # Load configuration
20
+ config = jgtcore.get_config()
21
+ demo_config = jgtcore.get_config(demo=True)
22
+
23
+ # Get specific config values
24
+ user_id = jgtcore.get_config_value('user_id')
25
+ quotes_count = jgtcore.get_config_value('quotes_count', 1000)
26
+ ```
27
+
28
+ ### Settings Management
29
+ ```python
30
+ import jgtcore
31
+
32
+ # Get all settings
33
+ settings = jgtcore.get_settings()
34
+
35
+ # Get specific setting with default
36
+ instrument = jgtcore.get_setting('instrument', 'EUR/USD')
37
+ timeframes = jgtcore.get_setting('_timeframes', 'D1')
38
+ ```
39
+
40
+ ### Environment Setup
41
+ ```python
42
+ import jgtcore
43
+
44
+ # One-call environment setup
45
+ config, settings = jgtcore.setup_environment(demo=True)
46
+
47
+ # Check demo mode
48
+ if jgtcore.is_demo_mode():
49
+ print("Running in demo mode")
50
+ ```
51
+
52
+ ### Advanced Usage
53
+ ```python
54
+ from jgtcore import readconfig, load_settings
55
+
56
+ # Load with specific options
57
+ config = readconfig(demo=True, export_env=True)
58
+ settings = load_settings(custom_path="/path/to/settings.json")
59
+ ```
60
+
61
+ ## Configuration Files
62
+
63
+ - **config.json**: Trading credentials and connection settings
64
+ - **settings.json**: Application settings and preferences
65
+
66
+ See `examples/` directory for sample configuration files.
67
+
68
+ ## File Locations
69
+
70
+ ### config.json lookup order:
71
+ 1. Current directory: `config.json`
72
+ 2. User home: `~/.jgt/config.json`
73
+ 3. System: `/etc/jgt/config.json`
74
+ 4. Environment variables: `JGT_CONFIG`, `JGT_CONFIG_PATH`
75
+
76
+ ### settings.json lookup order:
77
+ 1. System: `/etc/jgt/settings.json`
78
+ 2. User home: `~/.jgt/settings.json`
79
+ 3. Current directory: `.jgt/settings.json`
80
+ 4. YAML variants: `jgt.yml`, `_config.yml`
81
+ 5. Environment variables: `JGT_SETTINGS`
82
+
83
+ ## License
84
+
85
+ MIT License
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env python3
2
+
3
+ """
4
+ jgtcore - Core library functions extracted from jgtutils
5
+
6
+ This module provides the core configuration, settings, and utility functions
7
+ from jgtutils without CLI dependencies, making them suitable for use in
8
+ other libraries and applications.
9
+
10
+ Main Functions:
11
+ - Configuration: readconfig(), get_config(), get_config_value()
12
+ - Settings: load_settings(), get_settings(), get_setting()
13
+ - Environment: setup_environment(), export_env_if_any()
14
+ - Utilities: str_to_datetime(), is_market_open(), print_exception()
15
+ - Trading: read_fx_str_from_config(), is_demo_mode()
16
+ """
17
+
18
+ from .core import (
19
+ # Core configuration functions
20
+ readconfig,
21
+ load_settings,
22
+ get_settings,
23
+
24
+ # Simple API wrappers
25
+ get_config,
26
+ get_setting,
27
+ setup_environment,
28
+ get_config_value,
29
+ is_demo_mode,
30
+
31
+ # Environment helpers
32
+ load_arg_from_jgt_env,
33
+ load_arg_default_from_settings,
34
+ export_env_if_any,
35
+
36
+ # Utility functions
37
+ str_to_datetime,
38
+ print_exception,
39
+ is_market_open,
40
+ dt_from_last_week_as_datetime,
41
+ dt_from_last_week_as_string_fxformat,
42
+
43
+ # Trading helpers
44
+ read_fx_str_from_config,
45
+
46
+ # Helper functions for advanced use
47
+ update_settings,
48
+ load_arg_default_from_settings_if_exist,
49
+ )
50
+
51
+ __version__ = "1.0.0"
52
+ __author__ = "JGWill"
53
+ __description__ = "Core library functions extracted from jgtutils"
54
+
55
+ # Export the main functions that external packages are likely to use
56
+ __all__ = [
57
+ # Configuration functions
58
+ 'readconfig',
59
+ 'load_settings',
60
+ 'get_settings',
61
+
62
+ # Simple API wrappers
63
+ 'get_config',
64
+ 'get_setting',
65
+ 'setup_environment',
66
+ 'get_config_value',
67
+ 'is_demo_mode',
68
+
69
+ # Environment helpers
70
+ 'load_arg_from_jgt_env',
71
+ 'load_arg_default_from_settings',
72
+ 'export_env_if_any',
73
+
74
+ # Utility functions
75
+ 'str_to_datetime',
76
+ 'print_exception',
77
+ 'is_market_open',
78
+ 'dt_from_last_week_as_datetime',
79
+ 'dt_from_last_week_as_string_fxformat',
80
+
81
+ # Trading helpers
82
+ 'read_fx_str_from_config',
83
+
84
+ # Helper functions
85
+ 'update_settings',
86
+ 'load_arg_default_from_settings_if_exist',
87
+ ]