Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
trigger buy/sell at specified times?

Would it be feasible for to provide a list of times at which to buy/sell a security? The list could be a file that I upload (or if necessary, I could cut and paste the data into the Quantopian editor). For example, for a single security, I could provide a list of times to buy and a list of times to sell. When a backtest is run, buying and selling would be triggered off of the lists.

This would seem to be a straightforward way of enabling users to incorporate external influential events into their algorithms (e.g. weather, news, etc.).

6 responses

Ha! I think that's a brilliant idea. Instead of having to support an infinite amount of alternative data sources we just allow people to feed in their own analysis.

Maybe in conjunction to that, we could have you also add data sources by pointing to any URL with time-series data (e.g. csv uploaded as a gist) to be used in your algorithm. Someone could then extract e.g. twitter data and feed it into his algorithm that way.

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.

Genius idea @Grant! I had a few thoughts and questions:

  • we'd need a datetime field to splice the data into the simulation in chronological order
  • should we required a sid field? some other identification scheme? or maybe no identifier?
  • what are the various ways you would want to expose the data? gist? any URL? dropbox? git?
  • would you want Quantopian to secure and store the data? Or just stream it through memory without storing it?
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.

John & Thomas,

I suggest posting a simple, sample algorithm that users can modify. Rather than dealing with the file upload issue now, just include fields for cut-and-paste. The fields would be lists of times to buy and sell a specified single SID.

You can sort-of do this already by reading

i = sid(1234)  
data[i].datetime.hour  

in your handle_data hook.

Depending on what you want to do, you need to make sure metadata of the sids that are purchased (whether it has already been bought / sold within the timeframe) are persistent between calls to handle_data, but it is doable.

Having an actual time filter would be a lot better though. And speedier.

John,

Conceptually, what I have in mind is to provide the Quantopian backtester with a stack of order sheets, each corresponding to a different SID. Each order sheet would list order times and corresponding order amounts (positive for buy, negative for sell). So, in response to your question above, yes I think it would make sense to require a SID field (e.g. the SID integer ID).

Regarding ways to expose the data, I suggest you first consider how much data you might need to deal with. I suppose that the worst-case scenario would be if a user wanted to order every security in your database every minute of the backtest, extending over the longest time period (2002 to summer 2012):

(10000 SIDS)(1 order/minute)(60 minutes/hour)(7.5 trading hours/day)(250 trading days/year)*(10 years) = 11.25 billion orders

See here for some example code.