Esempio n. 1
0
        private static void ShowInstrument()
        {
            Console.Write("Enter algorithm id and Press Enter:");
            long?algoId = TryReadLong();

            if (algoId == null)
            {
                Console.WriteLine("Invalid value.");
                return;
            }
            ShowIndentedJson(mmRestService.GetInstrument(algoId.Value));
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            try
            {
                baseUrl = args.Length > 0 ? args[0] : null;
                if (string.IsNullOrEmpty(baseUrl))
                {
                    Console.WriteLine("String is null or empty");
                    return;
                }
                mmRestService = MarketMakerRestServiceFactory.CreateMakerRestService(baseUrl, "/oauth/token", authorization);
                mmRestService.Authorize("admin", "admin");


                var ws = new SubscriptionFactory("wss://18.218.146.41:8990/websocket/v0", mmRestService.Token);

                // Receive instrument by ID
                _instrument          = mmRestService.GetInstrument(_algoId);
                _originalBuyMargins  = _instrument.PricerConfig.BuyMargins;
                _originalSellMargins = _instrument.PricerConfig.SellMargins;

                var tradeStatisticsSubs = ws.CreateTradingStatisticsSubscription();

                // Subscribe for trade statistics
                tradeStatisticsSubs.Subscribe(OnStatisticsMessage);

                Console.ReadLine();
                tradeStatisticsSubs.Unsubscribe(OnStatisticsMessage);
                ws.Close();
                Console.ReadLine();

                /*
                 * Console.Clear();
                 * var menuItems = GetMenuItems();
                 * var options = GetMenuOptions();
                 * ShowOptions(menuItems, options);
                 * while (true)
                 * {
                 * Console.Write("Select option and press Enter:");
                 * var s = Console.ReadLine();
                 * if (string.IsNullOrWhiteSpace(s))
                 * s = " ";
                 * else
                 * s = s.ToLower();
                 * if (s.Contains("clear") || s.Contains("cls"))
                 * {
                 * Console.Clear();
                 * ShowOptions(menuItems, options);
                 * continue;
                 * }
                 * if (s.Contains("exit") || s.Contains("quit"))
                 * {
                 * return;
                 * }
                 * var option = GetChoice(options, s[0]);
                 * if (option == -1 || option >= menuItems.Length)
                 * {
                 * Console.WriteLine("Incorrect choice.");
                 * Console.WriteLine();
                 * ShowOptions(menuItems, options);
                 * continue;
                 * }
                 * try
                 * {
                 * Console.WriteLine($"('{menuItems[option].Item1}' was selected)");
                 * menuItems[option].Item2();
                 * }
                 * catch (Exception ex)
                 * {
                 * Console.WriteLine(ex.ToString());
                 * }
                 * }
                 */
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
Esempio n. 3
0
        public void AddChangeStopFullInstrumentConfig()
        {
            Initialize();

            _testEvent.Algorithms[0].InstrumentConfigInfo = _mmRest.CreateInstrument(_testEvent.Algorithms[0].InstrumentConfigInfo);
            _testEvent.Algorithms[0].SetAlgoId(_testEvent.Algorithms[0].InstrumentConfigInfo.AlgoId);
            _testEvent.Algorithms[0].PricerConfigInfo = _mmRest.SavePricer(_testEvent.Algorithms[0].PricerConfigInfo);

            _testEvent.Algorithms[0].HedgerConfigInfo    = _mmRest.SaveHedger(_testEvent.Algorithms[0].HedgerConfigInfo);
            _testEvent.Algorithms[0].RiskLimitConfigInfo = _mmRest.SaveRiskLimitsConfig(_testEvent.Algorithms[0].RiskLimitConfigInfo);
            Thread.Sleep(1000);
            // Check full config
            bool testResult = _testEvent.Algorithms[0].Equals(_mmRest.GetInstrument(_testEvent.Algorithms[0].AlgoId));

            _mmRest.StartInstrument(_testEvent.Algorithms[0].AlgoId);
            _testEvent.Algorithms[0].InstrumentConfigInfo.Running = true;
            _mmRest.StartPricer(_testEvent.Algorithms[0].AlgoId);
            _testEvent.Algorithms[0].PricerConfigInfo.Running = true;
            _mmRest.StartHedger(_testEvent.Algorithms[0].AlgoId);
            _testEvent.Algorithms[0].HedgerConfigInfo.Running = true;
            Thread.Sleep(1000);
            // Check start
            testResult = _testEvent.Algorithms[0].Equals(_mmRest.GetInstrument(_testEvent.Algorithms[0].AlgoId)) && testResult;

            // Change pricer
            PricerConfigDto newPricerConfig = AlgorithmInfo.CreateConfig <PricerConfigDto>("pricer3.json", _testEvent.Algorithms[0].AlgoId);

            _testEvent.Algorithms[0].PricerConfigInfo = _mmRest.SavePricer(newPricerConfig);
            // Change hedger
            HedgerConfigDto newHedgerConfig = AlgorithmInfo.CreateConfig <HedgerConfigDto>("hedger2.json", _testEvent.Algorithms[0].AlgoId);

            _testEvent.Algorithms[0].HedgerConfigInfo = _mmRest.SaveHedger(newHedgerConfig);
            // Change riskLimits
            RiskLimitsConfigDto newRiskLimitsConfig = AlgorithmInfo.CreateConfig <RiskLimitsConfigDto>("riskLimit3.json", _testEvent.Algorithms[0].AlgoId);

            _testEvent.Algorithms[0].RiskLimitConfigInfo = _mmRest.SaveRiskLimitsConfig(newRiskLimitsConfig);
            Thread.Sleep(1000);
            // Check after change
            testResult = _testEvent.Algorithms[0].Equals(_mmRest.GetInstrument(_testEvent.Algorithms[0].AlgoId)) && testResult;

            _mmRest.StopHedger(_testEvent.Algorithms[0].AlgoId);
            _testEvent.Algorithms[0].InstrumentConfigInfo.Running = false;
            _mmRest.StopPricer(_testEvent.Algorithms[0].AlgoId);
            _testEvent.Algorithms[0].PricerConfigInfo.Running = false;
            _mmRest.StopInstrument(_testEvent.Algorithms[0].AlgoId);
            _testEvent.Algorithms[0].HedgerConfigInfo.Running = false;
            Thread.Sleep(1000);
            // Check stop
            testResult = _testEvent.Algorithms[0].Equals(_mmRest.GetInstrument(_testEvent.Algorithms[0].AlgoId)) && testResult;

            _mmRest.DeleteAlgorithm(_testEvent.Algorithms[0].AlgoId);
            Thread.Sleep(1000);
            // Check delete and test result
            Assert.AreEqual(true, _mmRest.GetInstrument(_testEvent.Algorithms[0].AlgoId) == null, "Deleted algorithm doesn't equal to null");
            Assert.AreEqual(true, testResult, TestFail);
        }