Наследование: IDisposable
Пример #1
0
 public Leg(Instrument instrument, double weight = 1.0)
 {
     this.instrument = instrument;
     Weight = weight;
     InstrumentId = instrument.Id;
     this.framework = instrument.Framework;
 }
Пример #2
0
 public EventPipe(Framework framework, bool threaded = false)
 {
     this.framework = framework;
     Threaded = threaded;
     if (threaded)
         throw new NotSupportedException();
 }
Пример #3
0
 public PortfolioManager(Framework framework, PortfolioServer portfolioServer)
 {
     this.framework = framework;
     Server = portfolioServer;
     Server?.Open();
     Pricer = new Pricer(framework);
 }
Пример #4
0
 public DataSimulator(Framework framework) : base(framework)
 {
     this.id = ProviderId.DataSimulator;
     this.name = "DataSimulator";
     this.description = "Default data simulator";
     this.url = $"www.{nameof(FastQuant).ToLower()}.com";
 }
Пример #5
0
 internal void Init(Framework framework)
 {
     this.framework = framework;
     this.instrument = framework.InstrumentManager.GetById(InstrumentId);
     if (this.instrument == null)
         Console.WriteLine($"{nameof(Leg)}::{nameof(Init)} Can not find leg instrument in the framework instrument manager. Id = {InstrumentId}");
 }
Пример #6
0
 public OrderManager(Framework framework, OrderServer orderServer)
 {
     this.framework = framework;
     Server = orderServer;
     Server?.Open();
     this.counter = 0;
 }
Пример #7
0
 public DataManager(Framework framework, DataServer server)
 {
     this.framework = framework;
     Server = server;
     Server?.Open();
     this.thread = new Thread(ThreadRun) { Name = "Data Manager Thread", IsBackground = true };
     this.thread.Start();
 }
Пример #8
0
 public ProviderManager(Framework framework, IDataSimulator dataSimulator = null, IExecutionSimulator executionSimulator = null)
 {
     this.framework = framework;
     this.dataSimulator = dataSimulator ?? new DataSimulator(framework);
     AddProvider(this.dataSimulator);
     this.executionSimulator = executionSimulator ?? new ExecutionSimulator(framework);
     AddProvider(this.executionSimulator);
 }
Пример #9
0
 public GroupDispatcher(Framework framework)
 {
     this.framework = framework;
     this.framework.EventManager.Dispatcher.NewGroup += OnNewGroup;
     this.framework.EventManager.Dispatcher.NewGroupEvent += OnNewGroupEvent;
     this.framework.EventManager.Dispatcher.NewGroupUpdate += OnNewGroupUpdate;
     this.framework.EventManager.Dispatcher.FrameworkCleared += OnFrameworkCleared;
 }
Пример #10
0
 public EventBus(Framework framework)
 {
     this.framework = framework;
     Mode = framework.Mode == FrameworkMode.Realtime ? EventBusMode.Realtime : EventBusMode.Simulation;
     CommandPipe = new EventPipe(framework, false);
     DataPipe = new EventPipe(framework, false);
     ExecutionPipe = new EventPipe(framework, false);
     ServicePipe = new EventPipe(framework, false);
     HistoricalPipe = new EventPipe(framework, false);
 }
Пример #11
0
 public Controller(Framework framework, string name)
 {
     this.framework = framework;
     this.name = name;
     //this.tcpClient = new TcpClient(this.host, this.port);
     this.tcpClient = new TcpClient(AddressFamily.InterNetwork);
     this.stream = this.tcpClient.GetStream();
     this.reader = new BinaryReader(this.stream);
     this.writer = new BinaryWriter(this.stream);
     this.thread = new Thread(Run) { IsBackground = true };
     this.thread.Start();
 }
