public BacktestInstrumentServer(Framework framework, string path, bool save, bool useFileName)
     : base(framework)
 {
     Path = path;
     Save = save;
     UseFileName = useFileName;
 }
示例#2
0
 public OrderManager(Framework framework)
 {
     this.framework = framework;
     this.orders = new List<Order>();
     this.oCAGroups = new Dictionary<string, List<Order>>();
     this.next_id = 0;
 }
示例#3
0
 public ProviderManager(Framework framework, IDataSimulator dataSimulator = null, IExecutionSimulator executionSimulator = null)
 {
     this.framework = framework;
     this.providers = new ProviderList();
     this.settings = new ProviderManagerSettings();
     this.LoadSettings();
     if (dataSimulator == null)
     {
         this.dataSimulator = new DataSimulator(framework);
     }
     else
     {
         this.dataSimulator = dataSimulator;
     }
     this.AddProvider(this.dataSimulator);
     if (executionSimulator == null)
     {
         this.executionSimulator = new ExecutionSimulator(framework);
     }
     else
     {
         this.executionSimulator = executionSimulator;
     }
     this.AddProvider(this.executionSimulator);
 }
示例#4
0
		public MetaStrategy(Framework framework, string name) : base(framework, name)
		{
			this.strategiesByInstrument = new IdArray<List<Strategy>>(1000);
			this.strategyById = new IdArray<Strategy>(1000);
			this.strategyByPortfolioId = new IdArray<Strategy>(1000);
			this.strategies = new List<Strategy>();
		}
示例#5
0
 public void Init(Framework framework, ControlSettings settings, object[] args)
 {
     this.framework = framework;
     this.settings = settings;
     this.args = args;
     OnInit();
 }
示例#6
0
        public MainForm()
        {
            InitComponent();
            var f = new Framework("Demo", true);
            f.IsDisposable = false;
            f.GroupDispatcher = new GroupDispatcher(f);
            this.barChart.Init(f, null, null);
            this.barChart2.Init(f, null, null);
            this.barChart.ResumeUpdates();
            this.barChart2.ResumeUpdates();

            this.timer = new System.Windows.Forms.Timer();
            this.timer.Interval = 500;
            this.timer.Tick += new EventHandler((sender, e) =>
            {
                try
                {
                    this.timer.Stop();
                    barChart.UpdateGUI();
                    barChart2.UpdateGUI();
                    this.timer.Interval = 500;
                    this.timer.Enabled = true;
                }
                catch (Exception)
                {
                }
            });
            this.timer.Start();
        }
示例#7
0
文件: TTFIX.cs 项目: javagg/Junction
 public TTFIX(Framework framework)
     : base(framework, (QuickFIXApplication)new TTFIXApplication ())
 {
     this.id = 10;
     this.name = "TT FIX";
     this.description = "Trading Technologies FIX Adapter";
     this.url = "www.tradingtechnologies.com";
 }
示例#8
0
		public EventBus(Framework framework, EventBusMode mode = EventBusMode.Realtime)
		{
			this.framework = framework;
			this.mode = mode;
			this.dataPipe = new EventPipe(framework, true);
			this.executionPipe = new EventPipe(framework, false);
			this.servicePipe = new EventPipe(framework, false);
		}
示例#9
0
		public FileInstrumentServer(Framework framework, string fileName, string host = null) : base(framework)
		{
			if (host == null)
			{
				this.file = new DataFile(fileName, framework.streamerManager);
				return;
			}
			this.file = new NetDataFile(fileName, host, framework.streamerManager);
		}
 public SellSideInstrumentStrategy(Framework framework, string name)
     : base(framework, name)
 {
     this.raiseEvents = false;
     this.strategyByInstrument = new IdArray<List<SellSideInstrumentStrategy>>(1000);
     this.strategyByPortfolio = new IdArray<SellSideInstrumentStrategy>(1000);
     this.strategyBySynthInstrument = new IdArray<SellSideInstrumentStrategy>(1000);
     this.strategies = new List<Strategy>();
 }
示例#11
0
		public DataSimulator(Framework framework) : base(framework)
		{
			this.id = 1;
			this.name = "DataSimulator";
			this.description = "Default data simulator";
			this.url = "www.smartquant.com";
			this.dateTime1 = DateTime.MinValue;
			this.dateTime2 = DateTime.MaxValue;
		}
