Skip to content

Commit

Permalink
small changes to market replay code
Browse files Browse the repository at this point in the history
  • Loading branch information
mamahfouz committed Jun 17, 2019
1 parent 7c5b525 commit ffd4f3d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
3 changes: 0 additions & 3 deletions agent/ExperimentalAgent.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import pandas as pd

from agent.TradingAgent import TradingAgent


Expand All @@ -14,7 +12,6 @@ def __init__(self, id, name, symbol,
self.quantity = quantity
self.is_buy_order = is_buy_order
self.limit_price = limit_price
self.timestamp = pd.Timestamp("2012-06-21 09:30:02")

def kernelStarting(self, startTime):
super().kernelStarting(startTime)
Expand Down
9 changes: 4 additions & 5 deletions agent/MarketReplayAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,16 @@ def wakeup (self, currentTime):
self.last_trade[self.symbol] = self.oracle.getDailyOpenPrice(self.symbol, self.mkt_open)
if not self.mkt_open or not self.mkt_close:
return
elif currentTime == self.oracle.orderbook_df.iloc[0].name:
order = self.oracle.trades_df.loc[self.oracle.trades_df.timestamp == currentTime]
order = self.oracle.trades_df.loc[self.oracle.trades_df.timestamp == currentTime]
wake_up_time = self.oracle.trades_df.loc[self.oracle.trades_df.timestamp > currentTime].iloc[0].timestamp
if currentTime == self.oracle.orderbook_df.iloc[0].name:
self.placeMktOpenOrders(order, t=currentTime)
self.setWakeup(self.oracle.trades_df.loc[self.oracle.trades_df.timestamp > currentTime].iloc[0].timestamp)
elif (currentTime > self.mkt_open) and (currentTime < self.mkt_close):
try:
order = self.oracle.trades_df.loc[self.oracle.trades_df.timestamp == currentTime]
self.placeOrder(currentTime, order)
self.setWakeup(self.oracle.trades_df.loc[self.oracle.trades_df.timestamp > currentTime].iloc[0].timestamp)
except Exception as e:
log_print(e)
self.setWakeup(wake_up_time)


def receiveMessage (self, currentTime, msg):
Expand Down
4 changes: 2 additions & 2 deletions config/marketreplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@
# 7) Data Oracle
oracle = OrderBookOracle(symbol='AAPL',
date='2012-06-21',
orderbook_file_path='C:/_code/py/air/abides_open_source/abides/data/LOBSTER/AAPL_2012-06-21_34200000_57600000_orderbook_10.csv',
message_file_path='C:/_code/py/air/abides_open_source/abides/data/LOBSTER/AAPL_2012-06-21_34200000_57600000_message_10.csv',
orderbook_file_path='C:/_code/py/air/abides_open_source/abides/data/lob_data/AAPL_2012-06-21_34200000_57600000_orderbook_10.csv',
message_file_path='C:/_code/py/air/abides_open_source/abides/data/lob_data/AAPL_2012-06-21_34200000_57600000_message_10.csv',
num_price_levels=10)

kernel.runner(agents = agents, startTime = kernelStartTime,
Expand Down

0 comments on commit ffd4f3d

Please sign in to comment.