Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def run(self, prices, timestamp, cash, **kwargs):
symbol = "AAPL"
orders = Orders()
if (prices.loc[timestamp, symbol] * 100) < cash:
orders.add_order(symbol, 100)
return orders
def __init__(self, *args):
super(Orders, self).__init__()
self.extend(args)
def run(self, prices, timestamp, cash, **kwargs):
symbol = "AAPL"
orders = Orders()
if (prices.loc[timestamp, symbol] * 100) < cash:
orders.add_order(symbol, 100)
return orders
def run(self, prices, timestamp, cash, data, **kwargs):
""" Takes bollinger event data and generates orders """
events = data['events']
if not hasattr(self, 'sell_orders'):
self.setup(events)
orders = Orders()
# Find buy events for this timestamp
timestamps = prices.index
daily_data = events.loc[timestamp]
order_series = daily_data[daily_data > 0]
# Sell 5 market days after bought
index = timestamps.get_loc(timestamp)
if index + 5 >= len(timestamps):
sell_datetime = timestamps[-1]
else:
sell_datetime = timestamps[index + 5]
symbols = order_series.index
self.sell_orders.loc[sell_datetime, symbols] -= 100
daily_sell_data = self.sell_orders.loc[timestamp]
daily_sell_orders = daily_sell_data[daily_sell_data != 0]