azapyGUI 0.0.1__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.
- azapyGUI/AppSettingsPage.py +213 -0
- azapyGUI/AppSettingsPageMisc.py +101 -0
- azapyGUI/AppSettingsWindow.py +52 -0
- azapyGUI/BacktestComputation.py +166 -0
- azapyGUI/BacktestEntryWindow.py +307 -0
- azapyGUI/BacktestMenuPortfolioWindow.py +20 -0
- azapyGUI/CloneMenuPortfolioWindow.py +93 -0
- azapyGUI/CrossHairBCursor.py +80 -0
- azapyGUI/DF_Window.py +63 -0
- azapyGUI/DF_table.py +282 -0
- azapyGUI/EditMenuPortfolioWindow.py +16 -0
- azapyGUI/EditPortfolioWindow.py +475 -0
- azapyGUI/EntryClonePortfolioWindow.py +35 -0
- azapyGUI/EntryNameWindow.py +55 -0
- azapyGUI/EntryRenamePortfolioWindow.py +33 -0
- azapyGUI/GetMktData.py +85 -0
- azapyGUI/MenuApp.py +194 -0
- azapyGUI/MktDataFrame.py +129 -0
- azapyGUI/MktDataNode.py +34 -0
- azapyGUI/ModelParamEditWindow.py +143 -0
- azapyGUI/NrShares_table.py +54 -0
- azapyGUI/PortAnalyseWindow.py +179 -0
- azapyGUI/PortDataNode.py +180 -0
- azapyGUI/PortfolioFrame.py +197 -0
- azapyGUI/RebalanceMenuPortfolioWindow.py +21 -0
- azapyGUI/RemoveMenuPortfolioWindow.py +33 -0
- azapyGUI/SaveMenuPortfolioWindow.py +36 -0
- azapyGUI/Scrollable.py +60 -0
- azapyGUI/SelectOneWindow.py +65 -0
- azapyGUI/SymbAnalyseWindow.py +21 -0
- azapyGUI/SymbExtractWindow.py +129 -0
- azapyGUI/SymbTableEntry.py +109 -0
- azapyGUI/TimeSeriesViewWindow.py +480 -0
- azapyGUI/ViewTip.py +72 -0
- azapyGUI/WeightsWindow.py +352 -0
- azapyGUI/__init__.py +6 -0
- azapyGUI/azHelper.py +27 -0
- azapyGUI/azapyApp.py +89 -0
- azapyGUI/config.py +35 -0
- azapyGUI/configHelps.py +84 -0
- azapyGUI/configMSG.py +194 -0
- azapyGUI/configModels.py +519 -0
- azapyGUI/configPlot.py +70 -0
- azapyGUI/configSettings.py +138 -0
- azapyGUI/configTips.py +240 -0
- azapyGUI/mktDataValidation.py +42 -0
- azapyGUI/modelParametersValidation.py +442 -0
- azapyGUI/serviceMasterUserConfig.py +28 -0
- azapyGUI/tkHelper.py +18 -0
- azapyGUI-0.0.1.dist-info/LICENSE +674 -0
- azapyGUI-0.0.1.dist-info/METADATA +126 -0
- azapyGUI-0.0.1.dist-info/RECORD +54 -0
- azapyGUI-0.0.1.dist-info/WHEEL +5 -0
- azapyGUI-0.0.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import azapyGUI.configTips as configTips
|
|
3
|
+
from azapyGUI.modelParametersValidation import _validDateMMDDYYYY, _validInt, _validIntNegative, _validIntPositive
|
|
4
|
+
|
|
5
|
+
Version = '0.0.1'
|
|
6
|
+
|
|
7
|
+
settings_model = {"Directors": {"UserPortfolioDirectory": {"default": None,
|
|
8
|
+
"type": 'ButtonDir',
|
|
9
|
+
"field": 'Portfolios Directory',
|
|
10
|
+
"tip": configTips._settings_UserPortfolioDirectory_tip,
|
|
11
|
+
"title": 'Portfolios Directory',
|
|
12
|
+
},
|
|
13
|
+
"UserMktDataDirectory": {"default": None,
|
|
14
|
+
"type": 'ButtonDir',
|
|
15
|
+
"field": 'Market Data Directory',
|
|
16
|
+
"tip": configTips._settings_UserMktDataDirectory_tip,
|
|
17
|
+
"title": 'Market Data Directory',
|
|
18
|
+
},
|
|
19
|
+
"UserOutputDirectory": {"default": None,
|
|
20
|
+
"type": 'ButtonDir',
|
|
21
|
+
"field": 'Data Output Directory',
|
|
22
|
+
"tip": configTips._settings_UserOutputDirectory_tip,
|
|
23
|
+
"title": 'Data Output Directory'
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
"MkTData": {"Provider": {"default": {'yahoo': {}},
|
|
27
|
+
"type": 'MCheckbutton',
|
|
28
|
+
"field": "Market data provider",
|
|
29
|
+
"tip": configTips._settings_MkTDataProvider_tip,
|
|
30
|
+
"values": {"yahoo": {},
|
|
31
|
+
"alphavantage": {"key": {"default": None,
|
|
32
|
+
"type": 'str',
|
|
33
|
+
"field": 'Provider Access Key',
|
|
34
|
+
"tip": configTips._settings_porviderKey_tip,
|
|
35
|
+
"envkey": 'ALPHAVANTAGE_API_KEY',
|
|
36
|
+
},
|
|
37
|
+
"max_req_per_min": {"default": 50,
|
|
38
|
+
"type": 'int',
|
|
39
|
+
"field": 'Max Requests / minute',
|
|
40
|
+
"tip": configTips._settings_max_req_per_min_tip,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
"eofhistoricaldata": {"key": {"default": None,
|
|
44
|
+
"type": 'str',
|
|
45
|
+
"field": 'Provider Access Key',
|
|
46
|
+
"tip": configTips._settings_porviderKey_tip,
|
|
47
|
+
"envkey": 'EODHISTORICALDATA_API_KEY',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
"marketstack": {"key": {"default": None,
|
|
51
|
+
"type": 'str',
|
|
52
|
+
"field": 'Provider Access Key',
|
|
53
|
+
"tip": configTips._settings_porviderKey_tip,
|
|
54
|
+
"envkey": 'MARKETSTACK_API_KEY',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
"force": {"default": False,
|
|
60
|
+
"type": 'Checkbutton',
|
|
61
|
+
"field": 'force',
|
|
62
|
+
"tip": configTips._settings_force_default_tip,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
"Miscellaneous": {"edate": {"default": 'today',
|
|
67
|
+
"type": 'Entry',
|
|
68
|
+
"field": '"edate" default value',
|
|
69
|
+
"tip": configTips._settings_edate_default_tip,
|
|
70
|
+
"validate": _validDateMMDDYYYY,
|
|
71
|
+
},
|
|
72
|
+
"sdate": {"default": '1/1/2012',
|
|
73
|
+
"type": 'Entry',
|
|
74
|
+
"field": '"sdate" default value',
|
|
75
|
+
"tip": configTips._settings_sdate_default_tip,
|
|
76
|
+
"validate": _validDateMMDDYYYY,
|
|
77
|
+
},
|
|
78
|
+
"noffset": {"default": -3,
|
|
79
|
+
"type": 'Entry',
|
|
80
|
+
"field": '"noffset" default value',
|
|
81
|
+
"tip": configTips._settings_noffset_default_tip,
|
|
82
|
+
"validate": _validInt,
|
|
83
|
+
},
|
|
84
|
+
"fixoffset": {"default": -1,
|
|
85
|
+
"type": 'Entry',
|
|
86
|
+
"field": '"fixoffset" default value',
|
|
87
|
+
"tip": configTips._settings_fixoffset_default_tip,
|
|
88
|
+
"validate": _validIntNegative,
|
|
89
|
+
},
|
|
90
|
+
"capital": {"default": 100000,
|
|
91
|
+
"type": 'Entry',
|
|
92
|
+
"field": 'Capital default value',
|
|
93
|
+
"tip": configTips._settings_capital_default_tip,
|
|
94
|
+
"validate": _validIntPositive,
|
|
95
|
+
},
|
|
96
|
+
"nsh_round": {"default": True,
|
|
97
|
+
"type": 'Checkbutton',
|
|
98
|
+
"field": 'Int. nr. shares',
|
|
99
|
+
"tip": configTips._settings_nsh_round_default_tip,
|
|
100
|
+
},
|
|
101
|
+
"OpenExcel": {"default": False,
|
|
102
|
+
"type": 'Checkbutton',
|
|
103
|
+
"field": 'Open Excel',
|
|
104
|
+
"tip": configTips._settings_OpenExcel_tip,
|
|
105
|
+
},
|
|
106
|
+
"ShowTips": {"default": True,
|
|
107
|
+
"type": 'Checkbutton',
|
|
108
|
+
"field": 'Show Tips',
|
|
109
|
+
"tip": configTips._settings_ShowTips_tip,
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
},
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def get_settings_default(category):
|
|
118
|
+
rout = {kk: vv["default"] for kk, vv in settings_model[category].items()}
|
|
119
|
+
return rout
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def get_settings_default_all():
|
|
123
|
+
rout = {}
|
|
124
|
+
rout["Version"] = Version
|
|
125
|
+
for category in settings_model.keys():
|
|
126
|
+
rout.update(get_settings_default(category))
|
|
127
|
+
return rout
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def get_envkey_valriable_name(provider):
|
|
131
|
+
return settings_model["MkTData"]["Provider"]["values"][provider]["key"]["envkey"]
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def get_envkey(provider):
|
|
135
|
+
return os.getenv(get_envkey_valriable_name(provider))
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
MasterApplicationSettings = None
|
azapyGUI/configTips.py
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
_rtype_param_tip = "Optimization type for risk-based strategies."
|
|
2
|
+
|
|
3
|
+
_mu_param_tip = "Targeted portfolio expected rate of return."
|
|
4
|
+
|
|
5
|
+
_mu0_param_tip = "Risk-free rate accessible to the investor."
|
|
6
|
+
|
|
7
|
+
_aversion_param_tip = "The value of the risk-aversion coefficient."
|
|
8
|
+
|
|
9
|
+
_ww0_param_tip = \
|
|
10
|
+
"Targeted portfolio weights. List of int>=0.\n\
|
|
11
|
+
Size = number of port components. Otherwise padded with 1 or right truncated."
|
|
12
|
+
|
|
13
|
+
_diver_param_tip = "Targeted portfolio diversification factor."
|
|
14
|
+
|
|
15
|
+
_freq_param_tip = "Rate of return horizon: Q - quarterly, M - monthly."
|
|
16
|
+
|
|
17
|
+
_method_lin_param_tip = "Liner Programming numerical library."
|
|
18
|
+
|
|
19
|
+
_method_socp_param_tip = "Second Order Cone Programming numerical library."
|
|
20
|
+
|
|
21
|
+
_method_exp_param_tip = \
|
|
22
|
+
"Exponential Cone Programming numerical library.\n\
|
|
23
|
+
excp is using ecos, while ncp and ncp2 are using cvxopt numerical libraries."
|
|
24
|
+
|
|
25
|
+
_method_quad_param_tip = "Quadratic Programming numerical library."
|
|
26
|
+
|
|
27
|
+
_hlength_val_param_tip = \
|
|
28
|
+
"History length in number of years used for calibration\n\
|
|
29
|
+
(rounded to months), float >= 0.5."
|
|
30
|
+
|
|
31
|
+
_col_calibration_param_tip = \
|
|
32
|
+
"Name of the price column from market data used in the weight’s calibration."
|
|
33
|
+
|
|
34
|
+
_ftype_param_tip = "Filter name."
|
|
35
|
+
|
|
36
|
+
_fw_param_tip = "Filter weights: list of 4 int >=0."
|
|
37
|
+
|
|
38
|
+
_nw_param_tip = "Maximum number of selected symbols: int >=1."
|
|
39
|
+
|
|
40
|
+
_threshold_param_tip = \
|
|
41
|
+
"Minimum number of symbols with positive momentum\n\
|
|
42
|
+
for a full capital allocation: int >=nw."
|
|
43
|
+
|
|
44
|
+
_Dual_Momentum_model_tip = "Dual Momentum filter."
|
|
45
|
+
|
|
46
|
+
_corr_threshold_param_tip = "Cluster correlation threshold': float [-1,1]."
|
|
47
|
+
|
|
48
|
+
_Correlation_Clustering_model_tip = "Correlation Clustering filter."
|
|
49
|
+
|
|
50
|
+
_alpha_mCVaR_param_tip = \
|
|
51
|
+
"List of distinct confidence levels, float in (0.5, 1)."
|
|
52
|
+
|
|
53
|
+
_coef_param_tip = \
|
|
54
|
+
"Mixture weights, list of float >0, same size as alpha,\n\
|
|
55
|
+
otherwise padded with 1 or right truncated."
|
|
56
|
+
|
|
57
|
+
_mCVaR_model_tip = "Mixture Conditional Value at Risk measure."
|
|
58
|
+
|
|
59
|
+
_alpha_mSMCR_param_tip = \
|
|
60
|
+
"List of distinct confidence levels, float in (0.5, 1)."
|
|
61
|
+
|
|
62
|
+
_mSMCR_model_tip = "Mixture Second Moment Coherent Risk measure."
|
|
63
|
+
|
|
64
|
+
_alpha_mEVaR_param_tip = \
|
|
65
|
+
"List of distinct confidence levels, float in (0.5, 1)."
|
|
66
|
+
|
|
67
|
+
_mEVaR_model_tip = "Mixture Entropic Value at Risk measure."
|
|
68
|
+
|
|
69
|
+
_coef_mMAD_param_tip = \
|
|
70
|
+
"Mixture weights.\n\
|
|
71
|
+
Positive non-increasing list of mixture coefficients, float in (0, 1]."
|
|
72
|
+
|
|
73
|
+
_mMAD_model_tip = "m-level Mean Absolute Deviation risk measure."
|
|
74
|
+
|
|
75
|
+
_mLSD_model_tip = "m-level Lower Semi-Deviation risk measure."
|
|
76
|
+
|
|
77
|
+
_alpha_mBTAD_param_tip = \
|
|
78
|
+
"List of distinct rates threshold levels, float in (-1, 1)."
|
|
79
|
+
|
|
80
|
+
_coef_BTAD_param_tip = \
|
|
81
|
+
"Mixture weights, list of float >0, same size as alpha,\n\
|
|
82
|
+
otherwise padded with 1 or right truncated."
|
|
83
|
+
|
|
84
|
+
_detrended_param_tip = "True - rates of return are detrended (mean=0)."
|
|
85
|
+
|
|
86
|
+
_mBTAD_model_tip = "Mixture Below Threshold Absolute Deviation measure."
|
|
87
|
+
|
|
88
|
+
_mBTSD_model_tip = "Mixture Below Target Semi-Deviation measure."
|
|
89
|
+
|
|
90
|
+
_GINI_model_tip = "Gini risk measure."
|
|
91
|
+
|
|
92
|
+
_SD_model_tip = "Standard Deviation risk measure."
|
|
93
|
+
|
|
94
|
+
_MV_model_tip = "Mean Variance measure."
|
|
95
|
+
|
|
96
|
+
_Equal_Weighted_model_tip = "Equal weighted portfolio."
|
|
97
|
+
|
|
98
|
+
_Inverse_Volatility_model_tip = "Inverse Volatility model."
|
|
99
|
+
|
|
100
|
+
_Inverse_Variance_model_tip = "Inverse Variance model."
|
|
101
|
+
|
|
102
|
+
_Inverse_Drawdown_model_tip = "Inverse Maximum Drawdown model."
|
|
103
|
+
|
|
104
|
+
_rtype_Kelly_param_tip = \
|
|
105
|
+
"Optimization method:\n\
|
|
106
|
+
ExpCone - exponential cone programming,\n\
|
|
107
|
+
Full - non-linear solver,\n\
|
|
108
|
+
Order2 - quadratic programming for second order Taylor approx."
|
|
109
|
+
|
|
110
|
+
_Kelly_model_tip = "Kelly's portfolio strategy."
|
|
111
|
+
|
|
112
|
+
_dirichlet_alpha_param_tip = \
|
|
113
|
+
"List of Dirichlet alpha coefficients (for Monte-Carlo simulations)\n\
|
|
114
|
+
Size = number of port components. Otherwise padded with 1 or right truncated."
|
|
115
|
+
|
|
116
|
+
_variance_reduction_param_tip = \
|
|
117
|
+
"A value of 1 triggers the Monte Carlo variance reduction procedure."
|
|
118
|
+
|
|
119
|
+
_mc_seed_param_tip = \
|
|
120
|
+
"Random number generator seed."
|
|
121
|
+
|
|
122
|
+
_nr_batches_param_tip = \
|
|
123
|
+
"Number of Monte Carlo batches."
|
|
124
|
+
|
|
125
|
+
_mc_paths_param_tip = \
|
|
126
|
+
"Number of Monte Carlo simulations per batch per variance reduction mode."
|
|
127
|
+
|
|
128
|
+
_univ_hlength_val_param_tip = \
|
|
129
|
+
"History length in number of years. The larger the better. \
|
|
130
|
+
A typical value is 12."
|
|
131
|
+
|
|
132
|
+
_Universal_model_tip = \
|
|
133
|
+
"Universal Portfolio strategy. \
|
|
134
|
+
Any additional selector model will be ignored.",
|
|
135
|
+
|
|
136
|
+
_settings_UserPortfolioDirectory_tip = \
|
|
137
|
+
"Default folder to save portfolio collection."
|
|
138
|
+
|
|
139
|
+
_settings_UserMktDataDirectory_tip = \
|
|
140
|
+
"Working directory for temporary market data"
|
|
141
|
+
|
|
142
|
+
_settings_UserOutputDirectory_tip = \
|
|
143
|
+
"Default folder for user reports etc."
|
|
144
|
+
|
|
145
|
+
_settings_MkTDataProvider_tip = \
|
|
146
|
+
"Name of historical market data provider."
|
|
147
|
+
|
|
148
|
+
_settings_porviderKey_tip = \
|
|
149
|
+
"Market data provider access key \
|
|
150
|
+
(if is not already set as an environment variable)."
|
|
151
|
+
|
|
152
|
+
_settings_max_req_per_min_tip = \
|
|
153
|
+
"Maximum number of requests per minute (as specified by the provider)."
|
|
154
|
+
|
|
155
|
+
_settings_ShowTips_tip = \
|
|
156
|
+
"Set visibility for widget tips."
|
|
157
|
+
|
|
158
|
+
_settings_edate_default_tip = \
|
|
159
|
+
"Default end data for market data (e.g. today or 1/1/2024 etc.)."
|
|
160
|
+
|
|
161
|
+
_settings_sdate_default_tip = \
|
|
162
|
+
"Default starting date for market data (e.g. 1/1/2012)."
|
|
163
|
+
|
|
164
|
+
_settings_noffset_default_tip = \
|
|
165
|
+
"Default rebalancing date as offset days relative to investment period \
|
|
166
|
+
end (e.g. -3)."
|
|
167
|
+
|
|
168
|
+
_settings_fixoffset_default_tip = \
|
|
169
|
+
"Default fixing date as offset days relative to rebalancing date (e.g. -1)."
|
|
170
|
+
|
|
171
|
+
_settings_capital_default_tip = \
|
|
172
|
+
"Default initial (cash) Capital value."
|
|
173
|
+
|
|
174
|
+
_settings_nsh_round_default_tip = \
|
|
175
|
+
"Default setting for the quantity of shares as a whole number."
|
|
176
|
+
|
|
177
|
+
_settings_force_default_tip = \
|
|
178
|
+
"Default value for the force flag in market data retrieving procedure."
|
|
179
|
+
|
|
180
|
+
_settings_OpenExcel_tip = \
|
|
181
|
+
"Auto open Excel when an xlsx file is saved."
|
|
182
|
+
|
|
183
|
+
_epw_portfolio_name_tip = \
|
|
184
|
+
"Short, unique, name to identify the portfolio."
|
|
185
|
+
|
|
186
|
+
_bkt_edate_tip = \
|
|
187
|
+
"Backtesting end date (e.g. today)."
|
|
188
|
+
|
|
189
|
+
_bkt_sdate_tip = \
|
|
190
|
+
"Backtesting start date (e.g. 1/1/2012)."
|
|
191
|
+
|
|
192
|
+
_bkt_noffset_tip = \
|
|
193
|
+
"Rebalancing date, as number of business days offset relative to the end \
|
|
194
|
+
of investment period (end of month or quarter). A typical value is -3."
|
|
195
|
+
|
|
196
|
+
_bkt_fixoffset_tip = \
|
|
197
|
+
"Fixing date, as number of business days offset relative to the rebalancing \
|
|
198
|
+
date (always a <=0). A typical value is -1."
|
|
199
|
+
|
|
200
|
+
_bkt_capital_tip = \
|
|
201
|
+
"Initial capital (cash value), e.g. 100000."
|
|
202
|
+
|
|
203
|
+
_bkt_nsh_round_tip = \
|
|
204
|
+
"Check to set the number of shares as whole numbers."
|
|
205
|
+
|
|
206
|
+
_bkt_provider_tip = \
|
|
207
|
+
"Market data provider."
|
|
208
|
+
|
|
209
|
+
_bkt_force_tip = \
|
|
210
|
+
"Check to force a fresh reading of market data from the Provider \
|
|
211
|
+
(ignoring the local buffer) - potentially slowing the application."
|
|
212
|
+
|
|
213
|
+
_reb_as_of_tip = \
|
|
214
|
+
"Reference date - the weights will be computed using the latest closing \
|
|
215
|
+
relative to this day."
|
|
216
|
+
|
|
217
|
+
_reb_cash_tip = \
|
|
218
|
+
"Additional cash to be added at the rebalancing (a negative value is a \
|
|
219
|
+
reduction of the reinvested total capital)."
|
|
220
|
+
|
|
221
|
+
_reb_nsh_round_tip = _bkt_nsh_round_tip
|
|
222
|
+
|
|
223
|
+
_reb_provider_tip = _bkt_provider_tip
|
|
224
|
+
|
|
225
|
+
_reb_force_tip = _bkt_force_tip
|
|
226
|
+
|
|
227
|
+
_sew_symb_tip = \
|
|
228
|
+
"Comma delimited list of symbols"
|
|
229
|
+
|
|
230
|
+
_sew_edate_tip = \
|
|
231
|
+
"Market data end date (e.g. today or 1/1/2024 etc.)."
|
|
232
|
+
|
|
233
|
+
_sew_sdate_tip = \
|
|
234
|
+
"Market data start date (e.g. 1/1/2012, or empty to get the most recent hist. data only)."
|
|
235
|
+
|
|
236
|
+
_sew_provider_tip = \
|
|
237
|
+
"Market data provider."
|
|
238
|
+
|
|
239
|
+
_sew_force_tip = \
|
|
240
|
+
"Check to force market data reding from provider (slower)."
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
|
|
3
|
+
import azapyGUI.config as config
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def sdate_edate_validate(sdate, edate):
|
|
7
|
+
try:
|
|
8
|
+
_sdate, _edate = _mkt_sedate(sdate, edate)
|
|
9
|
+
except:
|
|
10
|
+
msg = "Warning: wrong date format"
|
|
11
|
+
return False, msg, False
|
|
12
|
+
|
|
13
|
+
if _edate < _sdate:
|
|
14
|
+
msg = "Warning: end date smaller than start data"
|
|
15
|
+
return False, msg, False
|
|
16
|
+
|
|
17
|
+
return True, _sdate, _edate
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def mkt_today():
|
|
21
|
+
dn = pd.Timestamp.now(tz='America/New_York')
|
|
22
|
+
reftime = dn.replace(hour=16, minute=0, second=0, microsecond=0)
|
|
23
|
+
if dn > reftime: return dn.normalize().tz_localize(None)
|
|
24
|
+
|
|
25
|
+
return config._bday.rollback(dn - pd.Timedelta(1, 'day')).normalize().tz_localize(None)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _mkt_sedate(sdate, edate):
|
|
29
|
+
dn = pd.Timestamp.now(tz='America/New_York')
|
|
30
|
+
refdate = dn.replace(hour=16, minute=0, second=0, microsecond=0)
|
|
31
|
+
if dn > refdate:
|
|
32
|
+
refdate = config._bday.rollback(refdate).normalize().tz_localize(None)
|
|
33
|
+
else:
|
|
34
|
+
refdate = config._bday.rollback(refdate - pd.Timedelta(1, 'day')).normalize().tz_localize(None)
|
|
35
|
+
edate = min(pd.to_datetime(edate).normalize().tz_localize(None), refdate)
|
|
36
|
+
if sdate == '':
|
|
37
|
+
sdate = edate
|
|
38
|
+
elif sdate.strip('-').isnumeric() and (int(sdate) <= 0):
|
|
39
|
+
sdate = edate + int(sdate) * config._bday
|
|
40
|
+
else:
|
|
41
|
+
sdate = config._bday.rollforward(sdate).normalize().tz_localize(None)
|
|
42
|
+
return sdate, edate
|