| || |
Table Manager vs Non-table Manager
I am new here. I need to implement interface between FXCM and My software (WPF) to create/execute orders, get updates on those orders (executions), subscribe for quotes etc. I downloaded Forex Connect API and after install I see several example projects, which is divided in "Table Manager" AND "Non-table Manager" examples. What the difference between them? And which way "Table Manager" -OR- "Non-table Manager" would be better to use for my project? Suggestions highly appreciated. Thank you in advance.
The table manager is responsible to keep all tables data and perform all offer-based calculations (such as open trades profit/loss and current account equity) "on the fly". Without table manager you won't have keeping trading table data inside the API and calculations of the P/L, trailing stops, summary on each tick.
If your application does not need calculated values, usage of table manager is not recommended.
Please read also about advantages and disadvantages of table manager in this article O2GTableManager
Thank you for answer it was very helpful.
According to ForexConnect API document in order to login to FXCM and get responses I should create session, listeners, and subscribe listeners and catch SessionStatusChanged, onRequestCompleted etc...and “WholeSample” project from SDK does that, so all event handling is coded by hand. But, Session object already have all those events built in. Can I use built in events in Session object instead of writing all those listeners by hand?
Yes, you can use built-in events. For example, see the OpenPosition sample in the simple samples folder:
Thanks again. I used built-in events (no table manager) to create orders, get offers … etc. It’s working fine. I assigned “session.TablesUpdates” built-in event to get updates and updates coming for ALL tables offers, orders, trades … etc. into one event handler. So, I have to iterate through tables reader to get update for order or offer or trade, then when new “TableUpdate” response is coming I have to iterate again. That is problem for me, because it’s slows down offers updates stream. I need stream of Order updates and Offer updates coming in separate independent handles.
Q: Can I mix “table manager” and “non-table manager” architecture that I will use “non-table manager” built-in events to workout Orders updates AND “table manager” to workout just Offers updates? May be you know another solution using built-in events to SEPARATE flow of updates for different tables?
You can mix 'table manager' and 'non-table manager architecture, but in both architectures event calling and TableUpdate occurs in context of one thread (in other words, in context of one flow).
Could you please tell what do you mean by 'slows down offers updates stream'?
Please tell also for which purpose you get offers stream:
- calculate your values;
- show them in GUI;
- write to file;
- something else.
If you process all your events in TableUpdates, you may process offers with delay. Offers may be collected in an internal update queue. You can create two different threads. This provides you with different flows. In OnTablesUpdates, you route a response or result response to offer and trade thread. You can send IO2GResponse and process result in different threads or process a response and then send IO2GOfferRow directly (IO2GTradeRow, IO2GOrderRow, etc). For synchronization between threads you can use a queue (for details, please see samples/dotnet20/WholeSample/ResponseQueue.cs).
Thank you for your response.
1. What I meant is, all updates for Offers, Order and Trades coming into one event handler and goes into one response queue, then each update extracted one by one from response queue. For example while I am taking update for created “Order” and process it from response queue, another update for “Offer” waiting in the queue. I want stream offer updates without delays while I process order updates. Simply saying separate responses for orders updates from responses for offer updates.
2. Purpose of offers stream is “show them in the GUI” without delay And generate signals.
Yes, I can create internal queue just for offer updates and process offers queue in separate thread. But anyway I have to iterate through original response queue, Identify that this update for offer before add it to internal queue to process offers in separate thread. That is why I thought I will get table manager and assign “row change” event just for offers table, then whatever change is coming for offer it will publish “row change” event without any delays. For “orders updates” I am still going to process original response queue coming on Session_TablesUpdates event.
Internally, ForexConnect has the original response (the same as your application receives in TablesUpdate) and iterates original responses too.
If the table manager mode is "yes", the "row offer change" is called first, before TablesUpdates is called. In table manager mode the calculated field is computed (PL) and only then offer event is published.
Currently, the most of FXCM servers have 2 channels system: one for trading, another for prices. In this case, TablesUpdate (and onChange events) for offers and orders are called in a different thread.
So, if you need calculated fields for your application, it's better to use onChange offers event.
If you need to show prices only, then it's better to use TableUpdates in non-table manager mode. The offers are automatically received in a separated thread.
You can use O2GOffersTableResponseReader offersReader = factory.createOffersTableReader(response); in TablesUpdates. This reader contains only offers row.
P.S. We use TalbeUpdates and WPF (Windows Presentation Foundation) for showing prices in our NYSE monitor project. This project is intended to translate the FXCM prices on a big monitor at New-York Stock exchange. It works fine.
I am doing extensive testing of FXCM API and run into issue, when order sent with big quantity of lots
It is not responding with reject and order not appears in FXCM platform as well. But, when I do the same trade at FXCM itself I got message that I cannot trade that many lots.
Simply saying I need to handle reject if I send order have to many lots, but when I send this order there is no reject responses coming back.
Question: How to get reject response from FXCM if I send order which have too many lots?
First of all let's see what do you mean by " if I send order have to many lots".
1) If you mean that the order amount is bigger than the available margin, then ForexConnect must receive "request failed" with the following message:
[java] ORA-20113: Insufficient margin in session: G10D1_PUa7HMGvDEI05BJf7cfAr4vtpkbXa0vzgUFQXLR9AqHRo22lLQYuaq3DGW
2) If you trade on the Real account, then the orders with the big amount can be executed longer depending on the market liquidity. And most likely, such order will be executed partially.
You can find description of How to Monitor Order Execution in ForexConnect in the following section of Help (version 1.2.1):
How to open position on hedging and non-hedging accounts.
So, if the Order is rejected, then a rejection message will appear in the Messages table. An order with the "R" status will appear in the Orders table.
You can also use OrderMonitor class to catch rejected orders in all cases.
But if you still do not see messages, please provide us the following information:
- the type of connection you use: Demo or Real;
- the type of order: Market(at best, range) or Entry
- the order parameters: GTC/IOC/FOK