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.

How could I get position information?
 Post subject: How could I get position information? Post rating: 0   New post Posted: Mon 14 Feb, 2011, 16:59 

User rating: 0
Joined: Mon 14 Feb, 2011, 15:47
Posts: 3
Is there an easy way to control the open positions and exposure? All I have seen in the API documentation is various methods about orders, but no methods related to position and exposure.

For example, I would like to check if my current open position is Long or Short. If it is long, I will put a sellstop order at some price level, if it is short, I will put a buystop order at some price level. But I have not find a easy way to implement this logic.


 
 Post subject: Re: How could I get position information? Post rating: 0   New post Posted: Mon 14 Feb, 2011, 21:46 

User rating: 0
Joined: Tue 15 Sep, 2009, 00:44
Posts: 20
if (order.isLong()){
.....
}


 
 Post subject: Re: How could I get position information? Post rating: 0   New post Posted: Tue 15 Feb, 2011, 02:00 

User rating: 0
Joined: Mon 14 Feb, 2011, 15:47
Posts: 3
SquareRoot wrote:
if (order.isLong()){
.....
}


Thanks, this is not what I want, position and order are different.

For example, my last order is a SellStop order for 10000 unit EURUSD, before this order executed, the original position is 20000 unit EURUSD long. After the SellStop order has been executed, the total position is long EURUSD 10000 unit. Then I'm not sure what is the result of order.islong().

By the way, I found out that if I simply use SellStop and BuyStop order to close and reverse a position, it only works once at the beginning of strategy execution.

I feel that I have to make this position class by myself, but then I have to know how the strategy is evaluated on each bar/tick, and what kind of index each bar/tick has...


 
 Post subject: Re: How could I get position information? Post rating: 0   New post Posted: Tue 22 Feb, 2011, 05:51 

User rating: 0
Joined: Tue 01 Feb, 2011, 23:40
Posts: 5
I think in object oriented terms, a Position is an Order with a goodTillTime (i.e. a conditional "order"), and the terms are used somewhat interchangeably in the API. Would you specify some use cases? I'm thinking you would set a reasonably long goodTillTime when you "submitOrder" and then you can manage the "Order" (which you may consider an unrealized order == position) as SquareRoot said -- but you surely are exposed as you may get filled. Look at the methods for IEngine and IOrder and IOrder.State(s) from IOrder.getState (the getState method on an order).


 

Jump to:  

cron
  © 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