示例#12
0
 public OrderMap(Framework framework, SingleProvider provider)
     : base(framework, provider)
 {
     externalOrders = new ConcurrentDictionary<string, ExternalOrderRecord>();
     pendingOrders = new ConcurrentDictionary<string, OrderRecord>();
     workingOrders = new Dictionary<string, OrderRecord>();
     orderIDs = new Dictionary<int, string>();
     pendingCancels = new ConcurrentDictionary<string, OrderRecord>();
 }
示例#13
0
		public DataManager(Framework framework, DataServer server)
		{
			this.framework = framework;
			this.server = server;
			if (server != null)
			{
				server.Open();
			}
		}
示例#14
0
		public GroupDispatcher(Framework framework)
		{
			this.framework = framework;
			this.listeners = new List<IGroupListener>();
			this.listenerTable = new IdArray<List<IGroupListener>>(1000);
			this.groupByListenerTable = new Dictionary<IGroupListener, List<int>>();
			framework.eventManager.Dispatcher.NewGroup += new GroupEventHandler(this.Dispatcher_NewGroup);
			framework.eventManager.Dispatcher.NewGroupEvent += new GroupEventEventHandler(this.Dispatcher_NewGroupEvent);
			framework.eventManager.Dispatcher.NewGroupUpdate += new GroupUpdateEventHandler(this.Dispatcher_NewGroupUpdate);
			framework.EventManager.Dispatcher.FrameworkCleared += new FrameworkEventHandler(this.Dispatcher_FrameworkCleared);
		}
示例#15
0
		public EventDispatcher(Framework framework)
		{
			this.framework = framework;
			if (this.queue != null)
			{
				this.thread = new Thread(new ThreadStart(this.ThreadRun));
				this.thread.IsBackground = true;
				this.thread.Name = "Event Dispatcher Thread";
				this.thread.Start();
			}
		}
示例#16
0
        public MainForm()
        {
            InitComponent();
            SuspendLayout();
 
            this.orderManager = new SmartQuant.Controls.Orders.OrderManagerWindow();
            this.orderManager.Dock = DockStyle.Fill;
            this.orderManager.Name = "OrderManager";


            TabPage tpage = null;
            tpage = new TabPage();
            tpage.Controls.Add(this.orderManager);
            tpage.Name = this.orderManager.Name;
            tpage.Text = this.orderManager.Name;
            this.tabControl1.Controls.Add(tpage);


            ResumeLayout();

            var f = new Framework("Demo");
            f.IsDisposable = false;
            f.GroupDispatcher = new GroupDispatcher(f);
            this.dataLoader = new DataLoader(f);

            this.barChart.Init(f, null, null);
            this.barChart.ResumeUpdates();

            this.barChart2.Init(f, null, null);
            this.barChart2.ResumeUpdates();

            this.orderManager.Init(this.dataLoader.OrderManagerQueue, true);

            this.timer = new System.Windows.Forms.Timer();
            this.timer.Interval = 500;
            this.timer.Tick += (sender, e) =>
            {
                try
                {
                    this.timer.Stop();
                    this.barChart.UpdateGUI();
                    this.barChart2.UpdateGUI();
                    this.orderManager.UpdateGUI();

                    this.timer.Interval = 500;
                    this.timer.Enabled = true;
                }
                catch (Exception)
                {
                }
            };
            this.timer.Start();
        }
示例#17
0
 public Portfolio(Framework framework, string name = "")
 {
     this.framework = framework;
     this.name = name;
     this.account = new Account(framework);
     this.fills = new FillSeries(name);
     this.positions = new List<Position>();
     this.positionByInstrument = new IdArray<Position>(1000);
     this.pricer = framework.portfolioManager.pricer;
     this.performance = new PortfolioPerformance(this);
     this.statistics = new PortfolioStatistics(this);
 }
示例#18
0
        public MLProvider(Framework framework)
            : base(framework)
        {
            // 不能与已有的重复
            base.id = 55;

            base.name = "MenuLoader";
            base.description = "QuantBox Menu Loader";
            base.url = "www.quantbox.cn";

            _menuPath = Path.Combine(Installation.ConfigDir.FullName, "menu.json");

            menuLoader.LoadConfig(_menuPath);
            menuLoader.LoadOnce();
        }
        public ProviderHost(Framework framework)
            : base(framework)
        {
            Init(100, "API Host");

            ConfigPath = Path.Combine(Installation.ConfigDir.FullName, "API_Host.json");
            ProviderList = new BindingList<ProviderItem>();

            Load(ConfigPath);
            if (ProviderList == null)
                ProviderList = new BindingList<ProviderItem>();

            string applicationDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            Create(ProviderList);

            ProviderList.ListChanged += ProviderList_ListChanged;
        }
