public void Setup()
        {
            _orderBookManager                = new();
            _settingsMock                    = new();
            _walletManager                   = new();
            _tradingService                  = new();
            _instrumentDictionaryMock        = new();
            _assetDictionary                 = new AssetsDictionaryMock();
            _externalBalanceCacheManagerMock = new ExternalBalanceCacheManagerMock();

            _loggerFactory =
                LoggerFactory.Create(builder =>
                                     builder.AddSimpleConsole(options =>
            {
                options.IncludeScopes   = true;
                options.SingleLine      = true;
                options.TimestampFormat = "hh:mm:ss ";
            }));

            _engine = new AggregateLiquidityProvider(
                _loggerFactory.CreateLogger <AggregateLiquidityProvider>(),
                new OrderIdGenerator(),
                _orderBookManager,
                _settingsMock,
                _walletManager,
                _tradingService,
                _instrumentDictionaryMock,
                _assetDictionary,
                _externalBalanceCacheManagerMock
                );
        }
Exemple #2
0
        public void Setup()
        {
            _loggerFactory =
                LoggerFactory.Create(builder =>
                                     builder.AddSimpleConsole(options =>
            {
                options.IncludeScopes   = true;
                options.SingleLine      = true;
                options.TimestampFormat = "hh:mm:ss ";
            }));

            _positioPortfolioManager         = new PortfolioManagerMock();
            _hedgeSettings                   = new HedgeSettingsManagerMock();
            _externalMarketManager           = new ExternalMarketManagerMock();
            _walletManager                   = new LpWalletManagerMock();
            _settingsMock                    = new();
            _orderBookManager                = new OrderBookManagerMock();
            _externalBalanceCacheManagerMock = new ExternalBalanceCacheManagerMock();


            _service = new HedgeService(
                _loggerFactory.CreateLogger <HedgeService>(),
                _positioPortfolioManager,
                _hedgeSettings,
                _externalMarketManager,
                _walletManager,
                _settingsMock,
                _orderBookManager,
                _externalBalanceCacheManagerMock
                );


            _hedgeSettings.GlobalSettings.Mode = EngineMode.Active;


            _settingsMock.MmSettings.Mode = EngineMode.Disabled;
            _settingsMock.MmSettings.UseExternalBalancePercentage = 100;

            _settingsMock.LpSettings.Add(new LiquidityProviderInstrumentSettings()
            {
                Mode         = EngineMode.Active,
                ModeHedge    = EngineMode.Active,
                LpWalletName = "NAME",
                Symbol       = "BTCUSD",
                LpSources    = new List <LpSourceSettings>(),
                LpHedges     = new List <LpHedgeSettings>()
                {
                    new LpHedgeSettings()
                    {
                        Mode           = EngineMode.Active,
                        ExternalMarket = "FTX",
                        ExternalSymbol = "BTC/USD",
                        MinVolume      = 0.01
                    }
                },
                WalletId = "LP-Wallet",
                BrokerId = "broker"
            });

            _externalMarketManager.Prices["BTC/USD"]     = 10000;
            _externalMarketManager.Trades["FTX"]         = new List <ExchangeTrade>();
            _externalMarketManager.MarketInfo["BTC/USD"] = new ExchangeMarketInfo()
            {
                Market         = "BTC/USD",
                BaseAsset      = "BTC",
                QuoteAsset     = "USD",
                MinVolume      = 0.01,
                VolumeAccuracy = 4,
                PriceAccuracy  = 2
            };

            _walletManager.Wallets["NAME"] = new LpWallet()
            {
                WalletId = "LP-Wallet",
                BrokerId = "broker",
                ClientId = "client",
                Name     = "NAME"
            };

            _externalBalanceCacheManagerMock.Balances["FTX"]        = new Dictionary <string, ExchangeBalance>();
            _externalBalanceCacheManagerMock.Balances["FTX"]["BTC"] = new ExchangeBalance()
            {
                Symbol  = "BTC",
                Balance = 10,
                Free    = 10
            };
            _externalBalanceCacheManagerMock.Balances["FTX"]["USD"] = new ExchangeBalance()
            {
                Symbol  = "USD",
                Balance = 1000000,
                Free    = 1000000
            };

            _externalBalanceCacheManagerMock.Markets["FTX"]            = new Dictionary <string, ExchangeMarketInfo>();
            _externalBalanceCacheManagerMock.Markets["FTX"]["BTC/USD"] = new ExchangeMarketInfo()
            {
                Market         = "BTC/USD",
                BaseAsset      = "BTC",
                QuoteAsset     = "USD",
                MinVolume      = 0,
                PriceAccuracy  = 0,
                VolumeAccuracy = 4
            };

            _orderBookManager.Data[("BTC/USD", "FTX")] = new LeOrderBook