Пример #12
0
 public StatisticsManager(Framework framework)
 {
     this.framework = framework;
     var types = typeof(PortfolioStatisticsType).GetFields(BindingFlags.Public | BindingFlags.Static)
         .Select(f => f.Name)
         .Except(new[] { "DailyDownsideRisk", "AnnualDownsideRisk" })
         .Concat(new[] { "DailyReturnPercentDownsideRisk", "AnnualReturnPercentDownsideRisk" });
     foreach (var t in types)
     {
         var type = Type.GetType($"{nameof(FastQuant)}.Statistics.{t}");
         var item = (PortfolioStatisticsItem)Activator.CreateInstance(type);
         Add(item);
     }
 }
Пример #13
0
 public MyStrategy(Framework framework, string name)
     : base(framework, name)
 {
 }
Пример #14
0
 public BarFactory(Framework framework)
 {
     this.framework = framework;
 }
Пример #15
0
 public Backtest(Framework framework)
     : base(framework)
 {
 }
Пример #16
0
 public FrameworkEventArgs(Framework framework)
 {
     Framework = framework;
 }
Пример #17
0
 public GroupManager(Framework framework)
 {
     this.framework = framework;
 }
 public InstrumentServer(Framework framework)
 {
     this.framework = framework;
 }
Пример #19
0
 public OnFrameworkCleared(Framework framework)
 {
     Framework = framework;
 }
Пример #20
0
 public UserServer(Framework framework)
 {
     this.framework = framework;
 }
Пример #21
0
 public Realtime(Framework framework)
     : base(framework)
 {
     // Set bar size in seconds. 60 seconds is 1 minute.
     barSize = 60;
 }
Пример #22
0
 public StrategyManager(Framework framework)
 {
     this.framework = framework;
     Clear();
 }
Пример #23
0
        public EventManager(Framework framework, EventBus bus)
        {
            this.framework  = framework;
            this.bus        = bus;
            BarFactory      = new BarFactory(this.framework);
            BarSliceFactory = new BarSliceFactory(this.framework);
            Dispatcher      = new EventDispatcher(this.framework);

            // Event Gates
            this.gates[EventType.Bid]                      = OnBid;
            this.gates[EventType.Ask]                      = OnAsk;
            this.gates[EventType.Trade]                    = OnTrade;
            this.gates[EventType.Quote]                    = OnQuote;
            this.gates[EventType.Bar]                      = OnBar;
            this.gates[EventType.Level2Snapshot]           = OnLevel2Snapshot;
            this.gates[EventType.Level2Update]             = OnLevel2Update;
            this.gates[EventType.ExecutionReport]          = OnExecutionReport;
            this.gates[EventType.Reminder]                 = OnReminder;
            this.gates[EventType.Fundamental]              = OnFundamental;
            this.gates[EventType.News]                     = OnNews;
            this.gates[EventType.Group]                    = OnGroup;
            this.gates[EventType.GroupEvent]               = OnGroupEvent;
            this.gates[EventType.Command]                  = OnCommand;
            this.gates[EventType.OnPositionOpened]         = OnPositionOpened;
            this.gates[EventType.OnPositionClosed]         = OnPositionClosed;
            this.gates[EventType.OnPositionChanged]        = OnPositionChanged;
            this.gates[EventType.OnFill]                   = OnFill;
            this.gates[EventType.OnTransaction]            = OnTransaction;
            this.gates[EventType.OnSendOrder]              = OnSendOrder;
            this.gates[EventType.OnPendingNewOrder]        = OnPendingNewOrder;
            this.gates[EventType.OnNewOrder]               = OnNewOrder;
            this.gates[EventType.OnOrderStatusChanged]     = OnOrderStatusChanged;
            this.gates[EventType.OnOrderPartiallyFilled]   = OnOrderPartiallyFilled;
            this.gates[EventType.OnOrderFilled]            = OnOrderFilled;
            this.gates[EventType.OnOrderReplaced]          = OnOrderReplaced;
            this.gates[EventType.OnOrderCancelled]         = OnOrderCancelled;
            this.gates[EventType.OnOrderRejected]          = OnOrderRejected;
            this.gates[EventType.OnOrderExpired]           = OnOrderExpired;
            this.gates[EventType.OnOrderCancelRejected]    = OnOrderCancelRejected;
            this.gates[EventType.OnOrderReplaceRejected]   = OnOrderReplaceRejected;
            this.gates[EventType.OnOrderDone]              = OnOrderDone;
            this.gates[EventType.OnPortfolioAdded]         = OnPortfolioAdded;
            this.gates[EventType.OnPortfolioRemoved]       = OnPortfolioRemoved;
            this.gates[EventType.OnPortfolioParentChanged] = OnPortfolioParentChanged;
            this.gates[EventType.HistoricalData]           = OnHistoricalData;
            this.gates[EventType.HistoricalDataEnd]        = OnHistoricalDataEnd;
            this.gates[EventType.BarSlice]                 = OnBarSlice;
            this.gates[EventType.OnStrategyEvent]          = OnStrategyEvent;
            this.gates[EventType.AccountData]              = OnAccountData;
            this.gates[EventType.OnPropertyChanged]        = OnPropertyChanged;
            this.gates[EventType.OnException]              = OnException;
            this.gates[EventType.AccountReport]            = OnAccountReport;
            this.gates[EventType.ProviderError]            = OnProviderError;
            this.gates[EventType.OnProviderConnected]      = OnProviderConnected;
            this.gates[EventType.OnProviderDisconnected]   = OnProviderDisconnected;
            this.gates[EventType.OnSimulatorStart]         = OnSimulatorStart;
            this.gates[EventType.OnSimulatorStop]          = OnSimulatorStop;
            this.gates[EventType.OnSimulatorProgress]      = OnSimulatorProgress;

            // Enable all events by defaults
            for (int i = 0; i < byte.MaxValue; i++)
            {
                Enabled[i] = true;
            }

            if (bus != null)
            {
                this.thread = new Thread(Run)
                {
                    Name         = "Event Manager Thread",
                    IsBackground = true
                };
                this.thread.Start();
            }
        }
