Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Net mode account
 Post subject: Net mode account Post rating: 0   New post Posted: Thu 12 Sep, 2013, 20:55 

User rating: 0
Joined: Tue 05 Feb, 2013, 19:48
Posts: 13
Hello Support,

How can I tell if the account is in net mode or hedge mode?
In net mode , where the filled orders are?
The IEngine getOrders() method return null.

Thanks,
Stassen


 
 Post subject: Re: Net mode account Post rating: 0   New post Posted: Fri 13 Sep, 2013, 08:09 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
stassen wrote:
How can I tell if the account is in net mode or hedge mode?
You can tell it by the platform GUI - that there are no TP/SL orders in the entry order panel.
stassen wrote:
In net mode , where the filled orders are?
They get merged to the instruments position.
stassen wrote:
The IEngine getOrders() method return null.
Are there any orders/positions visible in the platform?


 
 Post subject: Re: Net mode account Post rating: 0   New post Posted: Fri 13 Sep, 2013, 09:54 

User rating: 0
Joined: Tue 05 Feb, 2013, 19:48
Posts: 13
What method can be called for account mode detection then?

After the fill message (ORDER_FILL_OK) came in , calling the IEngine getOrders() method does not contains the fill.
In net account mode , is there other method to query the current positions? The getOrders() seems out of sync.

Thanks,
Stassen


 
 Post subject: Re: Net mode account Post rating: 0   New post Posted: Fri 13 Sep, 2013, 10:03 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
stassen wrote:
What method can be called for account mode detection then?
There is no such method in API. IAccount.isGlobal.
stassen wrote:
After the fill message (ORDER_FILL_OK) came in , calling the IEngine getOrders() method does not contains the fill.
Please provide an example strategy which demonstrates this.
stassen wrote:
In net account mode , is there other method to query the current positions? The getOrders() seems out of sync.
IEngine.getOrders() is the method to use, please provide an example strategy that would support your claims.


 
 Post subject: Re: Net mode account Post rating: 0   New post Posted: Fri 13 Sep, 2013, 10:35 

User rating: 0
Joined: Tue 05 Feb, 2013, 19:48
Posts: 13
Here is an example:

   public void onMessage(IMessage message) throws JFException
    {
        if (message.getType() == IMessage.Type.ORDER_FILL_OK)
        {
            console.getOut().println("Order filled");
           
           List orders = engine.getOrders();
         
            console.getOut().println("Orders:"+orders.size());
        }
    }


This is the output when a fill came in:
09:29:15 Orders:0
09:29:15 Order filled


 
 Post subject: Re: Net mode account Post rating: 3   New post Posted: Fri 13 Sep, 2013, 14:43 
User avatar

User rating: 70
Joined: Sat 22 Sep, 2012, 17:43
Posts: 118
Location: Brazil, Fortaleza, Ceará
We Have Two Available Account Types.

HEDGING ACCOUNT
Hedging in the sense of permitting the establishing of a market position or positions in some underlying financial security such that the position or positions effectively counter all or some of the exposure already existing due to a previous position or positions still active in the same financial security. Hedging in this context involves the opening of position(s) in a financial security to a side (e.g. SELL) opposite to that of existing positions (e.g. BUY).

GLOBAL ACCOUNT
Global in the sense of globally acceptable for legal and regulatory purposes worldwide as it is the case that some jurisdictions prohibit the use of financial trading facilities allowing multiple positions to be taken on both sides of a speculative financial transaction.

How We Determine Account Type

PROGRAMMATICALLY
Following strategy initialisation, the strategy container will cause a call to be made to the IStrategy.onAccount method. This call follows the initialisation call made to IStrategy.onStart and will expose the IAccount interface to your strategy.

It is at this point that you have the opportunity to interrogate the account type by making a call to IAccount.isGlobal() which will tell you whether you are currently operating under a GLOBAL account or not. Of course an answer in the Negative implies that the account in use is indeed a HEDGING account.

MANUALLY
I'll repeat the solution provided by Support which specifically refers to identifying GLOBAL account status and is as follows:
Quote:
You can tell it by the platform GUI - that there are no TP/SL orders in the entry order panel.

