Пример #1
0
 public void Stop()
 {
     try
     {
         _runbg = false;
         stiQuote.DeRegisterAllQuotes();
         stiBook   = null;
         stiOrder  = null;
         stiPos    = null;
         stiEvents = null;
         stiQuote  = null;
         if ((_bw.ThreadState != ThreadState.Aborted) || (_bw.ThreadState != ThreadState.Stopped))
         {
             try
             {
                 _bw.Abort();
             }
             catch { }
         }
     }
     catch (Exception ex)
     {
         debug(ex.Message + ex.StackTrace);
     }
     if (tl != null)
     {
         tl.Stop();
     }
 }
Пример #2
0
 public void Stop()
 {
     try
     {
         _runbg = false;
         stiQuote.DeRegisterAllQuotes();
         stiBook = null;
         stiOrder = null;
         stiPos = null;
         stiEvents = null;
         stiQuote = null;
         if ((_bw.ThreadState != ThreadState.Aborted) || (_bw.ThreadState != ThreadState.Stopped))
         {
             try
             {
                 _bw.Abort();
             }
             catch { }
         }
     }
     catch (Exception ex)
     {
         debug(ex.Message + ex.StackTrace);
     }
     if (tl != null)
         tl.Stop();
 }
Пример #3
0
        public bool Start()
        {
            try
            {
                if (_connected) return true;
                ost = new OversellTracker(pt);
                ost.Split = OversellSplit;
                ost.SendOrderEvent += new OrderDelegate(ost_SendOrderEvent);
                ost.SendDebugEvent += new DebugDelegate(ost_SendDebugEvent);
                debug(Util.TLSIdentity());
                debug("Attempting to start: " + PROGRAM);
                // basic structures needed for operation
                stiEvents = new STIEvents();
                stiOrder = new STIOrderMaint();
                stiPos = new STIPosition();
                stiQuote = new STIQuote();
                stiBook = new STIBook();
                stiApp = new STIApp();
                _bw = new Thread(new ParameterizedThreadStart(background));
                _runbg = true;
                _bw.Start();
                ptt.GotCancelEvent+=new LongDelegate(tl.newCancel);
                ptt.GotFillEvent+=new FillDelegate(tl.newFill);
                ptt.GotOrderEvent+=new OrderDelegate(tl.newOrder);
                ptt.SendDebugEvent += new DebugDelegate(ptt_SendDebugEvent);
                ptt.UseBidAskFills = isPaperTradeUsingBidAsk;

                stiEvents.OnSTIShutdown += new _ISTIEventsEvents_OnSTIShutdownEventHandler(stiEvents_OnSTIShutdown);
                stiEvents.SetOrderEventsAsStructs(true);

                stiEvents.OnSTIOrderUpdate += new _ISTIEventsEvents_OnSTIOrderUpdateEventHandler(stiEvents_OnSTIOrderUpdate);
                stiEvents.OnSTIOrderUpdateXML += new _ISTIEventsEvents_OnSTIOrderUpdateXMLEventHandler(stiEvents_OnSTIOrderUpdateXML);
                stiEvents.OnSTITradeUpdate += new _ISTIEventsEvents_OnSTITradeUpdateEventHandler(stiEvents_OnSTITradeUpdate);
                stiEvents.OnSTITradeUpdateXML += new _ISTIEventsEvents_OnSTITradeUpdateXMLEventHandler(stiEvents_OnSTITradeUpdateXML);
                stiPos.OnSTIPositionUpdate += new _ISTIPositionEvents_OnSTIPositionUpdateEventHandler(stiPos_OnSTIPositionUpdate);
                stiPos.OnSTIPositionUpdateXML += new _ISTIPositionEvents_OnSTIPositionUpdateXMLEventHandler(stiPos_OnSTIPositionUpdateXML);
                stiQuote.OnSTIQuoteUpdate += new _ISTIQuoteEvents_OnSTIQuoteUpdateEventHandler(stiQuote_OnSTIQuoteUpdate);
                stiQuote.OnSTIQuoteSnap += new _ISTIQuoteEvents_OnSTIQuoteSnapEventHandler(stiQuote_OnSTIQuoteSnap);
                stiEvents.OnSTIOrderRejectMsg += new _ISTIEventsEvents_OnSTIOrderRejectMsgEventHandler(stiEvents_OnSTIOrderRejectMsg);
                stiEvents.OnSTIOrderRejectXML += new _ISTIEventsEvents_OnSTIOrderRejectXMLEventHandler(stiEvents_OnSTIOrderRejectXML);
                stiEvents.OnSTIOrderReject += new _ISTIEventsEvents_OnSTIOrderRejectEventHandler(stiEvents_OnSTIOrderReject);
                stiQuote.OnSTIQuoteUpdateXML += new _ISTIQuoteEvents_OnSTIQuoteUpdateXMLEventHandler(stiQuote_OnSTIQuoteUpdateXML);
                stiQuote.OnSTIQuoteSnapXML += new _ISTIQuoteEvents_OnSTIQuoteSnapXMLEventHandler(stiQuote_OnSTIQuoteSnapXML);
                stiPos.GetCurrentPositions();

                tl.newAcctRequest += new StringDelegate(tl_newAcctRequest);
                tl.newProviderName = Providers.Sterling;
                tl.newSendOrderRequest += new OrderDelegateStatus(tl_gotSrvFillRequest);
                tl.newPosList += new PositionArrayDelegate(tl_gotSrvPosList);
                tl.newRegisterSymbols += new SymbolRegisterDel(tl_newRegisterSymbols);
                tl.newOrderCancelRequest += new LongDelegate(tl_OrderCancelRequest);
                tl.newFeatureRequest += new MessageArrayDelegate(tl_newFeatureRequest);
                tl.newUnknownRequest += new UnknownMessageDelegate(tl_newUnknownRequest);
                tl.newImbalanceRequest += new VoidDelegate(tl_newImbalanceRequest);
                tl.SendDebugEvent += new DebugDelegate(tl_SendDebugEvent);
                stiApp.SetModeXML(UseXmlMode);
                string trader = stiApp.GetTraderName().ToUpper();
                debug("trader: " + trader);
                if (!accts.Contains(trader))
                {
                    accts.Add(trader);
                    debug("accounts: " + string.Join(",", Accounts));
                }

                if(VerboseDebugging)
                    debug("Verbose Mode On.");
                if (isPaperTradeEnabled)
                    debug("Papertrading enabled.");

            }
            catch (Exception ex)
            {
                debug(ex.Message + ex.StackTrace);
                _connected = false;
                return false;
            }
            debug(PROGRAM + " started.");
            _connected = true;
            return _connected;
        }
