Hi Gabriel have you written any code yet? If yes, can you post your algo - I can try to help, and you will find many extremely helpful folks in the Q community. If you have not started coding do you have any of the signals being generated outside Q like Excel? If yes, you can import the orders using Fetcher. Below is a shell to import data you can modify for your use.
Best wishes with your strategy, Savio
import pytz
import pandas as pd
import datetime
Initialize the timezone:
EST = pytz.timezone('US/Eastern')
def preview(df):
log.info(' \n %s ' % df.head(10))
return df
def initialize(context):
fetch_csv('insert URL or link to csv', pre_func = preview)
Initialize slippage settings - I was told to use the default slippage so you might want to do that - volume slippage is not the default
set_slippage(slippage.VolumeShareSlippage(volume_limit=.5, price_impact=0))
these are the IB fees
set_commission(commission.PerShare(cost=0.005, min_trade_cost=1))
end of day - change minutes to 2 if that is what you prefer
schedule_function(end_of_day, date_rule = date_rules.every_day(), time_rule = time_rules.market_close(minutes=1))
def handle_data(context, data):
ESTdate = get_datetime().astimezone(EST)
for stock in data.fetcher_assets:
test for market open by timestamp - you can add any other conditions - data.current will pull information both from fetcher and the minute bars
if ESTdate.hour == 9 and ESTdate.minute == 31:
Place order for day for example
order(stock, shares, style=LimitOrder(limit))
get_order(order_id) will give you the order details
add the bracket order - profit taker, stop loss condition
close out positions at the close - note that depending on your slippage settings your order at the close may not be completely filled so you will need to keep that in mind - also read the post on volume discrepancies - you will get quite a bit of insight into Q data - worth noting that open, high, low, close, volume are related to the data in each minute, not the day overall - as far as I know
def end_of_day(context, data):
for stock in context.portfolio.positions:
order_target_percent(stock, 0)