Ejemplo n.º 1
0
 /// <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;
 }
Ejemplo n.º 2
0
 /// <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;
     }
 }
Ejemplo n.º 3
0
 /// <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;
 }
Ejemplo n.º 4
0
        public void Dispose()
        {
            if (!isDisposed && isOpened)
            {
                Flush();
            }

            isDisposed = true;

            DirectoryCache?.Dispose();
            storage.Dispose();

            DirectoryCache    = null;
            allocationManager = null;
            storage           = null;
        }
Ejemplo n.º 5
0
 /// <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));
 }
Ejemplo n.º 6
0
        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;
        }
Ejemplo n.º 7
0
        /// <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);
                }
            }
        }
Ejemplo n.º 8
0
 public CommonAccessParameters(IBlockStorage storage, IAllocationManager allocationManager)
 {
     Storage           = storage ?? throw new ArgumentNullException(nameof(storage));
     AllocationManager = allocationManager ?? throw new ArgumentNullException(nameof(allocationManager));
 }
Ejemplo n.º 9
0
 /// <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);
 }