Example #1
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>();
 }
 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>();
 }
Example #3
0
 public void CopyTo(IdArray <T> array)
 {
     array.Clear();
     for (int i = 0; i < this.size; ++i)
     {
         array[i] = this[i];
     }
 }
Example #4
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);
 }
Example #5
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);
 }
Example #6
0
 private void ReadCache()
 {
     this.cacheKey = this.file.ReadKey(this.cachePosition, 38);
     this.cache    = ((DataKeyIdArray)this.cacheKey.GetObject()).keys;
     for (int i = 0; i < this.cache.Size; i++)
     {
         if (this.cache[i] != null)
         {
             this.cache[i].file   = this.file;
             this.cache[i].number = i;
         }
     }
 }
Example #7
0
 public double this[byte index]
 {
     get
     {
         return(this.fields[index]);
     }
     set
     {
         if (this.fields == null)
         {
             this.fields = new IdArray <double>(16);
         }
         this.fields[index] = value;
     }
 }
Example #8
0
 public MatchingEngine(Framework framework) : base(framework)
 {
     this.id                  = 101;
     this.name                = "MatchingEngine";
     this.fillOnQuote         = true;
     this.fillOnTrade         = false;
     this.fillOnBar           = false;
     this.fillOnLevel2        = false;
     this.fillMarketOnNext    = false;
     this.fillLimitOnNext     = false;
     this.fillStopOnNext      = false;
     this.fillStopLimitOnNext = false;
     this.fillAtLimitPrice    = true;
     this.addQueueToOrderText = false;
     this.orders              = new IdArray <List <Order> >(1000);
 }
Example #9
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);
 }
Example #10
0
        public override void Write(BinaryWriter writer, object obj)
        {
            DataKeyIdArray    dataKeyIdArray = (DataKeyIdArray)obj;
            IdArray <DataKey> keys           = dataKeyIdArray.keys;

            writer.Write(0);
            writer.Write(keys.Size);
            for (int i = 0; i < keys.Size; i++)
            {
                if (keys[i] != null)
                {
                    writer.Write(i);
                    keys[i].WriteKey(writer);
                }
            }
            writer.Write(-1);
        }
Example #11
0
        public override object Read(BinaryReader reader)
        {
            reader.ReadByte();
            int size = reader.ReadInt32();
            IdArray <DataKey> idArray = new IdArray <DataKey>(size);

            while (true)
            {
                int num = reader.ReadInt32();
                if (num == -1)
                {
                    break;
                }
                DataKey dataKey = new DataKey(null, null, -1L, -1L);
                dataKey.Read(reader, true);
                idArray.Add(num, dataKey);
            }
            return(new DataKeyIdArray(idArray));
        }
Example #12
0
 internal void Init(DataFile file, ObjectKey key)
 {
     this.file             = file;
     this.key              = key;
     key.compressionLevel  = 0;
     key.compressionMethod = 0;
     if (this.cachePosition == -1L)
     {
         if (this.buffer_count < 4096)
         {
             this.cache = new IdArray <DataKey>(4096);
         }
         else
         {
             this.cache = new IdArray <DataKey>(this.buffer_count);
         }
         this.cacheKey = new ObjectKey(file, "", new DataKeyIdArray(this.cache));
     }
 }
Example #13
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);
 }
Example #14
0
 public void Clear()
 {
     if (this.cache == null)
     {
         this.ReadCache();
     }
     if (this.position1 != -1L)
     {
         DataKey dataKey = this.ReadKey(this.position1);
         while (true)
         {
             this.file.DeleteKey(dataKey, false);
             if (dataKey.next == -1L)
             {
                 break;
             }
             dataKey = this.ReadKey(dataKey.next);
         }
     }
     this.count        = 0L;
     this.buffer_count = 0;
     this.dateTime1    = new DateTime(0L);
     this.dateTime2    = new DateTime(0L);
     this.position1    = -1L;
     this.position2    = -1L;
     this.isOpenRead   = false;
     this.isOpenWrite  = false;
     this.cache        = new IdArray <DataKey>(4096);
     this.cacheKey.obj = new DataKeyIdArray(this.cache);
     this.readKey      = null;
     this.writeKey     = null;
     this.deleteKey    = null;
     this.insertKey    = null;
     this.changed      = true;
     this.Flush();
 }
Example #15
0
 public StrategyList()
 {
     this.strategies   = new List <Strategy>();
     this.strategyById = new IdArray <Strategy>(1000);
 }
Example #16
0
 private Instrument()
 {
     this.legs   = new List <Leg>();
     this.fields = new IdArray <double>(10);
 }
Example #17
0
 internal DataKeyIdArray(IdArray <DataKey> keys)
 {
     this.keys = keys;
 }
Example #18
0
 public BarFactory(Framework framework)
 {
     this.framework     = framework;
     this.itemLists     = new IdArray <List <BarFactoryItem> >(1000);
     this.reminderTable = new SortedList <DateTime, SortedList <long, List <BarFactoryItem> > >();
 }