public static object TestGetStockPrices(string ticker) { Contract cc = new Contract(1, ticker, "STK", "SMART", "USD", "", 100, "", 0, "", "", "", "", new PositiveInteger(1)); Ether privateEther = new Ether(60); IBSource tws = new IBSource(privateEther, "127.0.0.1", 7496, 1, "DU74885", false, 60); tws.Connect(); tws.Subscribe(cc); double[] ret = new double[6]; privateEther.AsObservable <Market>().Subscribe(m => { ret[0] = m.BidSize; ret[1] = (double)m.Bid; ret[2] = (double)m.Mid; ret[3] = (double)m.Ask; ret[4] = m.AskSize; }); return(ret); tws.Unsubscribe(cc); }
//public static TWSOMS OMS; static XL_RTD() { IBAccountId = XL.Config.AppSettings.Settings["IBAccountId"].Value; IBClientId = Int32.Parse(XL.Config.AppSettings.Settings["IBClientId"].Value); IBHostname = XL.Config.AppSettings.Settings["IBHostname"].Value; IBPort = Int32.Parse(XL.Config.AppSettings.Settings["IBPort"].Value); Ether = new Ether(XL.EpochSecs); HeartbeatSource = new HeartbeatDataSource(DateTimeOffset.UtcNow, DateTimeOffset.MaxValue, XL.EpochSecs, "Epoch Heartbeat"); DataSource = new IBSource(Ether, IBHostname, IBPort, IBClientId, IBAccountId, false, 86400000); //OMS = new TWSOMS(Ether, IBHostname, IBPort, IBClientId + 1); dynamic excel = ExcelDnaUtil.Application; excel.RTD.ThrottleInterval = 500; }