private void _login_Click(object sender, EventArgs e) { // only login once if (login()) { return; } try { m_session.CreateSessionWindow(this.Handle, 0); // setting up session callbacks m_session.HookExecMsgChat(new GTSession.PFNOnExecMsgChat(OnSessionExecMsgChat)); m_session.HookExecMsgErrMsg(new GTSession.PFNOnExecMsgErrMsg(OnSessionExecMsgErrMsg)); m_session.HookExecConnected(new GTSession.PFNOnExecConnected(OnExecConnected)); m_session.HookExecDisconnected(new GTSession.PFNOnExecDisconnected(OnExecDisconnected)); m_session.HookExecMsgState(new GTSession.PFNOnExecMsgState(OnSessionExecMsgState)); m_session.HookQuoteConnected(new GTSession.PFNOnQuoteConnected(OnQuoteConnected)); m_session.HookQuoteDisconnected(new GTSession.PFNOnQuoteDisconnected(OnQuoteDisconnected)); m_session.HookExecMsgLoggedin(new GTSession.PFNOnExecMsgLoggedin(OnExecMsgLoggedin)); m_session.HookGotLevel2Text(new GTSession.PFNOnGotLevel2Text(OnGotLevel2Text)); m_session.HookGotQuoteText(new GTSession.PFNOnGotQuoteText(OnGotQuoteText)); m_session.HookLevel2Connected(new GTSession.PFNOnLevel2Connected(OnLevel2Connected)); m_session.HookLevel2Disconnected(new GTSession.PFNOnLevel2Disconnected(OnLevel2Disconnected)); // login GTSession.GTSession32 session32 = m_session.GetSession32(); GTSession.GTime32 time32 = m_session.GetTime32(); GTSession.GTSetting32 setting32 = m_session.GetSetting32(); GTSession.gtSetExecAddress(m_session, "10.1.12.3", 16805); GTSession.gtSetQuoteAddress(m_session, "192.168.3.200", 16811); GTSession.gtSetLevel2Address(m_session, "192.168.3.200", 16810); int err = GTSession.gtLogin(m_session, _user.Text, _pass.Text); if (err == 0) { debug("login succeeded."); BackColor = Color.Green; Invalidate(true); _ok = true; } else { _ok = false; debug("login failed."); } } catch (Exception ex) { debug(ex.Message); debug(ex.StackTrace); debug("login failed."); } }
public ServerGenesisMain() { InitializeComponent(); // this.ContextMenu = new ContextMenu(); ContextMenu.MenuItems.Add("messages", new EventHandler(togmessage)); // tradelink events tl.newAcctRequest += new StringDelegate(tl_newAcctRequest); tl.newFeatureRequest += new MessageArrayDelegate(tl_newFeatureRequest); tl.newOrderCancelRequest += new UIntDelegate(tl_newOrderCancelRequest); tl.newRegisterStocks += new DebugDelegate(tl_newRegisterStocks); tl.newSendOrderRequest += new OrderDelegate(tl_newSendOrderRequest); tl.newProviderName = Providers.Genesis; tl.newUnknownRequest += new UnknownMessageDelegate(tl_newUnknownRequest); FormClosing += new FormClosingEventHandler(ServerGenesisMain_FormClosing); // genesis init m_session = new GTSession(); }
protected virtual int OnSessionExecMsgErrMsg(UInt32 hSession, GTSession.GTErrMsg32 errmsg) { string strMsg = GTSession.GetErrorMessage(errmsg); return(0); }
protected virtual int OnStockGotQuoteLevel2(UInt32 hStock, GTSession.GTLevel232 level232) { return 0; GTStock stock = new GTStock(hStock); if (stock.GetAskLevel2Count() > 0 && stock.GetBidLevel2Count() > 0) if (stock.GetAskLevel2Item(0).dblPrice < stock.GetBidLevel2Item(0).dblPrice) { //string str = "L1:" + level132.szStock + " " + level132.dblBidPrice + " " + level132.dblAskPrice; string str = "BID: " + stock.GetBidLevel2Item(0).dblPrice + " " + "ASK: " + stock.GetAskLevel2Item(0).dblPrice; //listMsg.Items.Insert(0, str); } return 0; }
protected virtual int OnStockSendingOrder(UInt32 hStock, GTSession.GTSending32 pending) { // get order Order o = new OrderImpl(pending.szStock, pending.nEntryShares); o.id = (uint)pending.dwTicketNo; o.side = pending.chEntrySide == 'B'; //o.TIF = pending.nEntryTIF; o.Account = pending.szAccountID; o.date = pending.nEntryDate; o.time = pending.nEntryTime; // is this limit v stop? char type = pending.chPriceIndicator; // not sure about these two o.price = (decimal)pending.dblEntryPrice; o.stopp = (decimal)pending.dblEntryStopLimitPrice; // notify clients tl.newOrder(o); return 0; }
protected virtual int OnStockExecMsgRejectCancel(UInt32 hStock, GTSession.GTRejectCancel32 reject) { string str = ((reject.chPendSide == 'B') ? "Bid" : (reject.chPendSide == 'S') ? "Ask" : "Short sold") + " " + reject.szStock + " @" + reject.dblPendPrice + " Rejected : " + reject.szRejectReason; debug(str); return 0; }
protected virtual int OnStockExecMsgCancel(UInt32 hStock, GTSession.GTCancel32 cancel) { // notify clients of cancel tl.newOrderCancel(cancel.dwTicketNo); return 0; }
protected virtual int OnStockExecMsgPrint(UInt32 hStock, GTSession.GTPrint32 print) { return 0; }
protected virtual int OnStockExecMsgSending(UInt32 hStock, GTSession.GTSending32 pending) { return 0; }
protected virtual int OnStockExecMsgTrade(UInt32 hStock, GTSession.GTTrade32 trade) { // map a trade object Trade t = new TradeImpl(trade.szStock, (decimal)trade.dblExecPrice, trade.nExecShares); // map remaining fields t.Account = trade.szAccountID; t.id = (uint)trade.dwTicketNo; t.side = trade.chExecSide == 'B'; t.xdate = trade.nExecDate; t.xtime = trade.nExecTime; // notify clients tl.newFill(t); return 0; }
protected virtual int OnStockExecMsgOpenPosition(UInt32 hStock, GTSession.GTOpenPosition32 openposition) { return 0; }
protected virtual int OnGotQuoteText(UInt32 hSession, GTSession.GTQuoteText32 text) { return 0; }
protected virtual int OnSessionExecMsgErrMsg(UInt32 hSession, GTSession.GTErrMsg32 errmsg) { string strMsg = GTSession.GetErrorMessage(errmsg); return 0; }
protected virtual int OnSessionExecMsgState(UInt32 hSession, GTSession.GTServerState32 state) { //message.Items.Insert(0, state.szServer + ": " + state.nConnect); return 0; }
protected virtual int OnSessionExecMsgChat(UInt32 hSession, GTSession.GTChat32 chat) { return 0; }