Now I've tried to hook this form up based on ETLURKER's animated gif tutorial in the previous link but am having no luck so far.
My first question- in the solution folder under references I have three various references to TWS. I first added a reference which showed up as TWSlib. I then right clicked in the tollbox and selected choos items. This added the TWS control to the toolbox which I then dragged onto the form. Somewhere along the way a reference to Interop.TWSLib also showed up in the references section of solution exporer. I think I may have only needed to add the control to the tollbox and drag it to the form, without adding any other references. Can anyone confirm this?
When I was setting up the form, I decided to go two steps further than the .gif in the link. I decided to add a few more data fields and some text boxes to let the user change the symbol.
Before making any of those additions functional, I wanted to stick to the tutorial and get a connection and only the last price for the ES. So in my form1.cs file, I have the following code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace IBTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void connectIBToolStripMenuItem_Click(object sender, EventArgs e)
{
axTws1.connect("localhost", 7496, 0);
}
private void button1_Click(object sender, EventArgs e)
{
double strike = new double();
axTws1.reqMktData(1, "ES", "FUT", "200706", strike, "", "", "GLOBEX", "", "USD", "");
}
private void axTws1_tickPrice(object sender, AxTWSLib._DTwsEvents_tickPriceEvent e)
{
if ((e.id == 1) && (e.tickType ==1))
{
label8.Text = (string)e.price;
}
}
But I get the following error when I try to build it:
cannot convert type 'double' to 'string'
This is in reference to that last line of code,
label8.Text = (string)e.price
I added that (string) to try and cast it, but that won't work. I get the same error either way. Anyone have any suggestions?
And also do I need a using statement for the TWS control?
Thanks.