示例#20
0
		public InstrumentManager(Framework framework, InstrumentServer server)
		{
			this.framework = framework;
			this.server = server;
			this.server.Open();
			this.next_id = -1;
			this.instruments = server.Load();
			for (int i = 0; i < this.instruments.Count; i++)
			{
				this.instruments.GetByIndex(i).isPersistent = true;
				int id = this.instruments.GetByIndex(i).Id;
				if (id > this.next_id)
				{
					this.next_id = id;
				}
			}
			this.next_id++;
		}
示例#21
0
        public MainWindow()
            : base(WindowType.Toplevel)
        {
            this.barChart = new SmartQuant.Controls.BarChart.BarChart();
            this.barChart2 = new SmartQuant.Controls.BarChart.BarChart2();
            this.chart3 = new SmartQuant.FinChart.Chart();
            this.chart3.ActionType = ChartActionType.Cross;
            var nb = new Notebook();
            nb.Add(barChart);
            nb.SetTabLabelText(barChart, "Chart");
            nb.Add(barChart2);
            nb.SetTabLabelText(barChart2, "Chart(Gapless)");
            nb.Add(chart3);
            nb.SetTabLabelText(chart3, "Performance");
            Add(nb);
            SetDefaultSize(624, 362);

            DeleteEvent += (sender, e) =>
            {
                Application.Quit();
                e.RetVal = true;
            };

            var f = new Framework("Demo", true);
            f.IsDisposable = false;
            f.GroupDispatcher = new GroupDispatcher(f);
            this.barChart.Init(f, null, null);
            this.barChart2.Init(f, null, null);
            this.barChart.ResumeUpdates();
            this.barChart2.ResumeUpdates();

            GLib.Timeout.Add(500, new TimeoutHandler(delegate
            {
                barChart.UpdateGUI();
                barChart2.UpdateGUI();
                return true;
            }));

            // Until the framework is created, We cannot show them
            ShowAll();
        }
示例#22
0
 public Strategy(Framework framework, string name)
 {
     this.framework = framework;
     this.Name = name;
     this.strategiesByInstrument = new IdArray<LinkedList<Strategy>>(1000);
     this.strategyByOrderId = new IdArray<Strategy>(1000);
     this.strategies = new LinkedList<Strategy>();
     this.status = StrategyStatus.Stopped;
     this.instruments = new InstrumentList();
     this.instrumentCountTable = new IdArray<int>(1000);
     if (framework != null)
     {
         this.portfolio = new Portfolio(framework, this.Name);
         framework.PortfolioManager.Add(this.portfolio);
     }
     this.bars = new BarSeries("", "");
     this.equity = new TimeSeries();
     this.bids = new TickSeries("");
     this.asks = new TickSeries("");
     this.stops = new List<Stop>();
     this.stopsByInstrument = new IdArray<List<Stop>>(1000);
 }
示例#23
0
文件: Pricer.cs 项目: ForTrade/CSharp
 public Pricer(Framework framework)
 {
     this.framework = framework;
 }
示例#24
0
		public CurrencyConverter(Framework framework)
		{
			this.framework = framework;
		}
示例#25
0
文件: Pricer.cs 项目: ForTrade/CSharp
 public Pricer(Framework framework)
 {
     this.framework = framework;
 }
示例#26
0
 public Provider(Framework framework)
 {
     this.framework = framework;
 }
示例#27
0
 public FrameworkEventArgs(Framework framework)
 {
     this.Framework = framework;
 }
示例#28
0
		public DataImport(Framework framework)
		{
			this.framework = framework;
		}
示例#29
0
 public SellSideStrategy(Framework framework, string name) : base(framework, name)
 {
 }
示例#30
0
 public Scenario(Framework framework)
 {
     this.framework = framework;
 }
示例#31
0
		public ExecutionSimulator(Framework framework) : base(framework)
		{
			this.id = 2;
			this.name = "ExecutionSimulator";
			this.description = "Default execution simulator";
			this.url = "www.smartquant.com";
			this.fillOnQuote = true;
			this.fillOnTrade = true;
			this.fillOnBar = false;
			this.fillMarketOnNext = false;
			this.fillLimitOnNext = false;
			this.fillStopOnNext = false;
			this.fillStopLimitOnNext = false;
			this.fillAtLimitPrice = true;
			this.orders = new IdArray<List<Order>>(1000);
		}