Where We Find Fill Information

HEDGED ACCOUNT FILLS
When an Order is made in HEDGED mode, each successful Order leads to the establishing of a Position in the underlying financial security.

Orders establish, modify (stop/loss) or close (opposite trade to the market partially or fully) Positions. A Position is considered closed when it's net exposure after honouring orders is 0.

When a FILL occurs in this mode, the strategy container will cause a call to IStrategy.onMessage to occur which will expose the IMessage where you can interrogate the message type to determine things like 'ORDER_FILL_OK'.

At this point the Order persists in the FILLED state as a Position until some other action causes this to be otherwise and can be found in the list of active "orders" using IEngine.getOrders.

In this mode, why would IEngine.getOrders() = 0 when the first Order should cause a Position to be opened in the FILLED state? :|
(a position you can see in the trading terminal also - hence why Support needs to see your full strategy example INCLUDING ORDER GENERATION to see if for example you are generating orders that FILL but then immediately CLOSE )

GLOBAL ACCOUNT FILLS
When an Order is made in GLOBAL mode, each successful Order is merged into an existing Position in the underlying financial security or where one does not already exist one is established.

Orders establish or add-to/subtract-from (via merging) Positions and there is no concept of 'close' which gets achieved by covering the existing position with enough Orders in the opposite direction to render the Position's total exposure 0.

When a FILL occurs in this mode, the strategy container will cause a call to IStrategy.onMessage to occur which will expose the IMessage where you can interrogate the message type to determine things like 'ORDER_FILL_OK'.

Beyond this point, the Order is merged out of existence into the existing Position for the underlying security so a live reference to it is effectively lost if you don't retain it within onMessage and despite being temporarily FILLED once merged into an existing Position, it cannot be retrieved through the active orders list by calling IEngine.getOrders or by the historical lists as it never entered the CLOSED state but served to modify an existing Position (this existing position with not enter the CLOSED state either but will be merged out of existence by some subsequent Order).

In short, order management in the GLOBAL account case requires more work at your end in order to manage what you consider the "current state of positions" to be. In this mode, 100 Orders can contribute to the same 1 Position, all 100 Orders merged into the 1 Position. State management is the responsibility of your strategy therefore and begins with maintaining a reference to the first Order establishing a Position in the underlying financial instrument.

In this mode, why would IEngine.getOrders() = 0 when the first Order should cause a Position to be opened in the FILLED state? :|
(a position you can see in the trading terminal also - hence why Support needs to see your full strategy example INCLUDING ORDER GENERATION to see if for example you are generating orders that FILL but then immediately CLOSE )


 
 Post subject: Re: Net mode account Post rating: 0   New post Posted: Fri 13 Sep, 2013, 16:15 

User rating: 0
Joined: Tue 05 Feb, 2013, 19:48
Posts: 13
Hello CriticalSection,

Thanks for the IsGlobal() method.

Altough I still do not understand how is it possible to query the open positions when a fill happen without getOrders()?

Stassen


Attachments:
Strategy.java [1.4 KiB]
Downloaded 125 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: Net mode account Post rating: 0   New post Posted: Fri 13 Sep, 2013, 17:33 
User avatar

User rating: 70
Joined: Sat 22 Sep, 2012, 17:43
Posts: 118
Location: Brazil, Fortaleza, Ceará
Please honour three favours:

1. Answer this question posed by Support some posts ago - it is critical
Quote:
Are there any orders/positions visible in the platform?
2. Within your strategy, output the actual state of the Order object referred to in the IMessage using message.getOrder().getState().
Your existing console.getOut().println("Order filled") only confirms the events causing that line to execute but doesn't refer to the object itself and its actual state at that point in time. Also perhaps place a console.getOut().println("new message: "+message.getType()) outside the if statement in that onMessage() to see what's going on around filling.

3. After you output the state of the order, kindly use the order's ID as input into IEngine.getOrderById to confirm that the order is indeed returnable.

To answer your question, it is expected in my understanding that the same Position you see active/filled in the platform is made available via IEngine.getOrders() hence my questions in green above to both yourself and Support.


 

Jump to:  

  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com