Hi Josh,
You can use the history() function to compare prices across current and previous bars in minute-mode simulation. There are a few different ways you can implement the logic, if you want to compare the current price to yesterday's close price you can follow this example right out of the help docs:
def initialize(context):
set_universe(universe.DollarVolumeUniverse(90.0, 90.1))
def handle_data(context, data):
price_history = history(bar_count=2, frequency='1d', field='price')
for s in data:
prev_bar = price_history[s][-2]
curr_bar = price_history[s][-1]
if curr_bar > prev_bar:
order(s, 20)
The history() function returns a dataframe of historical prices and dates that you can index into to grab the data you want. So in that example price_history[s][-1] is the most recent price for stock 's' and price_history[s][-2] is the price before that one (i.e. yesterday's close).
If you have a simple algo you are trying to get working with this logic feel free to post it and I'd be happy to try to help you debug it.
Best wishes, Jess
Disclaimer
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.