Пример #24
0
 public EventFilter(Framework framework)
 {
     this.framework = framework;
 }
Пример #25
0
 public SubscriptionManager(Framework framework)
 {
     this.framework = framework;
 }
Пример #26
0
 internal AccountDataManager(Framework framework)
 {
     this.framework = framework;
 }
Пример #27
0
 public SpreadSellSide(Framework framework, string name)
     : base(framework, name)
 {
 }
Пример #28
0
 public RiskManager(Framework framework)
 {
     this.framework = framework;
 }
Пример #29
0
 public InstrumentStrategy(Framework framework, string name) : base(framework, name)
 {
     this.raiseEvents = false;
 }
Пример #30
0
 public FrameworkEventArgs(Framework framework)
 {
     Framework = framework;
 }
Пример #31
0
 public MatchingEngine(Framework framework) : base(framework)
 {
     this.id = ProviderId.MatchingEngine;
     this.name = "MatchingEngine";
 }
Пример #32
0
 public DataServer(Framework framework)
 {
     this.framework = framework;
     this.tapeMode  = false;
 }
Пример #33
0
 public GroupManager(Framework framework)
 {
     this.framework = framework;
 }
Пример #34
0
 public PerformanceStrategy(Framework framework) : base(framework, "PerformanceStrategy")
 {
 }
