0

I had been trying to use the C#API to access HOng Kong Stock Fundamental Data. Some Background:

I tried the same program for accessing Hong Kong Stock market data and it is working, as follow:

namespace IB_Real_time_Console_CS
{
    class Program
    {
        static void Main(string[] args)
        {
            Samples.EWrapperImpl ibClient = new Samples.EWrapperImpl();
            ibClient.ClientSocket.eConnect("", 7496, 0);
            var reader = new EReader(ibClient.ClientSocket, ibClient.Signal);
            reader.Start();
            new Thread(() =>
            {
                while (ibClient.ClientSocket.IsConnected())
                {
                    ibClient.Signal.waitForSignal();
                    reader.processMsgs();
                }
            })
            { IsBackground = true }.Start();
            while (ibClient.NextOrderId <= 0) { }

            Contract contract = new Contract();
            contract.Symbol = "700";
            contract.SecType = "STK";
            contract.Exchange = "SEHK";
            contract.Currency = "HKD";

            List<TagValue> mktDataOptions = new List<TagValue>();
ibClient.ClientSocket.reqMktData(1, contract, "", true, false, mktDataOptions);

            // Pause so we can view the output
            Console.ReadKey();

            ibClient.ClientSocket.cancelMktData(1);
            ibClient.ClientSocket.eDisconnect();


        }   //end Main
    }       //end class Program
}           //end namespace IB_Real_time_console_cs

My aim is to access fundamental data. So I change this line of code: ibClient.ClientSocket.reqMktData(1, contract, "", true, false, mktDataOptions);

into this: ibClient.ClientSocket.reqMktData(1, contract, "258", true, false, mktDataOptions);

However I run into the following errors:

Error ID:-1 code:2104: Msg: Market data farm connection is OK:hfarm
Error ID:-1 code:2104: Msg: Market data farm connection is OK:usfuture
Error ID:-1 code:2104: Msg: Market data farm connection is OK:cashfarm
Error ID:-1 code:2104: Msg: Market data farm connection is OK:usfarm

Error ID:-1 code:2106: Msg: HMDS data farm connection is OK:ushmds.us
Error ID:-1 code:2106: Msg: HMDS data farm connection is OK:hkhmds
Error ID:-1 code:2106: Msg: HMDS data farm connection is OK:fundfarm
Error ID:-1 code:2106: Msg: HMDS data farm connection is OK:ushmds

Error ID:1, code 321, Msg:Error validating request:-'bo': cause-snapshot market data subscription is not applicable to generic ticks

Error ID:-1 code 2108, Msg: Market data farm connection is inactive but should be available upon demand.usfuture
Error ID:-1 code 2108, Msg: Market data farm connection is inactive but should be available upon demand.usfuture
Error ID:-1 code 2108, Msg: Market data farm connection is inactive but should be available upon demand.cashfarm
Error ID:-1 code 2108, Msg: Market data farm connection is inactive but should be available upon demand.cashfarm

Can anyabody point out what's wrong with this change of code? Alternatively, how can fundamental data be accessed? Thank you very much..

brian
  • 10,619
  • 4
  • 21
  • 79

1 Answers1

1

Read your errors, most of them are just information about the connection, the one I highlighted tells you the problem. You're asking for a snapshot and you're not allowed. The 4th arg is bool snapshot, set this to false.

void reqMktData (   int     tickerId,
    Contract    contract,
    string  genericTickList,
    bool    snapshot,
    bool    regulatorySnaphsot,
    List< TagValue >    mktDataOptions 
)       

ibClient.ClientSocket.reqMktData(1, contract, "258", false, false, mktDataOptions);

brian
  • 10,619
  • 4
  • 21
  • 79