예제 #1
0
 public UsersController(IUserProvider userProvider, IPortfolioProvider portfolioProvider, UserAdminMapper userMapper,
                        PortfolioAdminMapper portfolioMapper)
 {
     _userProvider      = userProvider;
     _portfolioProvider = portfolioProvider;
     _userMapper        = userMapper;
     _portfolioMapper   = portfolioMapper;
 }
예제 #2
0
            public PortfolioRule(Portfolio portfolio, IPortfolioProvider provider, Func <Portfolio, bool> changed)
                : base(portfolio)
            {
                _changed = changed ?? throw new ArgumentNullException(nameof(changed));

                _portfolio = portfolio ?? throw new ArgumentNullException(nameof(portfolio));
                _provider  = provider ?? throw new ArgumentNullException(nameof(provider));
                _provider.PortfolioChanged += OnPortfolioChanged;
            }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PortfolioDataSource"/>.
        /// </summary>
        /// <param name="provider">The portfolio provider interface.</param>
        public PortfolioDataSource(IPortfolioProvider provider)
            : base(new ObservableCollectionEx <Portfolio>())
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }

            AddRange(provider.Portfolios);

            _provider = provider;
            _provider.NewPortfolio += Add;
        }
예제 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BatchEmulation"/>.
        /// </summary>
        /// <param name="securityProvider">The provider of information about instruments.</param>
        /// <param name="portfolioProvider">The portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.</param>
        /// <param name="storageRegistry">Market data storage.</param>
        /// <param name="storageFormat">The format of market data. <see cref="StorageFormats.Binary"/> is used by default.</param>
        /// <param name="drive">The storage which is used by default. By default, <see cref="IStorageRegistry.DefaultDrive"/> is used.</param>
        public BatchEmulation(ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider, IStorageRegistry storageRegistry, StorageFormats storageFormat = StorageFormats.Binary, IMarketDataDrive drive = null)
        {
            _securityProvider  = securityProvider ?? throw new ArgumentNullException(nameof(securityProvider));
            _portfolioProvider = portfolioProvider ?? throw new ArgumentNullException(nameof(portfolioProvider));

            EmulationSettings = new EmulationSettings();

            StorageSettings = new StorageCoreSettings
            {
                StorageRegistry = storageRegistry,
                Drive           = drive,
                Format          = storageFormat,
            };
        }
 public PortfolioData(IPortfolioProvider provider, string portfolioTitle)
 {
     _dbProvider = provider;
     _portfolioTitles.Add(portfolioTitle);
 }
 public TradeAccountController(IPortfolioProvider portfolioProvider)
 {
     _portfolioProvider = portfolioProvider;
 }
예제 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HistoryEmulationConnector"/>.
 /// </summary>
 /// <param name="securityProvider">The provider of information about instruments.</param>
 /// <param name="portfolioProvider">The portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.</param>
 /// <param name="storageRegistry">Market data storage.</param>
 /// <param name="exchangeInfoProvider">Exchanges and trading boards provider.</param>
 public HistoryEmulationConnector(ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider, IExchangeInfoProvider exchangeInfoProvider, IStorageRegistry storageRegistry)
     : this(new HistoryMessageAdapter(new IncrementalIdGenerator(), securityProvider) { StorageRegistry = storageRegistry }, true, new InMemoryMessageChannel(new MessageByLocalTimeQueue(), "Emulator in", err => err.LogError()), securityProvider, portfolioProvider, exchangeInfoProvider)
 {
 }
예제 #8
0
        /// <summary>
        /// Initialize <see cref="EmulationMessageAdapter"/>.
        /// </summary>
        /// <param name="innerAdapter">Underlying adapter.</param>
        /// <param name="inChannel">Incoming messages channel.</param>
        /// <param name="isEmulationOnly">Send <see cref="TimeMessage"/> to emulator.</param>
        /// <param name="securityProvider">The provider of information about instruments.</param>
        /// <param name="portfolioProvider">The portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.</param>
        /// <param name="exchangeInfoProvider">Exchanges and trading boards provider.</param>
        public EmulationMessageAdapter(IMessageAdapter innerAdapter, IMessageChannel inChannel, bool isEmulationOnly, ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider, IExchangeInfoProvider exchangeInfoProvider)
            : base(innerAdapter)
        {
            Emulator = new MarketEmulator(securityProvider, portfolioProvider, exchangeInfoProvider, TransactionIdGenerator)
            {
                Parent   = this,
                Settings =
                {
                    ConvertTime    = true,
                    InitialOrderId = DateTime.Now.Ticks,
                    InitialTradeId = DateTime.Now.Ticks,
                }
            };

            InChannel = inChannel;

            _inAdapter = new SubscriptionOnlineMessageAdapter(Emulator);
            _inAdapter = new ChannelMessageAdapter(_inAdapter, inChannel, new PassThroughMessageChannel());
            _inAdapter.NewOutMessage += RaiseNewOutMessage;

            _isEmulationOnly = isEmulationOnly;
        }
