Skip to content

Commit

Permalink
remove fetch_quotes/fetch_depth from python http client, broker code …
Browse files Browse the repository at this point in the history
…now fetches bbo/depth from lifecycle methods
  • Loading branch information
calumrussell committed Nov 2, 2024
1 parent 2141ffa commit ba9b8f5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
10 changes: 4 additions & 6 deletions rotala-python/src/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,8 @@ def __init__(self, builder: BrokerBuilder):
# Initializes backtest_id, can ignore result
init_response = self.http.init(self.dataset_name)
self.backtest_id = init_response["backtest_id"]
quotes_resp = self.http.fetch_quotes()
depth_resp = self.http.fetch_depth()
self.latest_quotes = quotes_resp["quotes"]
self.latest_depth = depth_resp["quotes"]
self.latest_quotes = init_response["bbo"]
self.latest_depth = init_response["depth"]
self.ts = list(self.latest_quotes.values())[0]["date"]

def _update_holdings(self, position: str, chg: float):
Expand Down Expand Up @@ -269,10 +267,10 @@ def tick(self):
logger.critical("Sim finished")
exit(0)
else:
self.latest_quotes = self.http.fetch_quotes()["quotes"]
self.latest_quotes = tick_response["bbo"]
self.latest_depth = tick_response["depth"]
if self.latest_quotes:
self.ts = list(self.latest_quotes.values())[0]["date"]
self.latest_depth = self.http.fetch_depth()["quotes"]

curr_value = self.get_current_value()
logger.info(f"{self.backtest_id}-{self.ts} TOTAL VALUE: {curr_value}")
Expand Down
14 changes: 0 additions & 14 deletions rotala-python/src/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,6 @@ def cancel_order(self, order_id):
)
return r.json()

def fetch_quotes(self):
if self.backtest_id is None:
raise ValueError("Called before init")

r = requests.get(f"{self.base_url}/backtest/{self.backtest_id}/fetch_quotes")
return r.json()

def fetch_depth(self):
if self.backtest_id is None:
raise ValueError("Called before init")

r = requests.get(f"{self.base_url}/backtest/{self.backtest_id}/fetch_depth")
return r.json()

def info(self):
if self.backtest_id is None:
raise ValueError("Called before init")
Expand Down

0 comments on commit ba9b8f5

Please sign in to comment.