/// <summary> /// Initializes a new instance of the <see cref="BacktestDaemonState"/> class. /// </summary> /// <param name="algoService">The algorithm service.</param> /// <param name="allocationManager">The allocation manager.</param> /// <param name="exchangeFactory">The exchange factory service.</param> public BacktestDaemonState(AlgorithmService algoService, IAllocationManager allocationManager, ExchangeFactoryService exchangeFactory) { Guard.Argument(algoService).NotNull(); AlgorithmService = algoService; AllocationManager = allocationManager; ExchangeFactory = exchangeFactory; }
/// <summary> /// Initializes a new instance of the <see cref="DatabaseEventListenerService"/> class. /// </summary> /// <param name="factory">To create output.</param> /// <param name="allocation">To listen for portfolio changes.</param> /// <param name="database">To log events to.</param> public DatabaseEventListenerService(ILoggerFactory factory, IAllocationManager allocation, DatabaseContext database) { _sources = new List <IDisposable>(); _logger = factory.CreateLogger(GetType()); _allocation = allocation; lock (Lock) { _database = database; } }
/// <summary> /// Initializes a new instance of the <see cref="ExchangeFactoryService"/> class. /// </summary> /// <param name="loggerFactory">Provides logging.</param> /// <param name="context">Injected database context.</param> /// <param name="alloc">Injected AllocationManager service.</param> /// <param name="binanceComm">Injected binance communication service.</param> public ExchangeFactoryService( ILoggerFactory loggerFactory, DatabaseContext context, IAllocationManager alloc, BinanceCommunicationsService binanceComm) { _logger = loggerFactory.CreateLogger <ExchangeFactoryService>(); _loggerFactory = loggerFactory; _databaseContext = context; _binanceCommunications = binanceComm; _allocationManager = alloc; }
public void Dispose() { if (!isDisposed && isOpened) { Flush(); } isDisposed = true; DirectoryCache?.Dispose(); storage.Dispose(); DirectoryCache = null; allocationManager = null; storage = null; }
/// <summary> /// Initializes a new instance of the <see cref="TradingProvider"/> class. /// </summary> /// <param name="loggerFactory">Used to create output.</param> /// <param name="implementation">The implementation to delegate calls to.</param> /// <param name="dataProvider">The data provider to manager certain orders with.</param> /// <param name="allocationManager">The allocation manager to verify orders.</param> public TradingProvider( ILoggerFactory loggerFactory, AbstractTradingProvider implementation, DataProvider dataProvider, IAllocationManager allocationManager) { _logger = loggerFactory.CreateLogger(GetType()); Implementation = implementation; _allocationManager = allocationManager; _dataProvider = dataProvider; _openOrders = new Dictionary <long, OrderUpdate>(); Implementation.Subscribe(new ConfigurableObserver <OrderUpdate>( () => { }, _ => { }, HandleOrderUpdate)); }
private void InitializeFromHeader(IBlockStorage blockStorage, FSHeader header) { var allocationIndexFactory = new GenericFactory <IIndex <int>, IAllocationManager>( m => { var accessParameters = new CommonAccessParameters(blockStorage, m); var allocationIndexProvider = indexBlockProviderFactory.Create(header.AllocationBlock, accessParameters); return(indexFactory.Create(allocationIndexProvider, accessParameters)); }); allocationManager = allocationManagerFactory.Create(allocationIndexFactory, blockStorage, header.FreeBlockCount); var dictionaryCache = directoryCacheFactory.Create(new CommonAccessParameters(blockStorage, allocationManager)); var rootDirectory = dictionaryCache.ReadDirectory(header.RootDirectoryBlock); RootDirectory = rootDirectory; DirectoryCache = dictionaryCache; }
/// <summary> /// Initializes a new instance of the <see cref="AlgorithmService"/> class. /// </summary> /// <param name="loggerFactory">Provides logging capabilities.</param> /// <param name="allocationManager">Set allocations on startup.</param> /// <param name="exchangeFactoryService">Provides containers for algorithms.</param> public AlgorithmService( ILoggerFactory loggerFactory, IAllocationManager allocationManager, ExchangeFactoryService exchangeFactoryService) { _logger = loggerFactory.CreateLogger <AlgorithmService>(); _exchangeFactoryService = exchangeFactoryService; if (Program.CommandLineArgs.Trading) { // Sets initial configuration try { allocationManager.SetInitialConfiguration(Configuration.Instance.EnabledAlgorithm.Allocation); } catch (AllocationUnavailableException) { Program.ExitProgramWithCode(ExitCode.AllocationUnavailable); } } }
public CommonAccessParameters(IBlockStorage storage, IAllocationManager allocationManager) { Storage = storage ?? throw new ArgumentNullException(nameof(storage)); AllocationManager = allocationManager ?? throw new ArgumentNullException(nameof(allocationManager)); }
/// <summary> /// Initializes a new instance of the <see cref="BacktestDaemonService"/> class. /// </summary> /// <param name="algoService">The algorithm service.</param> /// <param name="allocationManager">The allocation manager.</param> /// <param name="exchangeFactoryService">The exchange factory service.</param> public BacktestDaemonService(AlgorithmService algoService, IAllocationManager allocationManager, ExchangeFactoryService exchangeFactoryService) { State = new BacktestDaemonState(algoService, allocationManager, exchangeFactoryService); }