I have started building a Broker Service and have a few questions.
1. Could you explain to me what the purpose of AddOrderUpdatedDelegate, AddPositionAvailableDelegate, RemoveOrderUpdatedDelegate, RemovePositionAvailableDelegate is. I couldn't really work out what I was supposed to be doing here from the sample.
2. My Broker does not have a function to return the cash in the account for GetBuyingPower. Should I just set this to 0, or will that stop orders going through? (in which case I guess I would set it to 10,000,000 or something like that)
3. My broker API only allows for limit and market orders to be placed. Am I correct in saying that this means that when I write a strategy in RE, that whilst I can use stop orders for back testing, that when I switch to live trading I will need to change my code to handle the stop from within RE. I am assuming that when a stop order is generated by a strategy in RE that it is sent directly to the broker for monitoring within the broker software, rather than being moinitored by RE and released as a market order when the level is hit. (What I am getting at here is, is the functionality of the BrokerOrderType enumeration members handled by RE, or does your broker software need to be able to handle this functionality?)
4. Really just a comment here, but I thought the BrokerTransactionType enumeration members names to be a bit confusing (Buy = Buy, Short = Sell, Sell = Close long, Cover = close short). Would have made more sense to have something like, Buy, Sell, ExitLong, ExitShort.
1. You should keep a list of OrderUpdatedDelegates and PositionAvailableDelegates in your plugin. The add and remove methods should add or remove items from the lists. When an order is filled, canceled, or in any other case where an order is updated, you should call all of the delegates in the OrderUpdatedDelegate list. The PositionAvailableDelegate is used to communicate the size of each currently open holding. The PositionAvailableDelegate is not really used right now, but you will need to make sure the OrderUpdatedDelegates are working or RightEdge will never know what happens to the orders you submit.
2. You're saying the broker has no way of letting you know programmatically what the size of your account is? If it's not implemented as a function you can call, it may be a message you receive every so often with account information. If you don't have any access to this value, it's probably better to return something like $10,000. Be aware that if you are using a percentage-based position sizing, the position sizes will be based on this value.
3. You are correct that it is up to the broker to implement the various order types, such as stops, limits, etc. If your broker does not support some of the order types you would like to use, you could implement those types in your broker plugin, and you wouldn't have to change your system code. For this to work your broker would probably have to provide you with current price information (so your broker plugin would probably also be a live data plugin). If a stop limit order was submitted to the broker plugin, it would monitor the price of the symbol, and when it fell below a certain level, it would submit that order as a market order.
4. I understand, but I'm not sure if it's possible to make perfect sense to everyone here . If someone doesn't use short positions at all, then they will just use Buy and Sell, which seems to make sense.