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.

Account Free Margin?
 Post subject: Account Free Margin? Post rating: 0   New post Posted: Sun 11 Jul, 2010, 20:50 

User rating: 0
Joined: Sun 11 Jul, 2010, 20:12
Posts: 20
In my JForex strategy, I need access to my account free margin. So I have two questions.
1. How do I get access to the IAccount object in the first place? I can't see a way to get this from the IContext object. Yes I can get the IAccount object from the IStrategy onAccount() method but this is only called after the account info changes. I need the IAccount object at the very start. How do i get it?
2. Is there any method in IAccount that returns the account free margin, ie the equivalent of the MT4 AccountFreeMargin()?

Thanks


 
 Post subject: Re: Account Free Margin? Post rating: 0   New post Posted: Mon 12 Jul, 2010, 15:35 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi
Quote:
1. How do I get access to the IAccount object in the first place? I can't see a way to get this from the IContext object. Yes I can get the IAccount object from the IStrategy onAccount() method but this is only called after the account info changes. I need the IAccount object at the very start. How do i get it?
IAccount method for the first time is called immediately after the onStart. It's not possible to cal this method sooner.
Quote:
2. Is there any method in IAccount that returns the account free margin, ie the equivalent of the MT4 AccountFreeMargin()?
Use method IAccount.getCreditLine().


 
 Post subject: Re: Account Free Margin? Post rating: 0   New post Posted: Mon 12 Jul, 2010, 15:50 

User rating: 0
Joined: Fri 07 May, 2010, 02:59
Posts: 61
zortag wrote:
1. How do I get access to the IAccount object in the first place? I can't see a way to get this from the IContext object. Yes I can get the IAccount object from the IStrategy onAccount() method but this is only called after the account info changes. I need the IAccount object at the very start. How do i get it?


Am I correct in assuming you've used Interactive Brokers before? Their API does this: you only get account updates if the account balance changes, and even then not in a timely manner.

When I started using Dukas' API, that was one of the first things I looked at and I soon found you get a new call to onAccount() about every 5 seconds, and thus far I've always received one before I even receive my first bar or tick. However, all of my testing has been in the backtester, so if you aren't seeing the same behavior there may be a disparity in behavior between the two.

-Brian


 

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