def buy_sell_logic(self, update):
# Check if the time limit has exceeded
if self.watch.ts >= self.exec_request.end_time:
self._time_exceeded(update)
return
if self.om.num_orders() == 0:
# Send limit order
order_price = self.book.passive_price(self.buysell, num_ticks=0)
order = self.om.create_order('L', self.buysell, self.size, order_price)
self.om.send_order(order)
Metrics
def divide_orders(self):
self._sub_orders = []
for i in range(self.num_orders):
order_size = max(self.size // self._num_orders, 100)
self._sub_orders.append(order_size)
def buy_sell_logic(self, update):
# Check if the time limit has exceeded
if self.watch.ts >= self.exec_request.end_time:
self._time_exceeded(update)
return
# Get the current bucket number
bucket = self._get_bucket()
if self.om.num_orders() == 0 and bucket > self._current_bucket:
# Send limit order
order_size = self._sub_orders[bucket]
order_price = self.book.passive_price(self.buysell, num_ticks=0)
order = self.om.create_order('L', self.buysell, order_size, order_price)
self.om.send_order(order)
Passive TWAP algorithm
def divide_orders(self):
self._sub_orders = []
for i in range(self.num_orders):
order_size = max(self.size // self._num_orders, 100)
self._sub_orders.append(order_size)
def buy_sell_logic(self, update):
# Check if the time limit has exceeded
if self.watch.ts >= self.exec_request.end_time:
self._time_exceeded(update)
return
# Get the latest top price
order_price = self.book.passive_price(self.buysell, 0)
if self.om.num_orders() > 0:
if time_diff >= self._interval:
# Modify to improve/aggressive price
self.om.modify_price(self.buysell, order_price)
# Get the current bucket number
bucket = self._get_bucket()
if self.om.num_orders() == 0 and bucket > self._current_bucket:
# Send limit order
order_size = self._sub_orders[bucket]
order_price = self.book.passive_price(self.buysell, num_ticks=0)
order = self.om.create_order('L', self.buysell, order_size, order_price)
self.om.send_order(order)
Security | Average PNL (bps) |
---|---|
FSTA | 6.11 |
FMAT | 5.86 |
VOX | 5.49 |
VBR | 4.61 |
FIDU | 4.27 |
Security | Average PNL (bps) |
---|---|
IVV | -2.68 |
VUG | -1.45 |
IVE | -1.27 |
XLE | -1.00 |
REM | -0.69 |
Date | Total PNL ($) |
---|---|
2017-07-27 | 4435 |
2017-08-15 | 2642 |
2017-08-23 | 1725 |
2017-03-15 | 1066 |
2017-08-18 | 932 |
Date | Total PNL ($) |
---|---|
2017-08-28 | -2353 |
2017-06-14 | -1964 |
2017-06-09 | -685 |
2017-06-22 | -293 |
2017-09-06 | -267 |
Size | Average PNL (bps) |
---|---|
<500 | 1.20 |
>=500 | 1.05 |