示例#1
0
        public void Test()
        {
            TestAuthResp();


            CBitfenixWebSockConnector bfxWebSock = new CBitfenixWebSockConnector(this,
                                                                                 GenListInstrument(),
                                                                                 true,
                                                                                 "fVgyf0Rk4hDDDdXAzys7yN0vnGcRPUVYRTLoOxTyDIL",
                                                                                 "MDqroztPvZzFIaKKspozdyeAD274OFAZnEZy2nv3eUE");

            bfxWebSock.Process();
            Thread.Sleep(300000000);
            // bfxWebSock.AddOrder(101,"tEDOUSD", TradingLib.Enums.EnmOrderDir.Buy, 4M, 1.2M);

            //bfxWebSock.AddMarketOrder(100, "tIOTUSD", TradingLib.Enums.EnmOrderDir.Buy, 6M, 1.69M);

            //  bfxWebSock.AddMarketOrder(100, "tIOTUSD", TradingLib.Enums.EnmOrderDir.Sell, 6M, 1.29M);
            //bfxWebSock.CancellOrder(7984743425);


            /*
             * while (!bfxWebSock.IsConnected)
             *  Thread.Sleep(100);
             *
             *
             * for (int i = 0; i < 30; i++)
             * {
             *  bfxWebSock.SendPing(i);
             * // Thread.Sleep(10);
             *
             * }*/
            Thread.Sleep(10000);
        }
        public void Test()
        {
            CBitfenixWebSockConnector bfxWebSock = new CBitfenixWebSockConnector(this,
                                                                                 GenListInstrument(),
                                                                                 true,
                                                                                 "fVgyf0Rk4hDDDdXAzys7yN0vnGcRPUVYRTLoOxTyDIL",
                                                                                 "MDqroztPvZzFIaKKspozdyeAD274OFAZnEZy2nv3eUE");


            ThreadPool.SetMinThreads(100, 100);
            //  System.Threading.Thread.Sleep(60000);

            //string path = @"e:\ATFS\Logs\TradeSystemCrypto\2018_06_27\BfxRaw_public___07_32_41.txt";
            string path = @"e:\temp993\1.txt";

            string [] lines = File.ReadAllLines(path);

            DateTime dtStart = DateTime.Now;

            Console.WriteLine("started" + CUtilTime.GetDateTimeString(dtStart));
            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i].Contains("== STARTED ==="))
                {
                    continue;
                }
                string msg = lines[i].Remove(0, 27);



                bfxWebSock.ProcessData(msg);
            }

            DateTime dtEnd = DateTime.Now;
            double   sec   = (dtEnd - dtStart).TotalSeconds;

            Console.WriteLine("Sec=" + sec);


            Console.ReadKey();
        }
        /*
         * public override bool IsStockAvailable(string instrument)
         * {
         *  return true;
         * }
         */



        public override void Process()
        {
            //2018-06-27
            CUtil.IncreaseProcessPriority();

            //2018-06-28 TODO make configurable or instruments num dependent
            ThreadPool.SetMinThreads(130, 130);

            base.Process();
            SetServerTimeAvailable();//just force for now

            _userDealsPosBoxCrypto.CreateDictBotDealId(ListBots);



            //TODO from DB etc
            Instruments.WaitInstrumentsLoaded();
            //_lstInstruments = GenerateListInstruments();
            _lstInstruments = Instruments.GetCryptoInstrDataList();



            //CreateStockConverters();

            CreateSnapshoters();
            _stockBoxCrypto = new CStockBoxCrypto(this, 100, this);

            _dealBoxCrypto = new CDealboxCrypto(this);
            IsDealsOnline  = true;
            EvDealsOnline.Set();

            _posBoxCrypto = new CPosBoxCrypto(this);
            EvPosOnline.Set();//TODO normal

            CreateTCPServerAndTradersDispatcher();
            _tradeHistStorV2 = new CTradeHistStorV2(this);
            _ordersHistStor  = new COrdersHistStor(this);



            //TODO from config
            //  _bfxAPIKey = "62NvrsDVwXDryVsGRU9uVkeDpYNdsnvTHfFnUGVVEsP";
            // _bfxAPISecret = "oNl3hdW0dxGtwN9UDSNNzNk74rzqgequpOcLuwtmNYz";

            _bfxAPIKey    = "fVgyf0Rk4hDDDdXAzys7yN0vnGcRPUVYRTLoOxTyDIL";
            _bfxAPISecret = "MDqroztPvZzFIaKKspozdyeAD274OFAZnEZy2nv3eUE";

            CUtil.ThreadStart(ThreadBfxRestV1);
            CUtil.ThreadStart(ThreadBfxRestV2);
            CUtil.ThreadStart(ThreadOneSecondLogics);
            CUtil.ThreadStart(Thread100MsLogics);

            _bfxWebSockConnector = new CBitfenixWebSockConnector(this,
                                                                 _lstInstruments,
                                                                 true, //isAuth
                                                                 _bfxAPIKey,
                                                                 _bfxAPISecret);

            _bfxWebSockConnector.Process();


            _bfxWebSockConnectorPublic = new CBitfenixWebSockConnector(this,
                                                                       _lstInstruments,
                                                                       false, //isAuth
                                                                       _bfxAPIKey,
                                                                       _bfxAPISecret);



            _bfxWebSockConnectorPublic.Process();

            IsAllBotLoaded       = true;
            IsOnlineUserOrderLog = true;
            IsOnlineUserDeals    = true;


            StartTradeManagerServer();

            EnableBotLogics();



            _evServerRunning.WaitOne();
        }