SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Thu Feb 27, 2020 7:24 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 45 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject:
PostPosted: Wed Mar 05, 2008 5:50 pm 
Offline

Joined: Mon Feb 27, 2006 9:07 pm
Posts: 52
I did it this way:

Code:
      BrokerAccount[] accounts = DataManager.GetBrokerInfo("IB").Accounts;
     
      foreach (BrokerAccount account in accounts)
      {
         Console.WriteLine(account.Name + " " + account.BuyingPower);
         foreach (BrokerPosition position in account.Positions)
         {
            Console.WriteLine(position.Symbol + " " + position.Qty);
         }
      }


But, as I mentioned above, I am not getting proper results for FA accounts.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 05, 2008 6:00 pm 
Offline
Site Admin

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

dwil wrote:
I then tried it on an FA account. I saw the account.Name for each account, but the account.BuyingPower displayed as 0 and the positions were empty when there are positions. I tested to see if I could place a live order in one of the sub-accounts and I could. Is there anything else that needs to be done in order to make this work with sub-accounts?


Currently, there is no possibility to get broker info for FA accounts. We will do it in near future.

Regards,
Alex

_________________
SmartQuant Development Team


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 11, 2008 6:23 am 
Offline

Joined: Mon Jan 07, 2008 6:18 am
Posts: 58
csharp_student wrote:
How do we get the Positions for this account in IB.

I get the following when I WriteLine account.Positions

Positions --> OpenQuant.API.BrokerPosition[]


Same here, I can manually change the position [IB sim account] and the change in buying power registers but position always returns as above.......


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 11, 2008 12:26 pm 
Offline
Site Admin

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

Quote:
How do we get the Positions for this account in IB.

I get the following when I WriteLine account.Positions

Positions --> OpenQuant.API.BrokerPosition[]


The 'account.Positions' property returns an array of the BrokerPosition classes and the string representation of any array looks like this.

Regards,
Alex

_________________
SmartQuant Development Team


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 12, 2008 4:57 am 
Offline

Joined: Mon Jan 07, 2008 6:18 am
Posts: 58
Well.... honestly, it's like we are asking somebody with a watch what time it is and they are giving us the history of clockmaking but not the time... can you tell us what we can do to use the position info with an example... maybe we convert a string to a number or something, I don't know...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 12, 2008 1:26 pm 
Offline
Site Admin

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

you can walk through positions like in code example below and analyze position's fields such as Symbol,Exchange,Qty etc.

dwil wrote:
I did it this way:

Code:
      BrokerAccount[] accounts = DataManager.GetBrokerInfo("IB").Accounts;
     
      foreach (BrokerAccount account in accounts)
      {
         Console.WriteLine(account.Name + " " + account.BuyingPower);
         foreach (BrokerPosition position in account.Positions)
         {
            Console.WriteLine(position.Symbol + " " + position.Qty);
         }
      }



Regards,
Alex

_________________
SmartQuant Development Team


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 14, 2008 3:20 am 
Offline

Joined: Mon Jan 07, 2008 6:18 am
Posts: 58
I updated to Ver 2.1.2 and that code gives me an error message at build: Cannot implicitly convert type 'OpenQuant.API.BrokerAccountList' to 'OpenQuant.API.BrokerAccount[]'


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 14, 2008 11:44 am 
Offline
Site Admin

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

The return value of the 'Accounts' property was changed from BrokerAccount[] to BrokerAccountList class that has a common functionality of array and allows to get BrokerAccount by its name.

Regards,
Alex

_________________
SmartQuant Development Team


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 14, 2008 1:23 pm 
Offline

Joined: Fri May 06, 2005 1:40 am
Posts: 521
Post this to hopefully to save some a lot of time... plus Its a recipe for disaster If your just plugging in the code snippets posted here without understanding whats going on.
Quote:
Well.... honestly, it's like we are asking somebody with a watch what time it is and they are giving us the history of clockmaking but not the time

It looks like the reason for the confusion is that the answers are being posted by experience c# programmers - and the answers are assuming you know c# - while at the same time not pointing out that the problem is a lack of c# experience.
Quote:
I get the following when I WriteLine account.Positions
Positions --> OpenQuant.API.BrokerPosition[]

Quote:
can you tell us what we can do to use the position info with an example... maybe we convert a string to a number or something, I don't know...

With some c# experience you will begin to see from this console printed result that account.Positions is an array full of some type (or even mixed types if its not a generic array), since it terminates with "[]" - and so you know immediately that it must be indexed to get a result you can use (using foreach, account.Positions[0],account.Positions[1]..., etc)
The result might be another array, or some other complex data structure, which you then need to print out study and treat accordingly (or check the API manual for the type vs printing them out). For example there are a whole host of things that will crash your OpenQuant strategy if you start indexing arrays incorrectly... which would be perfectly normal from a programming standpoint and have nothing directly to do with OpenQuant.
So its worth the time brush up on c#, c# arrays/generics, types etc... google them there are lots of great easy to follow tutorials around - one of the great advantages of using OpenQuant is that your not dependent on one company to tell you how the programming language operates like happens with some other trading products.

