API Support Forum
OEC API > API Support > Unable to get Price Feed from Sim environment using API.DLL
Author Topic: Unable to get Price Feed from Sim environment using API.DLL
(2 messages, Page 1 of 1)
Moderators: VPfau
JGronemus87
Posts: 14
Joined: Nov 28, 2007


Posted: Nov 30, 2010 @ 11:37 AM             Msg. 1 of 2
Hello,

I have a custom C# program that tries to Subscribe to a price feed for the ESZ0 contract. No price feeds come. I tried this on Win7 64 bit and Win XP sp2 32 bit.

I have .net Frameworks 2.0, 2.0 SP2, 3.0, 3.5 SP1 installed.

On the Win7 execution, it looks like there is an exception that is thrown and caught in the OEC library. Here it is...

Exception: "Key not valid for use in specified state." (System.Security.Cryptography.CryptographicException)

Thread: Reader Price [7076]

Look highly suspicious. The exception is thrown before "OnLoginComplete" is called.

Below is all the source code with the password removed. I'm able to connect, but calling Subscribe does not produce any price updates.

What am I doning wrong? This is holding up all of our projects.

Thanks,
JGronemus87


The code....

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using OEC.API;


namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
OECClient mOEC = new OECClient();

bool IsUp = false;
double LastPrice = 0.0;

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
this.toolStripStatusLabel1.Text = "Disconnected";

mOEC.OnPriceChanged += new OnPriceChangedEvent(this.OEC_OnPriceChanged);
mOEC.OnPriceTick += new OnPriceChangedEvent(this.OEC_OnPriceTick);

mOEC.OnOrderFilled += new OnOrderFilledEvent(this.OEC_OnOrderFilled);
mOEC.OnLoginComplete += new OnLoginCompleteEvent(this.OEC_OnLoginComplete);
mOEC.OnContractsChanged += new OnContractsChangedEvent(this.OEC_OnContractsChanged);
}


// connect and start the timer.
private void button1_Click(object sender, EventArgs e)
{
// Making this call will connect successfully but throw the exception listed above.
mOEC.Connect("sim.openecry.com", 9200, "JGronemus12", "Demo99273", false);
}

private void OEC_OnLoginComplete()
{
// This gets called, but the exception is already thown?
try
{
this.toolStripStatusLabel1.Text = "Connected";
mOEC.RequestContracts(mOEC.BaseContracts["ES"]);
}
catch (Exception Ex)
{

}
}


private void OEC_OnContractsChanged(OEC.API.BaseContract bc)
{
// This gets called but the exception is already thrown.
mOEC.Subscribe(mOEC.Contracts["ESZ0"]);
}


private void OEC_OnPriceChanged(Contract contract, Price price)
{
ProcessUpdate(contract, price);
}

private void OEC_OnPriceTick(Contract contract, Price price)
{
ProcessUpdate(contract, price);
}

void ProcessUpdate(Contract c, Price p)
{
// This never gets called. Why?
}



private void OEC_OnOrderFilled(Order ord, Fill fill)
{

}

}
}

John
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Nov 30, 2010 @ 12:38 PM             Msg. 2 of 2
Hello,

how did you get the text of exception? could you get a stack trace of the exception the same way? could you try to enable OECAPI logging and send me a log file with the issue?

I see you are trying to connect with your application and Trader. Did Trader receive prices? If yes, can you try to use DLLs from Trader in your application?

Victor Vins
Software Developer