[Quantproject-developers] QuantProject/b4_Business/a1_Financial/a2_Accounting/AccountProviding IAc
Brought to you by:
glauco_1
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/AccountProviding In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv32742 Added Files: IAccountProvider.cs InteractiveBrokerAccountProvider.cs SimpleAccountProvider.cs Log Message: Added: - IAccountProvider interface; - InteractiveBrokerAccountProvider; -SimpleAccountProvider --- NEW FILE: IAccountProvider.cs --- /* QuantProject - Quantitative Finance Library IAccountProvider.cs Copyright (C) 2008 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.Business.DataProviders; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Strategies.Logging; using QuantProject.Business.Timing; namespace QuantProject.Business.Financial.Accounting.AccountProviding { /// <summary> /// Interface to be implemented by objects /// that provide a new account through the /// GetAccount method. /// These objects are used at the moment /// by the EndOfDaysStrategyBackTester /// </summary> public interface IAccountProvider : ILogDescriptor { /// <summary> /// Returns a new account /// </summary> /// <param name="instrumentKey">instrument identifier</param> /// <param name="endOfDayDateTime">end of day date time for the market evaluation</param> /// <returns></returns> Account GetAccount( IEndOfDayTimer timer , IHistoricalQuoteProvider historicalQuoteProvider ); } } --- NEW FILE: InteractiveBrokerAccountProvider.cs --- /* QuantProject - Quantitative Finance Library InteractiveBrokerAccountProvider.cs Copyright (C) 2008 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.ADT; using QuantProject.Business.DataProviders; using QuantProject.Business.Financial.Accounting.Commissions; using QuantProject.Business.Financial.Accounting.Slippage; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Timing; namespace QuantProject.Business.Financial.Accounting.AccountProviding { /// <summary> /// IAccountProvider object that provides a typical account /// with Interactive Broker for individual traders, /// where commissions are managed and slippage can be simulated /// through a fixed percentage amount (on stock-price) /// lost at each stock-transaction /// </summary> public class InteractiveBrokerAccountProvider : IAccountProvider { private double slippageFixedPercentage; public InteractiveBrokerAccountProvider() { this.slippageFixedPercentage = 0.0; } public InteractiveBrokerAccountProvider(double slippageFixedPercentage) { if( slippageFixedPercentage < 0.0 || slippageFixedPercentage > 100.0 ) throw new OutOfRangeException(slippageFixedPercentage, 0.0, 100.0); this.slippageFixedPercentage = slippageFixedPercentage; } private ISlippageManager getAccount_getSlippageManager(IEndOfDayTimer timer , IHistoricalQuoteProvider historicalQuoteProvider) { ISlippageManager slippageManager; if(this.slippageFixedPercentage == 0.0) slippageManager = new ZeroSlippageManager(); else//this.slippageFixedPercentage > 0.0 slippageManager = new FixedPercentageSlippageManager( historicalQuoteProvider , timer , this.slippageFixedPercentage ); return slippageManager; } public Account GetAccount( IEndOfDayTimer timer , IHistoricalQuoteProvider historicalQuoteProvider ) { Account account = new Account( "IBAccount" , timer , new HistoricalEndOfDayDataStreamer( timer , historicalQuoteProvider ) , new HistoricalEndOfDayOrderExecutor( timer , historicalQuoteProvider , this.getAccount_getSlippageManager( timer , historicalQuoteProvider ) ), new IBCommissionManager() ); return account; } public string Description { get { string description = "IBAccountForIndividualTraders"; return description; } } } } --- NEW FILE: SimpleAccountProvider.cs --- /* QuantProject - Quantitative Finance Library SimpleAccountProvider.cs Copyright (C) 2008 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.Business.DataProviders; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Timing; namespace QuantProject.Business.Financial.Accounting.AccountProviding { /// <summary> /// IAccountProvider object that provides an account /// with no commissions and slippage /// on orders /// </summary> public class SimpleAccountProvider : IAccountProvider { public SimpleAccountProvider() { } public Account GetAccount( IEndOfDayTimer timer , IHistoricalQuoteProvider historicalQuoteProvider ) { Account account = new Account( "SimpleAccount" , timer , new HistoricalEndOfDayDataStreamer( timer , historicalQuoteProvider ) , new HistoricalEndOfDayOrderExecutor( timer , historicalQuoteProvider ) ); return account; } public string Description { get { string description = "SimpleAccount_NoComm_NoSlippage"; return description; } } } } |