Programming problems generate unnecessary support requests taking up valuable programmer time better spent on improving OpenQuant - perhaps SmartQuant support should try to state when the problem is most likely a c# programming problem Vs OpenQuant API problem, and/or redirect these types of questions to the programming c# help forum.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 15, 2008 9:45 pm 
Offline

Joined: Mon Jan 07, 2008 6:18 am
Posts: 58
Actually, if we that don't know C# very well, and possibly never will... could have specific examples, here in the OpenQuant FAQ section, we can do everything we want to... I don't have the "programmer gene", I took a C class at UCLA a long time ago and I hated every minute of it. I could probably take classes and look up stuff on the web forever and still need help. I'm an Electrical Engineer Analog Circuit Designer in my real life so it's not that I don't get tech stuff, I'm more on the mathy side of things, analog, not programming, well maybe programming in assembly language, to me that is my native programming environment, not C# which seems like a giant game of Rumpelstiltskin, but you not only have to guess the name, but where he was born, what he has in his pockets......... currently, by looking up example code, I have a strategy that works in backtesting and works on real data in realtime, I think that tells me that OpenQuant does what I want it to, I've designed trading systems for years in other languages and was writing machine code in 1975 and have been into computers ever since then....

In a thread on a trading website Dr. Foiken told me to post my questions on the OQ FAQ section because they are going to put it all in a document for newbies... I really think that specific examples would be appropriate. These questions have to only be answered for me and a few others once, then all the newer newbies can find the examples they need, and maybe a lot of the "programmers" as well... it's not a complicated "business model".

With Ninja Trader I could look in their existing API documentation and find specific examples of everything I could possibly do with the language. I could program Ninja faster in C# than Easy Language after a little practice.

If I could get specific examples here in the FAQ section, eventually I will be a candidate for upgrading to the institutional products with a programmer employee. I can't think of anything that I would like to do more than that at this point.

WTF


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 16, 2008 4:02 pm 
Offline

Joined: Fri May 06, 2005 1:40 am
Posts: 521
Hi Maxpi,
I agree, the more examples the better, and no need to be a master programmer to use OQ! Sorry if I was not clear: The main thing to I wanted to mention with this thread was that the support answers were assuming a level of c# programming knowledge, and so appeared an incomplete answer - which caused the confusion. Better not to assume and provide detailed examples like you say.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 16, 2008 8:40 pm 
Offline

Joined: Mon Jan 07, 2008 6:18 am
Posts: 58
ty


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 14, 2008 12:21 am 
Offline

Joined: Thu Mar 16, 2006 12:15 pm
Posts: 184
dito. Api docs should be added with sample code. This would help a lot.
And I think would save Anton some time in the longterm ;-)

_________________
Expect the unexpected. May your MM/RM be with you.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 10, 2008 1:06 pm 
Offline

Joined: Fri Feb 08, 2008 5:46 pm
Posts: 26
I tried the following code:

BrokerAccount[] accounts = DataManager.GetBrokerInfo("IB").Accounts;

foreach (BrokerAccount account in accounts)
{
Console.WriteLine(account.Name + " " + account.BuyingPower);
foreach (BrokerPosition position in account.Positions)
{
Console.WriteLine(position.Symbol + " " + position.Qty);
}
}

I get the following error:

Cannot implicitly convert type 'OpenQuant.API.BrokerAccountList to OpentQuant.API.BrokerAccount[]'

I am just trying to locate the IB buying power.
Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 10, 2008 1:10 pm 
Offline

Joined: Thu Mar 20, 2008 4:41 pm
Posts: 273
Location: Sweden
stjones1221 wrote:
I tried the following code:
Code:
      BrokerAccount[] accounts = DataManager.GetBrokerInfo("IB").Accounts;
     
      foreach (BrokerAccount account in accounts)
      {
         Console.WriteLine(account.Name + " " + account.BuyingPower);
         foreach (BrokerPosition position in account.Positions)
         {
            Console.WriteLine(position.Symbol + " " + position.Qty);
         }
      }

I get the following error:

Cannot implicitly convert type 'OpenQuant.API.BrokerAccountList to OpentQuant.API.BrokerAccount[]'

I am just trying to locate the IB buying power. Thanks.


Changed first line, try this:
See Alexei's post above for more info.
Code:
      BrokerAccountList accounts = DataManager.GetBrokerInfo("IB").Accounts;
     
      foreach (BrokerAccount account in accounts)
      {
         Console.WriteLine(account.Name + " " + account.BuyingPower);
         foreach (BrokerPosition position in account.Positions)
         {
            Console.WriteLine(position.Symbol + " " + position.Qty);
         }
      }

_________________
Asking smart qustions:
http://www.catb.org/~esr/faqs/smart-que ... html#intro

I don't mind when people PM me to see if I have the time to help, but please post in the forum FIRST, and then grab my attention so others can benefit aswell.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 45 posts ]  Go to page Previous  1, 2, 3  Next

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:  
cron
Powered by phpBB® Forum Software © phpBB Group