예제 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RealTimeEmulationTrader{T}"/>.
        /// </summary>
        /// <param name="underlyngMarketDataAdapter"><see cref="IMessageAdapter"/>, through which market data will be got.</param>
        /// <param name="securityProvider">The provider of information about instruments.</param>
        /// <param name="portfolioProvider">The portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.</param>
        /// <param name="ownAdapter">Track the connection <paramref name="underlyngMarketDataAdapter" /> lifetime.</param>
        public RealTimeEmulationTrader(TUnderlyingMarketDataAdapter underlyngMarketDataAdapter, ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider, bool ownAdapter = true)
            : base(new EmulationMessageAdapter(underlyngMarketDataAdapter, new MessageByOrderQueue(), false) { OwnInnerAdapter = ownAdapter }, securityProvider, portfolioProvider)
        {
            UpdateSecurityByLevel1   = false;
            UpdateSecurityLastQuotes = false;

            UnderlyngMarketDataAdapter = underlyngMarketDataAdapter;

            Adapter.IgnoreExtraAdapters = true;
        }
예제 #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RealTimeEmulationTrader{T}"/>.
        /// </summary>
        /// <param name="underlyngMarketDataAdapter"><see cref="IMessageAdapter"/>, through which market data will be got.</param>
        /// <param name="securityProvider">The provider of information about instruments.</param>
        /// <param name="portfolioProvider">The portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.</param>
        /// <param name="ownAdapter">Track the connection <paramref name="underlyngMarketDataAdapter" /> lifetime.</param>
        public RealTimeEmulationTrader(TUnderlyingMarketDataAdapter underlyngMarketDataAdapter, ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider, bool ownAdapter = true)
            : base(new EmulationMessageAdapter(underlyngMarketDataAdapter, new InMemoryMessageChannel(new MessageByOrderQueue(), "Emulator In", err => err.LogError()), new InMemoryMessageChannel(new MessageByOrderQueue(), "Emulator Out", err => err.LogError())) { OwnInnerAdapter = ownAdapter }, securityProvider, portfolioProvider)
        {
            UpdateSecurityByLevel1   = false;
            UpdateSecurityLastQuotes = false;

            UnderlyngMarketDataAdapter = underlyngMarketDataAdapter;

            Adapter.IgnoreExtraAdapters = true;
        }
예제 #11
0
        /// <summary>
        /// To create a rule for the event of money increase in portfolio above the specific level.
        /// </summary>
        /// <param name="portfolio">The portfolio to be traced for the event of money increase above the specific level.</param>
        /// <param name="provider">The provider of information about portfolios.</param>
        /// <param name="money">The level. If the <see cref="Unit.Type"/> type equals to <see cref="UnitTypes.Limit"/>, specified price is set. Otherwise, shift value is specified.</param>
        /// <returns>Rule.</returns>
        public static MarketRule <Portfolio, Portfolio> WhenMoneyMore(this Portfolio portfolio, IPortfolioProvider provider, Unit money)
        {
            if (portfolio == null)
            {
                throw new ArgumentNullException(nameof(portfolio));
            }

            if (money == null)
            {
                throw new ArgumentNullException(nameof(money));
            }

            var finishMoney = money.Type == UnitTypes.Limit ? money : portfolio.CurrentValue + money;

            return(new PortfolioRule(portfolio, provider, pf => pf.CurrentValue > finishMoney)
            {
                Name = LocalizedStrings.Str1041Params.Put(portfolio, finishMoney)
            });
        }
예제 #12
0
        /// <summary>
        /// To create a rule for the event of change portfolio .
        /// </summary>
        /// <param name="portfolio">The portfolio to be traced for the event of change.</param>
        /// <param name="provider">The provider of information about portfolios.</param>
        /// <returns>Rule.</returns>
        public static MarketRule <Portfolio, Portfolio> WhenChanged(this Portfolio portfolio, IPortfolioProvider provider)
        {
            if (portfolio == null)
            {
                throw new ArgumentNullException(nameof(portfolio));
            }

            return(new PortfolioRule(portfolio, provider, pf => true)
            {
                Name = "Pf {0} change".Put(portfolio)
            });
        }
