Skip to content

Commit

Permalink
Update extractor.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Seanman519 authored Apr 1, 2024
1 parent ae4ac33 commit 06863aa
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions rlbot/data/extractor.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
"""Function related to extract data from 3rd party and data stores."""
from __future__ import annotations

import _pickle as cPickle

import pandas as pd
import requests

from rlbot.utils.configs.constants import mt5_api_port_map
from rlbot.utils.configs.constants import mt5_creds
from rlbot.utils.logging import get_logger
from rlbot.workflows.service_manager import start_mt5_api
from releat.utils.configs.constants import mt5_api_port_map
from releat.utils.configs.constants import mt5_creds
from releat.utils.logging import get_logger
from releat.workflows.service_manager import start_mt5_api


logger = get_logger(__name__)
Expand Down Expand Up @@ -41,16 +40,16 @@ def download_tick_data(broker, symbol, dt0, dt1, data_mode, check_api=True, time
"""
port = mt5_api_port_map[broker][symbol]
if check_api:
resp = requests.get(f"http://127.0.0.1:{port}/healthcheck")
resp = requests.get(f"http://127.0.0.1:2000/healthcheck")
if resp.status_code != 200:
logger.warning(f"Connection error to port {port}. Initializing...")
logger.warning(f"Connection error to port 2000. Initializing...")
start_mt5_api(broker, symbol)
resp = requests.get(f"http://127.0.0.1:{port}/healthcheck")
assert resp.stats_code == 200, f"http://127.0.0.1:{port} failed to initialize"
resp = requests.get(f"http://127.0.0.1:2000/healthcheck")
assert resp.stats_code == 200, f"http://127.0.0.1:2000 failed to initialize"

mt5_config = mt5_creds[broker][data_mode]
resp = requests.post(f"http://127.0.0.1:{port}/init", json=mt5_config)
logger.info(f"Connection success to port {port}")
resp = requests.post(f"http://127.0.0.1:2000/init", json=mt5_config)
logger.info(f"Connection success to port 2000")

dt0 = dt0.strftime("%Y-%m-%d %H:%M:%S.%f")
dt1 = dt1.strftime("%Y-%m-%d %H:%M:%S.%f")
Expand All @@ -62,7 +61,7 @@ def download_tick_data(broker, symbol, dt0, dt1, data_mode, check_api=True, time
}

resp = requests.get(
f"http://127.0.0.1:{port}/get_tick_data",
f"http://127.0.0.1:2000/get_tick_data",
json=d_request,
timeout=timeout,
)
Expand Down

0 comments on commit 06863aa

Please sign in to comment.