Contents
Brokerages
Atreyu
Introduction
QuantConnect enables you to run your algorithms in live mode with real-time market data. We have successfully hosted more than 200,000 live algorithms and have had more than $15B in volume traded on our servers since 2015. Brokerages supply a connection to the exchanges so that you can automate orders using LEAN. You can use multiple data feeds in live trading algorithms.
Atreyu Trading was founded by George Kledaras and John Pyrovolakis in 2015 with the goal to connect quantitative managers to US markets. Atreyu Trading provides access to US prime brokers for clients from all countries that are not on the FinCen Anti-Money Laundering list. In addition to market access, Atreyu Trading provides information about short availability. Atreyu Trading doesn't have regulatory approval to trade for retail accounts, so you need to be a high net worth ($25M+) individual or firm to open an account. You need an organization on the Trading Firm or Institution tier to use the Atreyu Trading brokerage.
Account Types
Atreyu Trading supports cash and margin accounts.
SetBrokerageModel(BrokerageName.Atreyu, AccountType.Cash); SetBrokerageModel(BrokerageName.Atreyu, AccountType.Margin);
self.SetBrokerageModel(BrokerageName.Atreyu, AccountType.Cash) self.SetBrokerageModel(BrokerageName.Atreyu, AccountType.Margin)
Create an Account
Contact Atreyu Trading to create an Atreyu Trading account.
Paper Trading
The Atreyu Trading brokerage doesn't support paper trading, but you can follow these steps to simulate it:
- In the
Initialize
method of your algorithm, add one of the precedingSetBrokerageModel
method calls. - Deploy your algorithm with the QuantConnect Paper Trading brokerage.
Asset Classes
Atreyu Trading supports trading Equities.
AddEquity("SPY", Resolution.Minute, Market.USA);
self.AddEquity("SPY", Resolution.Minute, Market.USA)
If you call the SetBrokerageModel
method with the correct BrokerageName
, then you don't need to pass a Market
argument to the AddEquity
method because the brokerage model automatically selects the correct market.
Assets Available
Refer to the US Equities dataset to see the assets available.
You may not be able to trade all assets with Atreyu Trading. For example, if you live in the EU, you can’t trade US ETFs. Check with your local regulators to know which assets you are allowed to trade. You may need to adjust settings in your brokerage account to live trade some assets.
Orders
We model the Atreyu Trading API by supporting several order types, order properties, and order updates. When you deploy live algorithms, you can place manual orders through the IDE.
Order Types
Atreyu Trading supports the following order types:
MarketOrder
LimitOrder
MarketOnCloseOrder
MarketOrder(_symbol, quantity); LimitOrder(_symbol, quantity, limitPrice); MarketOnCloseOrder(_symbol, quantity);
self.MarketOrder(self.symbol, quantity) self.LimitOrder(self.symbol, quantity, limit_price) self.MarketOnCloseOrder(self.symbol, quantity)
Only integer order quantities are supported.
Order Properties
We model custom order properties from the Atreyu Trading API. The following table describes the members of the AtreyuOrderProperties
object that you can set to customize order execution:
Property | Description |
---|---|
TimeInForce | A TimeInForce instruction to apply to the order. The Day TimeInForce is supported. |
PostOnly | A flag to signal that the order must only add liquidity to the order book and not take liquidity from the order book. |
public override void Initialize() { // Set default order properties DefaultOrderProperties = new AtreyuOrderProperties { TimeInForce = TimeInForce.Day, PostOnly = false }; } public override void OnData(Slice slice) { // Use default order order properties LimitOrder(_symbol, quantity, limitPrice); // Override the default order properties LimitOrder(_symbol, quantity, limitPrice, orderProperties: new AtreyuOrderProperties { TimeInForce = TimeInForce.Day, PostOnly = true }); }
def Initialize(self) -> None: # Set the default order properties self.DefaultOrderProperties = AtreyuOrderProperties() self.DefaultOrderProperties.TimeInForce = TimeInForce.Day self.DefaultOrderProperties.PostOnly = False def OnData(self, slice: Slice) -> None: # Use default order order properties self.LimitOrder(self.symbol, quantity, limit_price) # Override default order properties order_properties = AtreyuOrderProperties() order_properties.TimeInForce = TimeInForce.Day order_properties.PostOnly = True self.LimitOrder(self.symbol, quantity, limit_price, orderProperties = order_properties)
Updates
We model the Atreyu Trading API by supporting order updates. You can define the following members of an UpdateOrderFields
object to update active orders:
Quantity
LimitPrice
Tag
var ticket = LimitOrder(symbol, quantity, limitPrice, tag); var orderFields = new UpdateOrderFields {
Quantity = newQuantity,
LimitPrice = newLimitPrice,
Tag = newTag
}; ticket.Update(orderFields);
ticket = self.LimitOrder(symbol, quantity, limit_price, tag)
update_fields = UpdateOrderFields() update_fields.Quantity = new_quantity update_fields.LimitPrice = new_limit_price update_fields.Tag = new_tag ticket.Update(update_fields)
Fees
We model the order fees of Atreyu Trading, which are $0.0035/share.
Margin
We model buying power and margin calls to ensure your algorithm stays within the margin requirements.
Buying Power
Atreyu Trading allows up to 2x leverage for margin accounts.
Margin Calls
Regulation T margin rules apply. When the amount of margin remaining in your portfolio drops below 5% of the total portfolio value, you receive a warning. When the amount of margin remaining in your portfolio drops to zero or goes negative, the portfolio sorts the generated margin call orders by their unrealized profit and executes each order synchronously until your portfolio is within the margin requirements.
Pattern Day Trading
If all of the following statements are true, you are classified as a pattern day trader:
- You reside in the United States.
- You trade in a margin account.
- You execute 4+ intraday US Equity trades within 5 business days.
- Your intraday US Equity trades represent more than 6% of your total trades.
Pattern day traders must maintain a minimum equity of $25,000 in their margin account to continue trading. For more information about pattern day trading, see Am I a Pattern Day Trader? on the FINRA website.
The PatternDayTradingMarginModel
doesn't enforce minimum equity rules and doesn't limit your trades, but it adjusts your available leverage based on the market state. During regular market hours, you can use up to 4x leverage. During extended market hours, you can use up to 2x leverage.
security.MarginModel = new PatternDayTradingMarginModel();
security.MarginModel = PatternDayTradingMarginModel()
Slippage
Orders through Atreyu Trading do not experience slippage in backtests. In live trading, your orders may experience slippage.
Short Availability
Atreyu Trading provides short availability information through the AtreyuShortableProvider
. If you try to short an Equity when there are no shares available to borrow, your order is invalidated.
var quantity = CalculateOrderQuantity(symbol, -0.1m); var canShort = Shortable(symbol, quantity);
quantity = self.CalculateOrderQuantity(self.symbol, -0.1) can_short = self.Shortable(self.symbol, quantity)
Security and Stability
When you deploy live algorithms with Atreyu Trading, we don't save your brokerage account credentials.
Promotions
Open an Atreyu Trading account and receive a free Trading Firm plan. For more information about the promotion, contact us.
Deploy Live Algorithms
You must have an available live trading node for each live trading algorithm you deploy.
Follow these steps to deploy a live algorithm:
- Open the project you want to deploy.
- Click the
Deploy Live icon.
- On the Deploy Live page, click the Brokerage field and then click from the drop-down menu.
- Enter your Atreyu Trading user name, password, client ID, request port, and subscription port.
- Click the Node field and then click the live trading node that you want to use from the drop-down menu.
- If your brokerage account has existing cash holdings, follow these steps:
- In the Algorithm Cash State section, click .
- Click .
- Enter the currency ticker (for example, USD or BTC) and a quantity.
- If your brokerage account has existing position holdings, follow these steps:
- In the Algorithm Holdings State section, click .
- Click .
- Enter the symbol ID, symbol, quantity, and average price.
- (Optional) Set up notifications.
- Configure the Automatically restart algorithm setting.
- Click .
Your account details are not saved on QuantConnect.
By enabling automatic restarts, the algorithm will use best efforts to restart the algorithm if it fails due to a runtime error. This can help improve the algorithm's resilience to temporary outages such as a brokerage API disconnection.
The deployment process can take up to 5 minutes. When the algorithm deploys, the live results page displays. If you know your brokerage positions before you deployed, you can verify they have been loaded properly by checking your equity value in the runtime statistics, your cashbook holdings, and your position holdings.