Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How To Buy on specific time of day.?

Hello All,

How to Check Price of security on specific time let's say 9.35?

Thank You.

9 responses

I think schedule_function will help you out here: https://www.quantopian.com/help/#ide-schedulefunction

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.

Here is an example.

thank You for you prompt reply,

What about using IF statement.

IF Time="9:35" do so and so.

Is this possible at All??

Yup! That is the intention behind schedule_function. By setting the minutes offset (by 5 in your case) you can do what you want.

Will Try, Thanks a lot.

I tryed to create 2 variable open_price at 9:32 and close_price at 15:55
got error open_price not defined, what I'm doing wrong??
I want to store price in variable at specific time.
Thanks.

import pandas as pd

def initialize(context):

schedule_function(func= openprice,date_rule=date_rules.every_day(),  
                  time_rule=time_rules.market_open(hours=0, minutes=1))  

schedule_function(func= closeprice,date_rule=date_rules.every_day(),  
                  time_rule=time_rules.market_open(hours=0, minutes=384))

def handle_data(context, data):
pass

def openprice(context,data):
open_price = data.current(symbol('F'),'price')

def closeprice(context,data):
close_price = data.current(symbol('F'),'price')

if close_price>open_price:  
    order(symbol('F'),100) 

elif close_price<open_price:  
    order(symbol('F'),-100)

This is the runtime error that i'm receiving

NameError: global name 'open_price' is not defined

The function you define is called openprice but you're trying to call open_price

Nothing Works!.

Let me simplify my problem,

I need to store price of 'F' at 9:31 in a variable "openprice"

Please Help!!!

Hi Zabrodin,

Try this may be it will fit your needs.