This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OrderManager(object): | |
""" A helper for placing and tracking orders in Quantopian. """ | |
def __init__(self): | |
self.orders = [] | |
self.context = None | |
self.data = None | |
def update(self, context, data): | |
self.context = context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This is an example of a one-or-the-other order, generalised as an any-one order. Useful when setting orders around a price point, such that if one order is triggered (begins to fill) the other orders are cancelled. | |
""" | |
class AnyOneOrder(object): | |
""" A group of orders where when one order is triggered, all other open orders are cancelled. """ | |
def __init__(self, *orders_or_ids): | |
self.order_ids = set( | |
map(self._get_id, orders_or_ids) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Prefix a string with an icon | |
def iconify(label, icon, options = {}) | |
"#{ icon(icon, options) } #{ label }".strip.html_safe | |
end | |
## | |
# Create a label | |
def llabel(text, kind = :default) | |
content_tag(:span, text, class: [ 'label', "label-#{ kind }" ].compact) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This should go into spec/support/auth_spec_helpers.rb | |
module AuthSpecHelpers | |
## | |
# Convenience method for setting the Digest Authentication details. | |
# To use, pass the username and password. | |
# The method and target are used for the initial request to get the digest auth headers. These will be translated into 'get :index' for example. | |
# The final 'header' parameter sets the request's authentication headers. | |
def authenticate_with_http_digest(user, password, method = :get, target = :index, header = 'HTTP_AUTHORIZATION') |