示例#32
0
 public DataFilter(Framework framework)
 {
     this.framework = framework;
 }
示例#33
0
 public PerformanceStrategy(Framework framework) : base(framework, "PerformanceStrategy")
 {
 }
示例#34
0
 public DataServer(Framework framework)
 {
     this.framework = framework;
     this.tapeMode  = false;
 }
示例#35
0
 public PortfolioManager(Framework framework)
 {
     this.framework = framework;
     this.pricer    = new Pricer(framework);
 }
示例#36
0
 public Clock(Framework framework, ClockMode mode = ClockMode.Simulation, bool isStandalone = false)
 {
     this.Mode = mode;
     throw new System.NotImplementedException();
 }
示例#37
0
		public Framework(string name = "", bool createServers = true)
		{
			this.name = name;
			this.LoadConfiguration();
			this.eventBus = new EventBus(this, EventBusMode.Realtime);
			this.clock = new Clock(this, ClockMode.Realtime, false);
			this.eventBus.reminderQueue = this.clock.reminderQueue;
			this.eventServer = new EventServer(this, this.eventBus);
			this.eventManager = new EventManager(this, this.eventBus);
			this.streamerManager = new StreamerManager();
			this.streamerManager.Add(new DataObjectStreamer());
			this.streamerManager.Add(new InstrumentStreamer());
			this.streamerManager.Add(new BidStreamer());
			this.streamerManager.Add(new AskStreamer());
			this.streamerManager.Add(new QuoteStreamer());
			this.streamerManager.Add(new TradeStreamer());
			this.streamerManager.Add(new BarStreamer());
			this.streamerManager.Add(new Level2SnapshotStreamer());
			this.streamerManager.Add(new Level2UpdateStreamer());
			this.streamerManager.Add(new NewsStreamer());
			this.streamerManager.Add(new FundamentalStreamer());
			this.streamerManager.Add(new DataSeriesStreamer());
			if (createServers)
			{
				if (this.configuration.IsInstrumentFileLocal)
				{
					this.instrumentServer = new FileInstrumentServer(this, this.configuration.InstrumentFileName, null);
				}
				else
				{
					this.instrumentServer = new FileInstrumentServer(this, "instruments.quant", this.configuration.InstrumentFileHost);
				}
				this.instrumentManager = new InstrumentManager(this, this.InstrumentServer);
				if (this.configuration.IsDataFileLocal)
				{
					this.dataServer = new FileDataServer(this, this.configuration.DataFileName, null);
				}
				else
				{
					this.dataServer = new FileDataServer(this, "data.quant", this.configuration.DataFileHost);
				}
				this.dataManager = new DataManager(this, this.dataServer);
			}
			this.providerManager = new ProviderManager(this, null, new ExecutionSimulator(this));
			this.eventLoggerManager = new EventLoggerManager();
			this.subscriptionManager = new SubscriptionManager(this);
			this.orderManager = new OrderManager(this);
			this.portfolioManager = new PortfolioManager(this);
			this.strategyManager = new StrategyManager(this);
			this.groupManager = new GroupManager(this);
			this.accountDataManager = new AccountDataManager(this);
			this.currencyConverter = new CurrencyConverter(this);
			this.dataFileManager = new DataFileManager(Installation.DataDir.FullName);
			if (Framework.currentFramework == null)
			{
				Framework.currentFramework = this;
			}
		}