Пример #35
0
        private Framework(string name, FrameworkMode mode, bool createServers, EventBus externalBus, InstrumentServer instrumentServer, DataServer dataServer, string fileServerPath)
        {
            Name = name;
            this.mode = mode;
            LoadConfiguration();

            // Setup events compoents setup
            EventBus = new EventBus(this);
            OutputManager = new OutputManager(this, Configuration.IsOutputLogEnabled ? Configuration.OutputLogFileName : null);
            Clock = new Clock(this, ClockType.Local, false);
            EventBus.LocalClockEventQueue = Clock.ReminderQueue;
            ExchangeClock = new Clock(this, ClockType.Exchange, false);
            EventBus.ExchangeClockEventQueue = ExchangeClock.ReminderQueue;
            externalBus?.Attach(EventBus);
            EventServer = new EventServer(this, EventBus);
            EventManager = new EventManager(this, EventBus);

            // Setup streamers
            StreamerManager = new StreamerManager();
            StreamerManager.AddDefaultStreamers();

            // Create Servers
            var iServer = instrumentServer ?? new FileInstrumentServer(this, Configuration.InstrumentFileName);
            var dServer = dataServer ?? new FileDataServer(this, Configuration.DataFileName);
            var oServer = new FileOrderServer(this, Configuration.OrderFileName);
            var pServer = new FilePortfolioServer(this, Configuration.PortfolioFileName);

            InstrumentManager = new InstrumentManager(this, iServer);
            InstrumentServer = iServer;
            InstrumentManager.Load();
            DataManager = new DataManager(this, dServer);
            DataServer = dServer;
            OrderManager = new OrderManager(this, oServer);
            OrderServer = oServer;
            PortfolioManager = new PortfolioManager(this, pServer);
            PortfolioServer = pServer;
            UserServer = new XmlUserServer(this);
            UserManager = new UserManager(this, UserServer);
            UserManager.Load();

            // Create Providers
            ProviderManager = new ProviderManager(this);

            // Other stuff
            EventLoggerManager = new EventLoggerManager();
            SubscriptionManager = new SubscriptionManager(this);
            ScenarioManager = new ScenarioManager(this);
            StrategyManager = new StrategyManager(this);
            StatisticsManager = new StatisticsManager(this);
            GroupManager = new GroupManager(this);
            AccountDataManager = new AccountDataManager(this);
            LicenseManager = new LicenseManager();
            CurrencyConverter = new CurrencyConverter(this);
            DataFileManager = new DataFileManager(Installation.DataDir.FullName);

            instance = instance ?? this;
        }
Пример #36
0
 public MatchingEngine(Framework framework) : base(framework)
 {
     this.id   = ProviderId.MatchingEngine;
     this.name = "MatchingEngine";
 }
Пример #37
0
 public RiskManager(Framework framework)
 {
     this.framework = framework;
 }
Пример #38
0
 public OutputManager(Framework framework, string path = null)
 {
     Framework = framework;
     this.textWriter = Console.Out;
     if (path != null)
     {
         path = path.Replace("%d", DateTime.Now.ToString("ddMMyyHHmmss"));
         path = path.Replace("%n", framework.Name);
         try
         {
             this.streamWriter = File.CreateText(path);
             this.streamWriter.AutoFlush = true;
         }
         catch (Exception)
         {
             Console.WriteLine($"OutputManager::OutputManager Error. Can not open output log file {path}");
             this.streamWriter = null;
         }
     }
     this.outputWriter = new OutputWriter(this);
     Console.SetOut(this.outputWriter);
 }
Пример #39
0
 public FilePortfolioServer(Framework framework, string fileName, string host = null, int port = -1) : base(framework)
 {
     this.host = host;
     this.port = port;
     this.dataFile= host == null? new DataFile(fileName, framework.StreamerManager): new NetDataFile(fileName, host, port, framework.StreamerManager);
 }
Пример #40
0
 public static Instrument GetInstrument(DataSeries series, Framework framework)
 {
     var parts = series.Name.Split(new[] { '.' }, StringSplitOptions.None);
     var id = GetDataType(series) == DataObjectType.Bar ? int.Parse(parts[parts.Length - 4]) : int.Parse(parts[parts.Length - 2]);
     return framework.InstrumentManager.GetById(id);
 }
Пример #41
0
 public Realtime(Framework framework)
     : base(framework)
 {
 }
Пример #42
0
 public BarFactory(Framework framework)
 {
     this.framework = framework;
 }
Пример #43
0
 public SellSideInstrumentStrategy(Framework framework, string name): base(framework, name)
 {
     IsInstance = false;
 }
Пример #44
0
 public UserManager(Framework framework, UserServer server)
 {
     this.framework = framework;
     this.server    = server;
 }
Пример #45
0
 public PerformanceProvider(Framework framework) : base(framework)
 {
 }
 public InstrumentManager(Framework framework, InstrumentServer server)
 {
     this.framework = framework;
     Server         = server;
 }