开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

C# Option Contract Details


andrewcmeier
 

Excellent, it worked, had to change a couple of other fields but it was definitely the contractID, thank you. The final code I used is:

AAAA = new Contract(0, "AAPL", SecurityType.Option, "20130719", 420.0, RightType.Call, "100", "SMART", "USD", "", "", SecurityIdType.None, "");

Still not sure how to get all options for a stock but will keep trying.

--- In TWSAPI@..., "Richard L King" <rlking@...> wrote:

contractId is IB's own unique identifier for a contract. If you know this id
for a specific contract, you can use it in a contract details request and
not supply any of the other fields.



Setting this to 22 as you have done, and then supplying all the other fields
for a contract whose id is almost certainly not 22, is probably the source
of your error.



So try setting contractId to 0.



Richard



From: TWSAPI@... [mailto:TWSAPI@...] On Behalf Of
andrewcmeier
Sent: 15 July 2013 04:47
To: TWSAPI@...
Subject: [TWS API] Re: C# Option Contract Details







I've had a look, it looks great, however, I still can't seem to fix my
problem. The way you set up a contract in VB is:
contract.conId = Convert.ToInt32(ss(2))
contract.symbol = TextBox1.Text
contract.secType = "OPT"
contract.expiry = ss(0).Trim.ToString
contract.strike = Convert.ToDouble(ss(1))
contract.right = "C"
contract.multiplier = ""
contract.exchange = "SMART"
contract.primaryExchange = ""
contract.currency = "USD"
contract.localSymbol = ""
contract.includeExpired = 0
tickcount += 1
AxTws1.reqMktDataEx(rnumber, contract, "", 1) '0 =streaming 1=snapshot

However, in C# I don't seem to have any of the contract.x and can't even
seem to use .reqMktDataEx()

I've tried another method which uses:
AAAA = new Contract(22, "AAPL", SecurityType.Option, "201307", 420.0,
RightType.Call, "", "SMART", "USD", "", "", SecurityIdType.None, "");

The constructor for this is:
public Contract(int contractId, String symbol, SecurityType securityType,
String expiry, double strike, RightType right,
String multiplier, string exchange, string currency, string localSymbol,
string primaryExchange,
SecurityIdType secIdType, string secId)

It still says no security definition found.
Any idea of what is wrong here?

Thanks again.

--- In TWSAPI@... <mailto:TWSAPI%40yahoogroups.com> , Nick
<nickhere@> wrote:

In the file section of this group
I wrote a option chain getter
I included the source.it in vb
and conversion is easy to c#
i had very little problems with it
it get the chain of any stock ticker
gets all the quotes
and draws vertical spread graphs

nick


On 7/14/2013 6:23 AM, andrewcmeier wrote:
Oops, Tester and A1 were meant to be the same variable in the options
lines, change Tester to A1 and that is what I have.

--- In TWSAPI@... <mailto:TWSAPI%40yahoogroups.com> ,
"andrewcmeier" <andrewcmeier@> wrote:
Hi there,
I've started using the Krs.Ats.IBNet software
(.
0.21.Full.zip) to develop TWS software in C#.

Setting up equities is easy enough:
Equity Google = new Equity("GOOG");
client.RequestMarketData(14, Google, null, true, false);

But when I try to adapt it to options, I can't get it to work. This is
what I'm using:
Option A1 = new Option("AA", "AA", "20130719", RightType.Call, 8.0m);
client.RequestMarketData(15, Tester, null, false, false);

This is what it has in its class):
public Option(string equitySymbol, string optionSymbol, string expiry,
RightType right, decimal strike)

This is the error I get when I raise e.ErrorCode:
"No security definition has been found for the request"

Does anyone know what I'm entering wrong, or just how to set up an
option in C#? I also then wan't to be able to leave fields out to do things
such as return all the contracts in a month, does anyone have any examples
how to do this?

I'm finding that C# should be a good way to download and analyse data
but don't have any documentation, I've only worked out what to do from
searching through lots of the code.

Thanks for your help.


------------------------------------

Yahoo! Groups Links








Join [email protected] to automatically receive all group messages.