Example #1
0
        public static void Initialize()
        {
            if (!Directory.Exists(DestinationPath))
            {
                Directory.CreateDirectory(DestinationPath);
                foreach (string newPath in Directory.GetFiles(SourcePath, "*.json*",
                                                              SearchOption.TopDirectoryOnly))
                {
                    File.Copy(newPath, newPath.Replace(SourcePath, DestinationPath), true);
                }
            }


            _mmRest = MarketMakerRestServiceFactory.CreateMakerRestService(_url, "/oauth/token",
                                                                           _authorization);
            _mmRest.Authorize("admin", "admin");
            _wsFactory = new SubscriptionFactory(_subscribeUrl, _mmRest.Token);

            _testEvent = new TestEventHandler();

            // Initializing algorithms for testing.
            _testEvent.Algorithms = new List <AlgorithmInfo>()
            {
                new AlgorithmInfo("instrument.json", "pricer.json", "hedger.json", "risklimit.json"),
                new AlgorithmInfo("instrument2.json", "pricer2.json", "hedger.json", "risklimit2.json")
            };
        }
Example #2
0
 public static void ConnectToCrypto()
 {
     _restCrypto = MarketMakerRestServiceFactory.CreateMakerRestService(_cryptoUrl, "/oauth/token",
                                                                        _cryptoAuthorization);
     _restCrypto.Authorize("Tester 1", "password");
     _wsCrypto = new TraderSubscription(_cryptoTraderSubscribeUrl, _restCrypto.Token);
     _wsCrypto.ResponsesSubscribe();
 }
Example #3
0
        public static void ConnectToCrypto()
        {
            _testEvent = new TestEventHandler();
            string authorization = "Basic d2ViOg==";
            string urlCrypto     = "http://18.218.20.9";

            _restCrypto = MarketMakerRestServiceFactory.CreateMakerRestService(urlCrypto, "/oauth/token",
                                                                               authorization);
            _restCrypto.Authorize("Tester 1", "password");
            _wsCrypto = new TraderSubscription("ws://18.218.20.9/websocket/v1?trader_0", _restCrypto.Token);
            _wsCrypto.ResponsesSubscribe();
        }
Example #4
0
 public void StopDeleteAll(IMarketMakerRestService service)
 {
     if (AlgoId == -1 || !IsDelete)
     {
         return;
     }
     if (HedgerConfigInfo.Running)
     {
         service.StopHedger(AlgoId);
         Thread.Sleep(500);
     }
     if (PricerConfigInfo.Running)
     {
         service.StopPricer(AlgoId);
         Thread.Sleep(500);
     }
     if (InstrumentConfigInfo.Running)
     {
         service.StopInstrument(AlgoId);
         Thread.Sleep(500);
     }
     service.DeleteAlgorithm(AlgoId);
 }
Example #5
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());
            }
        }