示例#38
0
		public Framework(string name, EventBus externalBus, InstrumentServer instrumentServer, DataServer dataServer = null)
		{
			this.isExternalDataQueue = true;
			this.name = name;
			this.LoadConfiguration();
			this.clock = new Clock(this, ClockMode.Realtime, false);
			this.eventBus = new EventBus(this, EventBusMode.Realtime);
			this.eventBus.reminderQueue = this.clock.reminderQueue;
			externalBus.Attach(this.eventBus);
			this.eventServer = new EventServer(this, this.eventBus);
			this.eventManager = new EventManager(this, this.eventBus);
			this.streamerManager = new StreamerManager();
			this.streamerManager.Add(new DataObjectStreamer());
			this.streamerManager.Add(new InstrumentStreamer());
			this.streamerManager.Add(new BidStreamer());
			this.streamerManager.Add(new AskStreamer());
			this.streamerManager.Add(new QuoteStreamer());
			this.streamerManager.Add(new TradeStreamer());
			this.streamerManager.Add(new BarStreamer());
			this.streamerManager.Add(new Level2SnapshotStreamer());
			this.streamerManager.Add(new Level2UpdateStreamer());
			this.streamerManager.Add(new NewsStreamer());
			this.streamerManager.Add(new FundamentalStreamer());
			this.streamerManager.Add(new DataSeriesStreamer());
			this.instrumentServer = instrumentServer;
			this.instrumentManager = new InstrumentManager(this, instrumentServer);
			this.dataServer = dataServer;
			this.dataManager = new DataManager(this, dataServer);
			this.providerManager = new ProviderManager(this, null, new ExecutionSimulator(this));
			this.eventLoggerManager = new EventLoggerManager();
			this.orderManager = new OrderManager(this);
			this.portfolioManager = new PortfolioManager(this);
			this.strategyManager = new StrategyManager(this);
			this.groupManager = new GroupManager(this);
			this.currencyConverter = new CurrencyConverter(this);
			this.dataFileManager = new DataFileManager(Installation.DataDir.FullName);
			if (Framework.currentFramework == null)
			{
				Framework.currentFramework = this;
			}
		}
示例#39
0
		public EventManager(Framework framework, EventBus bus)
		{
			this.framework = framework;
			this.bus = bus;
			this.factory = new BarFactory(framework);
			this.dispatcher = new EventDispatcher(framework);
			this.handler[107] = new EventManager.OnEventHandler(this.OnSimulatorStart);
			this.handler[108] = new EventManager.OnEventHandler(this.OnSimulatorStop);
			this.handler[109] = new EventManager.OnEventHandler(this.OnSimulatorProgress);
			this.handler[2] = new EventManager.OnEventHandler(this.OnBid);
			this.handler[3] = new EventManager.OnEventHandler(this.OnAsk);
			this.handler[4] = new EventManager.OnEventHandler(this.OnTrade);
			this.handler[6] = new EventManager.OnEventHandler(this.OnBar);
			this.handler[8] = new EventManager.OnEventHandler(this.OnLevel2Snapshot);
			this.handler[9] = new EventManager.OnEventHandler(this.OnLevel2Update);
			this.handler[23] = new EventManager.OnEventHandler(this.OnNews);
			this.handler[22] = new EventManager.OnEventHandler(this.OnFundamental);
			this.handler[13] = new EventManager.OnEventHandler(this.OnExecutionReport);
			this.handler[116] = new EventManager.OnEventHandler(this.OnOrderStatusChanged);
			this.handler[117] = new EventManager.OnEventHandler(this.OnOrderPartiallyFilled);
			this.handler[118] = new EventManager.OnEventHandler(this.OnOrderFilled);
			this.handler[119] = new EventManager.OnEventHandler(this.OnOrderReplaced);
			this.handler[120] = new EventManager.OnEventHandler(this.OnOrderCancelled);
			this.handler[121] = new EventManager.OnEventHandler(this.OnOrderDone);
			this.handler[113] = new EventManager.OnEventHandler(this.OnFill);
			this.handler[110] = new EventManager.OnEventHandler(this.OnPositionOpened);
			this.handler[111] = new EventManager.OnEventHandler(this.OnPositionClosed);
			this.handler[112] = new EventManager.OnEventHandler(this.OnPositionChanged);
			this.handler[15] = new EventManager.OnEventHandler(this.OnReminder);
			this.handler[50] = new EventManager.OnEventHandler(this.OnGroup);
			this.handler[52] = new EventManager.OnEventHandler(this.OnGroupEvent);
			this.handler[130] = new EventManager.OnEventHandler(this.OnHistoricalData);
			this.handler[131] = new EventManager.OnEventHandler(this.OnHistoricalDataEnd);
			this.handler[140] = new EventManager.OnEventHandler(this.OnAccountData);
			if (bus != null)
			{
				this.thread = new Thread(new ThreadStart(this.ThreadRun));
				this.thread.Name = "Event Manager Thread";
				this.thread.IsBackground = true;
				this.thread.Start();
			}
		}
 public SubscriptionManager(Framework framework)
 {
     this.framework     = framework;
     this.subscriptions = new Dictionary <int, Dictionary <Instrument, int> >();
 }