Пример #4
0
        public bool Start()
        {
            try
            {
                if (_connected) return true;
                ost = new OversellTracker(pt,_idt);
                ost.MinLotSize = MinLotSize;
                ost.Split = OversellSplit;
                ost.SendOrderEvent += new OrderDelegate(ost_SendOrderEvent);
                ost.SendDebugEvent += new DebugDelegate(ost_SendDebugEvent);
                ost.SendCancelEvent += new LongDelegate(reqcancel);
                ost.VerboseDebugging = VerboseDebugging;
                sho.SendDebugEvent+=new DebugDelegate(v);
                sho.DefaultAccount = Account;
                sho.VerboseDebugging = VerboseDebugging;
                
                debug(Util.TLSIdentity());
                debug("Attempting to start: " + PROGRAM);
                // basic structures needed for operation
                stiEvents = new STIEvents();
                stiOrder = new STIOrderMaint();
                stiPos = new STIPosition();
                stiQuote = new STIQuote();
                stiBook = new STIBook();
                stiApp = new STIApp();
                stiMaint = new STIAcctMaint();
                _bw = new Thread(new ParameterizedThreadStart(background));
                _runbg = true;
                _bw.Start();
                ptt.GotCancelEvent+=new LongDelegate(newcancel);
                ptt.GotFillEvent += new FillDelegate(tl.newFill);
                ptt.GotOrderEvent+=new OrderDelegate(tl.newOrder);
                ptt.SendDebugEvent += new DebugDelegate(ptt_SendDebugEvent);
                ptt.UseBidAskFills = isPaperTradeUsingBidAsk;

                stiEvents.OnSTIShutdown += new _ISTIEventsEvents_OnSTIShutdownEventHandler(stiEvents_OnSTIShutdown);
                stiEvents.SetOrderEventsAsStructs(true);
                stiApp.SetModeXML(UseXmlMode);

                stiEvents.OnSTIOrderUpdate += new _ISTIEventsEvents_OnSTIOrderUpdateEventHandler(stiEvents_OnSTIOrderUpdate);
                stiEvents.OnSTIOrderUpdateXML += new _ISTIEventsEvents_OnSTIOrderUpdateXMLEventHandler(stiEvents_OnSTIOrderUpdateXML);
                stiEvents.OnSTITradeUpdate += new _ISTIEventsEvents_OnSTITradeUpdateEventHandler(stiEvents_OnSTITradeUpdate);
                stiEvents.OnSTITradeUpdateXML += new _ISTIEventsEvents_OnSTITradeUpdateXMLEventHandler(stiEvents_OnSTITradeUpdateXML);
                stiPos.OnSTIPositionUpdate += new _ISTIPositionEvents_OnSTIPositionUpdateEventHandler(stiPos_OnSTIPositionUpdate);
                stiPos.OnSTIPositionUpdateXML += new _ISTIPositionEvents_OnSTIPositionUpdateXMLEventHandler(stiPos_OnSTIPositionUpdateXML);
                stiQuote.OnSTIQuoteUpdate += new _ISTIQuoteEvents_OnSTIQuoteUpdateEventHandler(stiQuote_OnSTIQuoteUpdate);
                stiQuote.OnSTIQuoteSnap += new _ISTIQuoteEvents_OnSTIQuoteSnapEventHandler(stiQuote_OnSTIQuoteSnap);
                stiEvents.OnSTIOrderRejectMsg += new _ISTIEventsEvents_OnSTIOrderRejectMsgEventHandler(stiEvents_OnSTIOrderRejectMsg);
                stiEvents.OnSTIOrderRejectXML += new _ISTIEventsEvents_OnSTIOrderRejectXMLEventHandler(stiEvents_OnSTIOrderRejectXML);
                stiEvents.OnSTIOrderReject += new _ISTIEventsEvents_OnSTIOrderRejectEventHandler(stiEvents_OnSTIOrderReject);
                stiQuote.OnSTIQuoteUpdateXML += new _ISTIQuoteEvents_OnSTIQuoteUpdateXMLEventHandler(stiQuote_OnSTIQuoteUpdateXML);
                stiQuote.OnSTIQuoteSnapXML += new _ISTIQuoteEvents_OnSTIQuoteSnapXMLEventHandler(stiQuote_OnSTIQuoteSnapXML);

                Array acctlist = new string[0];
                stiMaint.GetAccountList(ref acctlist);
                if (acctlist.Length > 0)
                {
                    foreach (string au in acctlist)
                        Accounts = new string[] { au};


                }
                stiPos.GetCurrentPositions();
                

                tl.newAcctRequest += new StringDelegate(tl_newAcctRequest);
                tl.newProviderName = Providers.Sterling;
                tl.newSendOrderRequest += new OrderDelegateStatus(tl_gotSrvFillRequest);
                tl.newPosList += new PositionArrayDelegate(tl_gotSrvPosList);
                tl.newRegisterSymbols += new SymbolRegisterDel(tl_newRegisterSymbols);
                tl.newOrderCancelRequest += new LongDelegate(tl_OrderCancelRequest);
                tl.newFeatureRequest += new MessageArrayDelegate(tl_newFeatureRequest);
                tl.newUnknownRequest += new UnknownMessageDelegate(tl_newUnknownRequest);
                tl.newImbalanceRequest += new VoidDelegate(tl_newImbalanceRequest);
                tl.SendDebugEvent += new DebugDelegate(tl_SendDebugEvent);
                
                string trader = stiApp.GetTraderName().ToUpper();
                debug("trader: " + trader);
                if (!accts.Contains(trader))
                {
                    accts.Add(trader);
                    debug("accounts: " + string.Join(",", Accounts));
                }

                debug("VerboseDebugging: " + (VerboseDebugging ? "ON" : "disabled."));
                debug("PaperTrade: " + (isPaperTradeEnabled ? "ON" : "disabled."));
                debug("OversellSplit: " + (OversellSplit ? "ON" : "disabled."));
                debug("CoverEnabled: " + (CoverEnabled? "ON" : "disabled."));
                debug("RegSHOShorts: " + (RegSHOShorts ? "ON" : "disabled."));
                debug("ServerStops: " + (UseServerStops ? "ON" : "disabled."));
                debug("SendCancelOnRejects: "+(SendCancelOnReject ? "ON" : "disabled."));
                debug("SendCancelOnError: " + (SendCancelOnError? "ON" : "disabled."));
                debug("UseSubscribedSymbolForNotify: " + (UseSubscribedSymbolForNotify? "ON" : "disabled."));
                
                
            }
            catch (Exception ex)
            {
                debug(ex.Message + ex.StackTrace);
                _connected = false;
                return false;
            }
            debug(PROGRAM + " started.");
            _connected = true;
            return _connected;
        }
