SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Sun Sep 15, 2019 12:48 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 13 posts ] 
Author Message
PostPosted: Tue Nov 10, 2009 7:26 pm 
Offline

Joined: Sat Sep 26, 2009 12:08 am
Posts: 62
Location: Ireland
Which OQ API class should I use to:
1. Get account current available funds?
2. Get current positions?
3. Get current open orders?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 11, 2009 11:59 am 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
2.
in Strategy class methods:
base.Portfolio.Positions
3.
in Strategy class methods:
base.Orders

Please, look into OpenQuant API docs...

_________________
SmartQuant Development Team


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 22, 2009 1:05 am 
Offline

Joined: Wed Dec 16, 2009 3:18 am
Posts: 34
and what about AccountBalance ? (not buying power)
InteractiveBrokers account.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 22, 2009 12:43 pm 
Offline

Joined: Thu Sep 20, 2007 6:43 pm
Posts: 122
Location: Poland
Hi :)

Largo wrote:
and what about AccountBalance ? (not buying power)
InteractiveBrokers account.


Maybe Portfolio.GetAccountValue help you.

Regards
MaRCHeW

_________________
"Your worst day with OpenQuant is better than your best day with most of the other stuff."


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 22, 2009 3:11 pm 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
What 'AccountBalance' do you mean? Could you clarify your question?

_________________
SmartQuant Development Team


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 23, 2009 1:37 pm 
Offline

Joined: Wed Dec 16, 2009 3:18 am
Posts: 34
Account Balance means cash on broker account (without unrealized PnL)
(MetaTrader 4 term).

Maybe in IB there is no such a information, because on its "Account" Window I can't see expected value, neither in Balances -> Cash -> Total.

Marchew,
Portfolio.GetAccountValue() returns cash amount from Simulation -> Cash


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 23, 2009 1:52 pm 
Offline

Joined: Wed Dec 16, 2009 3:18 am
Posts: 34
At last it can be: Cash +/- Unrealized P&L


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 23, 2009 2:06 pm 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
Hi,

IB provides some account information and you are able to see it in BrokerInfo window of OpenQuant and also you can retrieve these values from strategy code. To view account information, set IB as execution provider for Live mode, switch to Live mode, connect plugin and goto View->Broker Info menu.

Regards,
Alex

_________________
SmartQuant Development Team


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 23, 2009 3:26 pm 
Offline

Joined: Wed Dec 16, 2009 3:18 am
Posts: 34
I know that I can see it in Broker Info window.
My question is how to see it from strategy code?

In API doc there is no information about how to get ie. cash balance value. I suppose that it can be hidden in Fields property.

BrokerAccount object has only few informations about broker account:

Code:
   
BrokerAccount account = DataManager.GetBrokerInfo("IB").Accounts[0];
Console.WriteLine(account.Name + " " + account.BuyingPower);


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 23, 2009 3:40 pm 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
Code:
BrokerInfo info = DataManager.GetBrokerInfo("IB");
      
if (info.Accounts.Count > 0)
{
     BrokerAccount account = info.Accounts[0];
         
     BrokerAccountField field = account.Fields["<field_name>"];
         
     if (field != null)
     {
           string value = field.Value;
     }
}

_________________
SmartQuant Development Team


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 23, 2009 4:29 pm 
Offline

Joined: Wed Dec 16, 2009 3:18 am
Posts: 34
Alexei,

I replaced <field_name> with UnrealizedPnL and "field" variable is null.

In Broker Info window this field has value.

info.Accounts.Count returns 1.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 23, 2009 4:45 pm 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
Since, some fields may have two and more values (in different currencies) the second parameter to account.Fields["name"] method is needed.
If it is missing then the value without currency is returned (red line)
Code:
BrokerAccountField field = account.Fields["UnrealizedPnL", "USD"];


Attachments:
brokerinfo.gif
brokerinfo.gif [ 26.94 KiB | Viewed 8970 times ]

_________________
SmartQuant Development Team
Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 23, 2009 5:37 pm 
Offline

Joined: Wed Dec 16, 2009 3:18 am
Posts: 34
Now works, thank you, Alexei.
My God, good to know, I suggests update API doc with this information because whole information about BrokerAccount.Fields is:

Syntax
Visual Basic (Declaration)
Public ReadOnly Property Fields As BrokerAccountFieldList

C#
public BrokerAccountFieldList Fields { get; }


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group