Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Congratulations to June contest winner - Michael Van Kleeck

We have an official winner to the June edition of the contest – congratulations to Michael Van Kleeck! You can see the results in the June leaderboard. It was a nail-biter race to the finish.

After running the contest for several months, we have learned quite a lot about launching algorithms -- everything from handling expected exception cases to inspecting the tear sheets. We want to share all these as best practices (see below), and as a first step we are onboarding the winner before s/he goes live. This will allow the winner to reap the full benefits of the contest and maximize the reward over the next 6 months.

To that end, we’re working with Michael and his algo will be deployed very soon.

As we’re building the fund, these are the suggestions we’re advising for algorithms. These are the same suggestions we shared with Michael, and I encourage you to add these to your entries:

  1. Refactor deprecated functions (e.g. update batch_transform to history)
  2. Update hard-coded date logic to use schedule_function instead where possible
  3. Consider replacing manual order calculations with order_target or order_target_percent where appropriate.
  4. Add a guard for open orders in algo logic when using order_target() functions
  5. Verify the algo will backfill any historical data needed to set initial parameters.
  6. Make sure algo is 'aware' of existing portfolio positions at deploy. The algo should handle starts/stops smoothly and pick up the correct positions.
  7. Add logging of intended orders (timing, symbols and order sizes). This helps us monitor that the algo is behaving correctly, and was able to achieve its target positions.

We’re excited to start the onboarding process and help you develop more intelligent, robust algorithms. Keep this list in mind as you’re developing your next strategy.

Cheers,
Alisa

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.

7 responses

This looks like the start of a good list and it probably deserves it's own thread, and unless these items are subsumed in more APIs or available in some framework (I've seen a couple kicked around) they may deserve their own page in the help section. I can think of a couple other items we seem to be taking care of:

  1. Make sure the symbols in your universe are tradable
  2. Have a strategy for handling pending orders
  3. Have guards to ensure you are not over-levered

Anything else?

Paul,

I agree; I could really benefit from a list of best practices for writing algos. I'll add another one:

  1. Remove price and volume objects that have incomplete data (NaN). I have seen this done several ways, but it would be nice to see the best practice methods to accomplish this.

  2. Always add a decimal point to variables that need floating point calculations performed. For example, don't use "1", instead use "1.0" (Someone smarter than me can explain how integer operations are different than floating point. All I know is that this has messed me up multiple times. I think that the default behavior has changed in Python 3.x, but the Q IDE is still using Python 2.x.)

Paul,

I agree that we need a separate thread for this. I could really benefit from a list of best practices for writing algos. I'll add another few:

  1. Remove price and volume objects that have incomplete data (NaN). I have seen this done several ways, but it would be nice to see the best practice methods to accomplish this.

  2. Always add a decimal point to variables that need floating point calculations performed. For example, don't use "1", instead use "1.0" (Someone smarter than me can explain how integer operations are different than floating point. All I know is that this has messed me up multiple times. I think that the default behavior has changed in Python 3.x, but the Q IDE is still using Python 2.x.)

What comes to my mind are:

  1. If algo is using fetcher can there be any guard against breakdown of server hosting .csv file.
  2. If your universe is dynamically created. Is there a mechanism in your algo to address any open positions of equities removed from universe at later date. .

I think that Quantopian needs a bulletin board which supports "sticky" posts, which can only be initiated and maintained by a moderator. Then you could maintain a few helpful checklists.

The ones I think could be really useful include:
1) Best practices for live trading and/or robust algorithms
2) Gotchas in moving code between the IDE and the research environment
3) Useful commonly used routines/code snippets

others?

If "sticky" posts are not on, I'd at least suggest clearly identified threads for each checklist, maintained exclusively be Quantopian, otherwise they will quickly become bogged down with other stuff.

@Alisa, your list is great. Would you be prepared to share some coding ideas to implement them :)

bulletin board which supports "sticky" posts,
+1

  1. Wherever possible, try to avoid parameters, and especially avoid optimizing them to an entire backtest of data. Either pick them based on some fundamental rationale and leave them alone, or have the algo calibrate them on a walk-forward basis.
  2. If you are managing stops in a stateful way (ie: making sure they only move closer to the position), do not save the stop price in context - that will break if the asset has a stock split. Instead, recalculate yesterday's stop using yesterday's price from history().

I'll add more if I think of them.