Example #1
0
        public void TestResize()
        {
            var arr = new IdArray <double>(10);

            Assert.Equal(arr.Size, 10);
            //Assert.Throws(() => arr[15] = 20.0);
        }
Example #2
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>();
		}
Example #3
0
        public override List <ExecutionMessage> Load(string series = null)
        {
            var idMap      = new IdArray <string>();
            var subSideMap = new IdArray <SubSide>();

            var reports = _reports.FindAll().ToList();

            foreach (var report in reports)
            {
                idMap[report.OrderId]      = report.ProviderOrderId;
                subSideMap[report.OrderId] = report.SubSide;
            }
            var orders     = _orders.FindAll().ToList();
            var maxLocalId = string.Empty;

            foreach (var order in orders)
            {
                order.ProviderOrderId = idMap[order.OrderId];
                SetSubSide(order, subSideMap[order.OrderId]);
                maxLocalId = DealProcessor.GetOrderId(order);
            }
            Settings.Set(ProviderSettingsType.MaxLocalId, maxLocalId);
            var list = new List <ExecutionMessage>();

            list.AddRange(orders);
            list.AddRange(reports);
            return(list);
        }
 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 #5
0
        public static T GetOrCreate <T>(this IdArray <T> array, int id, int size = 1024) where T : class, new()
        {
            var o = array[id];

            if (o == null)
            {
                array[id] = o = new T();
            }
            return(o);
        }
Example #6
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 #7
0
 public override void Open()
 {
     if (!this.opened)
     {
         this.dataFile.Open(FileMode.OpenOrCreate);
         this.byType = new IdArray<DataSeries>[128];
         for (int i = 0; i < this.byType.Length; i++)
             this.byType[i] = new IdArray<DataSeries>();
         this.opened = true;
     }
 }
Example #8
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 #9
0
		public double this[byte index]
		{
			get
			{
				return this.fields[(int)index];
			}
			set
			{
				if (this.fields == null)
				{
					this.fields = new IdArray<double>(10);
				}
				this.fields[(int)index] = value;
			}
		}
        public ActionResult GetUserFailedWordsDeleted([FromBody] IdArray ids)
        {
            if (ids.Ids.Length == 0)
            {
                return(StatusCode(400));
            }

            var items      = _unitOfWork.UserFailedWords.GetAll().Where(x => x.UserId == UserHelper.GetCurrentUserId(User)).Select(x => x.Id);
            var deletedIds = ids.Ids.Except(items);
            var obj        = new
            {
                extras = deletedIds
            };

            return(Ok(obj));
        }
        public ActionResult GetSekaniWordsDeleted([FromBody] IdArray ids)
        {
            if (ids.Ids.Length == 0)
            {
                return(StatusCode(400));
            }

            var items      = _unitOfWork.SekaniWords.GetAll().Select(x => x.Id);
            var deletedIds = ids.Ids.Except(items);
            var obj        = new
            {
                extras = deletedIds
            };

            return(Ok(obj));
        }
Example #12
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 #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 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 #15
0
		public BarFactory(Framework framework)
		{
			this.framework = framework;
			this.itemLists = new IdArray<List<BarFactoryItem>>(1000);
			this.reminderTable = new SortedList<DateTime, SortedList<long, List<BarFactoryItem>>>();
		}
Example #16
0
 private TickSeries GetOrCreateTickSeriesFor(IdArray<TickSeries> array, int instrumentId) => array[instrumentId] = array[instrumentId] ?? new TickSeries("", "");
Example #17
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 #18
0
 private TickSeries GetOrCreateTickSeriesFor(IdArray <TickSeries> array, int instrumentId) => array[instrumentId] = array[instrumentId] ?? new TickSeries("", "");
Example #19
0
		private Instrument()
		{
			this.legs = new List<Leg>();
			this.fields = new IdArray<double>(10);
		}
Example #20
0
        internal void OpenWrite()
        {
            lock (Sync)
            {
                if (this.writeOpened)
                {
                    Console.WriteLine("DataSeries::OpenWrite already write open");
                    return;
                }
                this.cache = this.cache ?? ReadCache();

                if (this.bufferCount != 0 && this.cache[this.bufferCount - 1] != null)
                {
                    this.writeKey = this.cache[this.bufferCount - 1];
                    this.writeKey.GetObjects();
                }
                else
                {
                    if (this.position2 != -1)
                    {
                        this.writeKey = ReadKey(this.position2);
                        this.writeKey.number = this.bufferCount - 1;
                        this.writeKey.GetObjects();
                    }
                    else
                    {
                        this.writeKey = new DataKey(this.file)
                        {
                            number = 0,
                            changed = true
                        };
                        this.bufferCount = 1;
                    }
                    this.cache[this.writeKey.number] = this.writeKey;
                }
                if (this.cacheKey.position != -1)
                    this.file.DeleteKey(this.cacheKey, false, false);

                this.cachePosition = -1;
                this.file.WriteKey(this.key);
                this.writeOpened = true;
            }
        }
Example #21
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 #22
0
 internal void OpenRead()
 {
     lock (Sync)
     {
         if (this.readOpened)
         {
             Console.WriteLine("DataSeries::OpenRead already read open");
             return;
         }
         this.cache = this.cache ?? ReadCache();
         this.readOpened = true;                
     }
 }
Example #23
0
        internal void Init(DataFile file, ObjectKey key)
        {
            lock (Sync)
            {
                this.file = file;
                this.key = key;
                key.CompressionLevel = 0;
                key.CompressionMethod = 0;

                // Init dataKey list
                if (this.cachePosition == -1)
                {
                    this.cache = new IdArray<DataKey>(Math.Max(4096, this.bufferCount));
                    this.cacheKey = new ObjectKey(file, "", new DataKeyIdArray(this.cache));
                }
            }
        }
Example #24
0
		internal DataKeyIdArray(IdArray<DataKey> keys)
		{
			this.keys = keys;
		}
Example #25
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 #26
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 #27
0
 private void ProcessReturnOrder(OrderField field)
 {
     _provider.Logger.Info(field.DebugInfo);
     _orderHandlers[(byte)field.ExecType](field);
 }
Example #28
0
 public void Clear()
 {
     lock (Sync)
     {
         this.cache = this.cache ?? ReadCache();
         if (this.position1 != -1)
         {
             var key = ReadKey(this.position1);
             while (true)
             {
                 this.file.DeleteKey(key, false, true);
                 if (key.next == -1)
                     break;
                 key = ReadKey(key.next);
             }
         }
         Count = 0;
         this.bufferCount = 0;
         DateTime1 = new DateTime(0);
         DateTime2 = new DateTime(0);
         this.position1 = -1;
         this.position2 = -1;
         this.readOpened = false;
         this.writeOpened = 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;
         Flush();
     }
 }
 public QBCommissionProvider()
 {
     InstrumentCommissions = new IdArray <InstrumentCommission>();
     ProductCommissions    = new Dictionary <string, InstrumentCommission>();
 }
Example #30
0
 public void TestResize()
 {
     var arr = new IdArray<double>(10);
     Assert.Equal(arr.Size, 10);
     //Assert.Throws(() => arr[15] = 20.0);
 }