예제 #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StorageEntityFactory"/>.
 /// </summary>
 /// <param name="securityProvider">The provider of information about instruments.</param>
 /// <param name="portfolioProvider">The portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.</param>
 public StorageEntityFactory(ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider)
 {
     _securityProvider  = securityProvider ?? throw new ArgumentNullException(nameof(securityProvider));
     _portfolioProvider = portfolioProvider ?? throw new ArgumentNullException(nameof(portfolioProvider));
 }
예제 #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RealTimeEmulationTrader{T}"/>.
        /// </summary>
        /// <param name="underlyngMarketDataAdapter"><see cref="IMessageAdapter"/>, through which market data will be got.</param>
        /// <param name="securityProvider">The provider of information about instruments.</param>
        /// <param name="portfolioProvider">The portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.</param>
        /// <param name="ownAdapter">Track the connection <paramref name="underlyngMarketDataAdapter" /> lifetime.</param>
        public RealTimeEmulationTrader(TUnderlyingMarketDataAdapter underlyngMarketDataAdapter, ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider, bool ownAdapter = true)
        {
            UnderlyngMarketDataAdapter = underlyngMarketDataAdapter ?? throw new ArgumentNullException(nameof(underlyngMarketDataAdapter));

            UpdateSecurityByLevel1   = false;
            UpdateSecurityLastQuotes = false;

            EntityFactory = new EmulationEntityFactory(securityProvider ?? throw new ArgumentNullException(nameof(securityProvider)), portfolioProvider ?? throw new ArgumentNullException(nameof(portfolioProvider)));

            _ownAdapter = ownAdapter;

            var emuAdapter = new RealTimeEmulationAdapter(underlyngMarketDataAdapter)
            {
                OwnInnerAdapter = ownAdapter
            };

            Adapter.InnerAdapters.Add(emuAdapter);
            Adapter.ApplyHeartbeat(emuAdapter, ownAdapter);

            Adapter.IgnoreExtraAdapters = true;

            //if (_ownAdapter)
            //	UnderlyngMarketDataAdapter.Log += RaiseLog;
        }
예제 #15
0
 public PortfoliosController(PortfolioAdminMapper portfolioMapper, IPortfolioProvider portfolioProvider, IUserProvider userProvider)
 {
     _portfolioMapper   = portfolioMapper;
     _portfolioProvider = portfolioProvider;
     _userProvider      = userProvider;
 }
 public PortfolioData(IPortfolioProvider provider, List <string> portfolioTitles)
 {
     _dbProvider      = provider;
     _portfolioTitles = portfolioTitles;
 }
예제 #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InMemoryPositionStorage"/>.
 /// </summary>
 /// <param name="underlying">Underlying provider.</param>
 public InMemoryPositionStorage(IPortfolioProvider underlying)
 {
     _underlying = underlying ?? throw new ArgumentNullException(nameof(underlying));
 }
예제 #18
0
 public ProjectsController(IProjectProvider projectProvider, IPortfolioProvider portfolioProvider, ProjectAdminMapper projectMapper)
 {
     _projectProvider   = projectProvider;
     _portfolioProvider = portfolioProvider;
     _projectMapper     = projectMapper;
 }
예제 #19
0
 public PortfolioController(IPortfolioProvider portfolioProvider)
 {
     _portfolioProvider = portfolioProvider;
 }
예제 #20
0
 public void Setup()
 {
     _portfolioCostProvider = new JsonFilePortfolioCostProvider(@"..\..\TestData");
     _portfolioProvider     = new JsonFilePortfolioProvider(@"..\..\TestData");
 }
 public EmulationEntityFactory(IPortfolioProvider portfolioProvider)
 {
     _portfolioProvider = portfolioProvider ?? throw new ArgumentNullException(nameof(portfolioProvider));
 }