Пример #5
0
        public bool Start()
        {
            try
            {
                if (_connected)
                {
                    return(true);
                }
                ost                 = new OversellTracker(pt);
                ost.Split           = OversellSplit;
                ost.SendOrderEvent += new OrderDelegate(ost_SendOrderEvent);
                ost.SendDebugEvent += new DebugDelegate(ost_SendDebugEvent);
                debug(Util.TLSIdentity());
                debug("Attempting to start: " + PROGRAM);
                // basic structures needed for operation
                stiEvents = new STIEvents();
                stiOrder  = new STIOrderMaint();
                stiPos    = new STIPosition();
                stiQuote  = new STIQuote();
                stiBook   = new STIBook();
                stiApp    = new STIApp();
                _bw       = new Thread(new ParameterizedThreadStart(background));
                _runbg    = true;
                _bw.Start();
                ptt.GotCancelEvent += new LongDelegate(tl.newCancel);
                ptt.GotFillEvent   += new FillDelegate(tl.newFill);
                ptt.GotOrderEvent  += new OrderDelegate(tl.newOrder);
                ptt.SendDebugEvent += new DebugDelegate(ptt_SendDebugEvent);
                ptt.UseBidAskFills  = isPaperTradeUsingBidAsk;

                stiEvents.OnSTIShutdown += new _ISTIEventsEvents_OnSTIShutdownEventHandler(stiEvents_OnSTIShutdown);
                stiEvents.SetOrderEventsAsStructs(true);

                stiEvents.OnSTIOrderUpdate    += new _ISTIEventsEvents_OnSTIOrderUpdateEventHandler(stiEvents_OnSTIOrderUpdate);
                stiEvents.OnSTIOrderUpdateXML += new _ISTIEventsEvents_OnSTIOrderUpdateXMLEventHandler(stiEvents_OnSTIOrderUpdateXML);
                stiEvents.OnSTITradeUpdate    += new _ISTIEventsEvents_OnSTITradeUpdateEventHandler(stiEvents_OnSTITradeUpdate);
                stiEvents.OnSTITradeUpdateXML += new _ISTIEventsEvents_OnSTITradeUpdateXMLEventHandler(stiEvents_OnSTITradeUpdateXML);
                stiPos.OnSTIPositionUpdate    += new _ISTIPositionEvents_OnSTIPositionUpdateEventHandler(stiPos_OnSTIPositionUpdate);
                stiPos.OnSTIPositionUpdateXML += new _ISTIPositionEvents_OnSTIPositionUpdateXMLEventHandler(stiPos_OnSTIPositionUpdateXML);
                stiQuote.OnSTIQuoteUpdate     += new _ISTIQuoteEvents_OnSTIQuoteUpdateEventHandler(stiQuote_OnSTIQuoteUpdate);
                stiQuote.OnSTIQuoteSnap       += new _ISTIQuoteEvents_OnSTIQuoteSnapEventHandler(stiQuote_OnSTIQuoteSnap);
                stiEvents.OnSTIOrderRejectMsg += new _ISTIEventsEvents_OnSTIOrderRejectMsgEventHandler(stiEvents_OnSTIOrderRejectMsg);
                stiEvents.OnSTIOrderRejectXML += new _ISTIEventsEvents_OnSTIOrderRejectXMLEventHandler(stiEvents_OnSTIOrderRejectXML);
                stiEvents.OnSTIOrderReject    += new _ISTIEventsEvents_OnSTIOrderRejectEventHandler(stiEvents_OnSTIOrderReject);
                stiQuote.OnSTIQuoteUpdateXML  += new _ISTIQuoteEvents_OnSTIQuoteUpdateXMLEventHandler(stiQuote_OnSTIQuoteUpdateXML);
                stiQuote.OnSTIQuoteSnapXML    += new _ISTIQuoteEvents_OnSTIQuoteSnapXMLEventHandler(stiQuote_OnSTIQuoteSnapXML);
                stiPos.GetCurrentPositions();

                tl.newAcctRequest        += new StringDelegate(tl_newAcctRequest);
                tl.newProviderName        = Providers.Sterling;
                tl.newSendOrderRequest   += new OrderDelegateStatus(tl_gotSrvFillRequest);
                tl.newPosList            += new PositionArrayDelegate(tl_gotSrvPosList);
                tl.newRegisterSymbols    += new SymbolRegisterDel(tl_newRegisterSymbols);
                tl.newOrderCancelRequest += new LongDelegate(tl_OrderCancelRequest);
                tl.newFeatureRequest     += new MessageArrayDelegate(tl_newFeatureRequest);
                tl.newUnknownRequest     += new UnknownMessageDelegate(tl_newUnknownRequest);
                tl.newImbalanceRequest   += new VoidDelegate(tl_newImbalanceRequest);
                tl.SendDebugEvent        += new DebugDelegate(tl_SendDebugEvent);
                stiApp.SetModeXML(UseXmlMode);
                string trader = stiApp.GetTraderName().ToUpper();
                debug("trader: " + trader);
                if (!accts.Contains(trader))
                {
                    accts.Add(trader);
                    debug("accounts: " + string.Join(",", Accounts));
                }

                if (VerboseDebugging)
                {
                    debug("Verbose Mode On.");
                }
                if (isPaperTradeEnabled)
                {
                    debug("Papertrading enabled.");
                }
            }
            catch (Exception ex)
            {
                debug(ex.Message + ex.StackTrace);
                _connected = false;
                return(false);
            }
            debug(PROGRAM + " started.");
            _connected = true;
            return(_connected);
        }