public Leg(Instrument instrument, double weight = 1.0) { this.instrument = instrument; Weight = weight; InstrumentId = instrument.Id; this.framework = instrument.Framework; }
public EventPipe(Framework framework, bool threaded = false) { this.framework = framework; Threaded = threaded; if (threaded) throw new NotSupportedException(); }
public PortfolioManager(Framework framework, PortfolioServer portfolioServer) { this.framework = framework; Server = portfolioServer; Server?.Open(); Pricer = new Pricer(framework); }
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"; }
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}"); }
public OrderManager(Framework framework, OrderServer orderServer) { this.framework = framework; Server = orderServer; Server?.Open(); this.counter = 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(); }
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); }
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; }
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); }
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(); }
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); } }
public MyStrategy(Framework framework, string name) : base(framework, name) { }
public BarFactory(Framework framework) { this.framework = framework; }
public Backtest(Framework framework) : base(framework) { }
public FrameworkEventArgs(Framework framework) { Framework = framework; }
public GroupManager(Framework framework) { this.framework = framework; }
public InstrumentServer(Framework framework) { this.framework = framework; }
public OnFrameworkCleared(Framework framework) { Framework = framework; }
public UserServer(Framework framework) { this.framework = framework; }
public Realtime(Framework framework) : base(framework) { // Set bar size in seconds. 60 seconds is 1 minute. barSize = 60; }
public StrategyManager(Framework framework) { this.framework = framework; Clear(); }
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(); } }
public EventFilter(Framework framework) { this.framework = framework; }
public SubscriptionManager(Framework framework) { this.framework = framework; }
internal AccountDataManager(Framework framework) { this.framework = framework; }
public SpreadSellSide(Framework framework, string name) : base(framework, name) { }
public RiskManager(Framework framework) { this.framework = framework; }
public InstrumentStrategy(Framework framework, string name) : base(framework, name) { this.raiseEvents = false; }
public MatchingEngine(Framework framework) : base(framework) { this.id = ProviderId.MatchingEngine; this.name = "MatchingEngine"; }
public DataServer(Framework framework) { this.framework = framework; this.tapeMode = false; }
public PerformanceStrategy(Framework framework) : base(framework, "PerformanceStrategy") { }
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; }
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); }
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); }
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); }
public Realtime(Framework framework) : base(framework) { }
public SellSideInstrumentStrategy(Framework framework, string name): base(framework, name) { IsInstance = false; }
public UserManager(Framework framework, UserServer server) { this.framework = framework; this.server = server; }
public PerformanceProvider(Framework framework) : base(framework) { }
public InstrumentManager(Framework framework, InstrumentServer server) { this.framework = framework; Server = server; }