MCPcopy Create free account
hub / github.com/DVampire/FinAgent / _process_price_and_features

Method _process_price_and_features

finagent/processor/processor.py:233–308  ·  view source on GitHub ↗
(self,
                stocks = None,
                start_date = None,
                end_date = None)

Source from the content-addressed store, hash-verified

231 return stocks
232
233 def _process_price_and_features(self,
234 stocks = None,
235 start_date = None,
236 end_date = None):
237
238 start_date = datetime.strptime(start_date if start_date else self.start_date, "%Y-%m-%d")
239 end_date = datetime.strptime(end_date if end_date else self.end_date, "%Y-%m-%d")
240
241 stocks = stocks if stocks else self.stocks
242
243 price_columns = [
244 "open",
245 "high",
246 "low",
247 "close",
248 "volume",
249 "adj_close"
250 ]
251
252 for stock in tqdm(stocks):
253 price = self.path_params["prices"][0]
254 price_type = price["type"]
255 price_path = price["path"]
256
257 price_path = os.path.join(self.root, price_path, "{}.csv".format(stock))
258
259 if price_type == "fmp":
260 price_column_map = {
261 "open": "open",
262 "high": "high",
263 "low": "low",
264 "close": "close",
265 "volume": "volume",
266 "adjClose": "adj_close",
267 }
268 elif price_type == "yahoofinance":
269 price_column_map = {
270 "Open": "open",
271 "High": "high",
272 "Low": "low",
273 "Close": "close",
274 "Volume": "volume",
275 "Date": "timestamp",
276 "Adj Close": "adj_close",
277 }
278 else:
279 price_column_map = {
280 "open": "open",
281 "high": "high",
282 "low": "low",
283 "close": "close",
284 "volume": "volume",
285 "adjClose": "adj_close",
286 }
287
288 assert os.path.exists(price_path), "Price path {} does not exist".format(price_path)
289 price_df = pd.read_csv(price_path)
290

Callers 1

processMethod · 0.95

Calls 2

cal_factorFunction · 0.85
cal_targetFunction · 0.85

Tested by

no test coverage detected