예제 #22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RealTimeEmulationTrader{T}"/>.
        /// </summary>
        /// <param name="underlyngMarketDataAdapter"><see cref="IMessageAdapter"/>, through which market data will be got.</param>
        /// <param name="securityProvider">The provider of information about instruments.</param>
        /// <param name="portfolioProvider">The portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.</param>
        /// <param name="ownAdapter">Track the connection <paramref name="underlyngMarketDataAdapter" /> lifetime.</param>
        /// <param name="exchangeInfoProvider">Exchanges and trading boards provider.</param>
        public RealTimeEmulationTrader(TUnderlyingMarketDataAdapter underlyngMarketDataAdapter, ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider, IExchangeInfoProvider exchangeInfoProvider, bool ownAdapter = true)
            : base(new EmulationMessageAdapter(underlyngMarketDataAdapter, new InMemoryMessageChannel(new MessageByOrderQueue(), "Emulator in", err => err.LogError()) { SuspendMaxCount = int.MaxValue }, false, securityProvider, portfolioProvider, exchangeInfoProvider) { OwnInnerAdapter = ownAdapter }, ownAdapter, true)
        {
            UpdateSecurityByLevel1   = false;
            UpdateSecurityLastQuotes = false;

            Adapter.IgnoreExtraAdapters = true;
        }
예제 #23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HistoryEmulationConnector"/>.
 /// </summary>
 /// <param name="securityProvider">The provider of information about instruments.</param>
 /// <param name="portfolioProvider">The portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.</param>
 /// <param name="exchangeInfoProvider">Exchanges and trading boards provider.</param>
 public HistoryEmulationConnector(ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider, IExchangeInfoProvider exchangeInfoProvider)
     : this(securityProvider, portfolioProvider, exchangeInfoProvider, new StorageRegistry(exchangeInfoProvider))
 {
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseEmulationConnector"/>.
        /// </summary>
        /// <param name="emulationAdapter">Emulation message adapter.</param>
        /// <param name="securityProvider">The provider of information about instruments.</param>
        /// <param name="portfolioProvider">The portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.</param>
        public BaseEmulationConnector(EmulationMessageAdapter emulationAdapter, ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider)
        {
            Adapter.InnerAdapters.Add(emulationAdapter ?? throw new ArgumentNullException(nameof(emulationAdapter)));
            Adapter.ApplyHeartbeat(EmulationAdapter, EmulationAdapter.OwnInnerAdapter);

            TimeChange = false;

            EntityFactory = new StorageEntityFactory(securityProvider ?? throw new ArgumentNullException(nameof(securityProvider)), portfolioProvider ?? throw new ArgumentNullException(nameof(portfolioProvider)));
        }
예제 #25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HistoryEmulationConnector"/>.
        /// </summary>
        /// <param name="innerAdapter">Underlying adapter.</param>
        /// <param name="ownInnerAdapter">Control <paramref name="innerAdapter"/> lifetime.</param>
        /// <param name="inChannel">Incoming messages channel.</param>
        /// <param name="securityProvider">The provider of information about instruments.</param>
        /// <param name="portfolioProvider">The portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.</param>
        /// <param name="exchangeInfoProvider">Exchanges and trading boards provider.</param>
        public HistoryEmulationConnector(IMessageAdapter innerAdapter, bool ownInnerAdapter, IMessageChannel inChannel, ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider, IExchangeInfoProvider exchangeInfoProvider)
            : base(new EmulationMessageAdapter(innerAdapter, inChannel, true, securityProvider, portfolioProvider, exchangeInfoProvider) { OwnInnerAdapter = ownInnerAdapter }, false, false)
        {
            MarketTimeChangedInterval = HistoryMessageAdapter.MarketTimeChangedInterval;

            Adapter.LatencyManager    = null;
            Adapter.CommissionManager = null;
            Adapter.PnLManager        = null;
            Adapter.SlippageManager   = null;

            Adapter.SupportSecurityAll = false;

            Adapter.SendFinishedCandlesImmediatelly = true;

            InMessageChannel  = new PassThroughMessageChannel();
            OutMessageChannel = new PassThroughMessageChannel();

            // при тестировании по свечкам, время меняется быстрее и таймаут должен быть больше 30с.
            //ReConnectionSettings.TimeOutInterval = TimeSpan.MaxValue;

            //MaxMessageCount = 1000;

            //Adapter.SupportCandlesCompression = false;
            Adapter.SupportBuildingFromOrderLog          = false;
            Adapter.SupportPartialDownload               = false;
            Adapter.SupportLookupTracking                = false;
            Adapter.SupportOrderBookTruncate             = false;
            Adapter.ConnectDisconnectEventOnFirstAdapter = false;

            MarketTimeChanged += OnMarketTimeChanged;
            Disconnected      += OnDisconnected;
        }
예제 #26
0
 public AboutMeController(IUserProvider userProvider, IPortfolioProvider portfolioProvider, AboutMeMapper aboutMeMapper)
 {
     _userProvider      = userProvider;
     _portfolioProvider = portfolioProvider;
     _aboutMeMapper     = aboutMeMapper;
 }