Пример #1
0
        static void loadEventHandlers()
        {
            onNewFormDataEvent  += new NewStringDataHandler(ShowStatus);
            onNewSecurityEvent  += new NewStringDataHandler(ShowStatus);
            onNewTimeframeEvent += new NewStringDataHandler(ShowStatus);
            onNewStatusEvent    += new NewBoolDataHandler(ConnectionStatusReflect);
            onPositionSuscriber += new PositionDelegate(setTakingClosingPosition);

            bConnected  = false;
            bConnecting = false;
        }
Пример #2
0
        public static void ConnectorSetCallback(NewStringDataHandler new_form_data
                                                , NewStringDataHandler new_security
                                                , NewStringDataHandler new_timeframe
                                                , NewBoolDataHandler new_status)
        {
            if (!SetCallback(myCallbackDelegate))
            {
                throw (new Exception(EX_SETTING_CALLBACK));
            }

            TXmlConnector.send_new_form_data = new_form_data;
            TXmlConnector.send_new_security  = new_security;
            TXmlConnector.send_new_timeframe = new_timeframe;
            TXmlConnector.send_new_status    = new_status;
        }
Пример #3
0
        //================================================================================
        void MainFormLoad(object sender, EventArgs e)
        {
            ctl_Tabs.SelectTab("tab_Param");

            // параметры по умолчанию
            ServerIP   = "tr1.finam.ru";
            ServerPort = "3900";

            loadLogginDetails();

            session_timeout = 25;
            request_timeout = 10;

            comboBox1.Items.Add(new ComboboxItem()
            {
                Text = "FORTS", Value = 4
            });
            comboBox1.Items.Add(new ComboboxItem()
            {
                Text = "ММВБ", Value = 1
            });
            comboBox1.Items.Add(new ComboboxItem()
            {
                Text = "SPBEX", Value = 7
            });
            comboBox1.Items.Add(new ComboboxItem()
            {
                Text = "INF", Value = 8
            });
            comboBox1.Items.Add(new ComboboxItem()
            {
                Text = "MMA", Value = 14
            });
            comboBox1.Items.Add(new ComboboxItem()
            {
                Text = "ETS", Value = 8
            });

            comboBox1.SelectedIndex = 0;


            edt_Login.Text    = sLogin;
            edt_Password.Text = sPassword;
            edt_IP.Text       = ServerIP;
            edt_Port.Text     = ServerPort;

            bConnected  = false;
            bConnecting = false;

            Enable_Password_Controls(false);

            Init_Data();

            // открытие лог-файла
            log.StartLogging(AppDir + "log" + DateTime.Now.ToString("yyMMdd") + ".txt");

            TXmlConnector.statusTimeout = session_timeout * 1000;

            TXmlConnector.ConnectorSetCallback(OnNewFormData, OnNewSecurity, OnNewTimeframe, OnNewStatus);

            this.onNewFormDataEvent  += new NewStringDataHandler(Add_FormData);
            this.onNewSecurityEvent  += new NewStringDataHandler(Add_Security);
            this.onNewTimeframeEvent += new NewStringDataHandler(Add_Timeframe);
            this.onNewStatusEvent    += new NewBoolDataHandler(ConnectionStatusReflect);

            TXmlConnector.Orders4HMISubscribe(OrdersSubscriber);
            this.onOrdersPublished += new NewStringDataHandler(processOrdersDistribution);


            OportunityMonitor.init();

            TXmlConnector.FormReady = true;

            string LogPath = AppDir + "\0";

            if (TXmlConnector.ConnectorInitialize(LogPath, 3))
            {
                TXmlConnector.statusDisconnected.Set();
            }

            OportunityMonitor.subscribeQuotationUpdate(quotationCall);
            this.onQuotation += new quotationDelegate(setQuotationPrice);

            OportunityMonitor.PositionPublisherCallback(PositionPublisherCall);
            onPositionSuscriber += new PositionDelegate(setTakingClosingPosition);

            MamuschkaRepeater.mamushkaStatusSubscribe(mamuschkaStatusCall);
            onMamushkaStatusResponse += new NewStringDataHandler(setMamushkaServerStatus);
            MamuschkaRepeater.monitorMamuschkaServer();
        }
Пример #4
0
 public static void ClientSubscribe(NewStringDataHandler callback)
 {
     onClientPublisher = new NewStringDataHandler(callback);
 }
Пример #5
0
 public static void MarketsSubscribe(NewStringDataHandler callback)
 {
     onMarketsPublisher = new NewStringDataHandler(callback);
 }
Пример #6
0
 public static void Orders4HMISubscribe(NewStringDataHandler callback)
 {
     onOrders4HMIPublisher = new NewStringDataHandler(callback);
 }
Пример #7
0
 public static void NewQuotationCallback(NewStringDataHandler callback)
 {
     onNewQuotation = new NewStringDataHandler(callback);
 }
Пример #8
0
 public static void mamushkaStatusSubscribe(NewStringDataHandler callback)
 {
     onMamushkaStatusResponse = new NewStringDataHandler(callback);
 }
Пример #9
0
        public static void init()
        {
            monitoredSecurities = new List <Security>();

            TXmlConnector.NewQuotationCallback(NewQuotationCall);
            TXmlConnector.OrdersSubscribe(OrdersSubscriber);
            TXmlConnector.MarketsSubscribe(MarketsSubscriber);
            TXmlConnector.ClientSubscribe(ClientSubscriber);


            onNewQuotationEvent += new NewStringDataHandler(processQuotationsDistribution);
            onOrdersPublished   += new NewStringDataHandler(processOrdersDistribution);
            onMarketsPublished  += new NewStringDataHandler(processMarketsDistribution);
            onClientPublished   += new NewStringDataHandler(processClientDistribution);



            XmlRootAttribute rootNodeQuotations = new XmlRootAttribute {
                ElementName = "quotations"
            };
            XmlRootAttribute rootNodeOrders = new XmlRootAttribute {
                ElementName = "orders"
            };
            XmlRootAttribute rootNodeResult = new XmlRootAttribute
            {
                ElementName = "result"
            };
            XmlRootAttribute rootNodeMarkets = new XmlRootAttribute
            {
                ElementName = "markets"
            };
            XmlRootAttribute rootNodeClient = new XmlRootAttribute
            {
                ElementName = "client"
            };

            Type deserializeType = typeof(quotations);

            serializer4quotations    = new XmlSerializer(deserializeType, rootNodeQuotations);
            deserializeType          = typeof(orders);
            serializer4orders        = new XmlSerializer(deserializeType, rootNodeOrders);
            deserializeType          = typeof(result);
            serializer4results       = new XmlSerializer(deserializeType, rootNodeResult);
            deserializeType          = typeof(NewStopOrder);
            serializer4newStopOrders = new XmlSerializer(deserializeType);
            deserializeType          = typeof(markets);
            serializer4markets       = new XmlSerializer(deserializeType, rootNodeMarkets);
            deserializeType          = typeof(client);
            serializer4client        = new XmlSerializer(deserializeType, rootNodeClient);

            emptyNamespaces = new XmlSerializerNamespaces(new[] { XmlQualifiedName.Empty });

            settingsXmlWriter.Indent             = true;
            settingsXmlWriter.OmitXmlDeclaration = true;

            xs = new XmlReaderSettings
            {
                IgnoreWhitespace = true,
                ConformanceLevel = ConformanceLevel.Fragment,
                ProhibitDtd      = false
            };
        }