Ejemplo n.º 1
0
        public static void ReceiveMaterial(ICswResources CswResources, CswNbtReceivingDefinitionReturn Response, CswNbtReceivingDefinition ReceivingDefiniton)
        {
            CswNbtResources    NbtResources = (CswNbtResources)CswResources;
            CswNbtActReceiving ActReceiving = new CswNbtActReceiving(NbtResources, ReceivingDefiniton.MaterialNodeId);
            JObject            ActionData   = ActReceiving.receiveMaterial(ReceivingDefiniton);

            Response.Data.ActionData = ActionData.ToString();


            //Create Print Job
            if (null != ReceivingDefiniton.PrintLabelId && null != ReceivingDefiniton.PrinterNodeId)
            {
                CswNbtObjClassContainer InitialContainer = NbtResources.Nodes.GetNode(ReceivingDefiniton.ContainerNodeId);

                Collection <Dictionary <string, string> > PropVals = new Collection <Dictionary <string, string> >();
                foreach (CswNbtAmountsGridQuantity Quant in ReceivingDefiniton.Quantities)
                {
                    CswNbtObjClassUnitOfMeasure UoMNode = NbtResources.Nodes.GetNode(Quant.UnitNodeId);
                    for (int i = 0; i < Quant.NumContainers; i++)
                    {
                        Dictionary <string, string> vals = InitialContainer.Node.getPropertiesAndValues();
                        vals[InitialContainer.Barcode.PropName]  = Quant.getBarcodes()[i];
                        vals[InitialContainer.Quantity.PropName] = Quant.Quantity + " " + UoMNode.BaseUnit.Text;
                        PropVals.Add(vals);
                    }
                }

                CswNbtWebServicePrintLabels.newPrintJob(CswResources, ReceivingDefiniton.PrinterNodeId, ReceivingDefiniton.PrintLabelId, ReceivingDefiniton.ContainerNodeId, PropVals);
            }
        }
Ejemplo n.º 2
0
 internal void Start()
 {
     for (int i = 0; i < Quant.RandomInt(); i++)
     {
         _particulas.Add(new Particula(Game, this));
     }
 }
Ejemplo n.º 3
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (OwnerAddress.Length != 0)
            {
                hash ^= OwnerAddress.GetHashCode();
            }
            if (ExchangeId != 0L)
            {
                hash ^= ExchangeId.GetHashCode();
            }
            if (TokenId.Length != 0)
            {
                hash ^= TokenId.GetHashCode();
            }
            if (Quant != 0L)
            {
                hash ^= Quant.GetHashCode();
            }
            if (Expected != 0L)
            {
                hash ^= Expected.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 4
0
        public string Post(string symbol, double close, long time)
        {
            DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
            var      date   = origin.AddSeconds(time);
            var      symb   = _context.Symbols.SingleOrDefault(s => s.Name == symbol);

            if (symb == null)
            {
                symb = new Symbol()
                {
                    Name = symbol
                };
                _context.Symbols.Add(symb);
                _context.SaveChanges();
            }

            var tick = new Tick()
            {
                Id       = Guid.NewGuid(),
                SymbolId = symb.Id,
                Close    = close,
                Time     = date
            };

            _context.Ticks.Add(tick);
            _context.SaveChanges();

            var quant = _context.Quants.Where(q => q.SymbolId == symb.Id).OrderByDescending(q => q.Ind).FirstOrDefault();

            if (quant == null)
            {
                _context.Quants.Add(new Quant()
                {
                    Id             = Guid.NewGuid(),
                    SymbolId       = symb.Id,
                    Close          = close,
                    Recommendation = Recommendation.CloseAll,
                    Ind            = 0,
                    TickId         = tick.Id
                });
                return("ok");
            }

            var dif = Math.Abs(close - quant.Close);

            if (dif > symb.QuantSize)
            {
                var network = _context.Networks.SingleOrDefault(n => n.SymbolId == symb.Id);
                var sign    = close < quant.Close ? -1 : 1;
                var steps   = (int)(dif / symb.QuantSize);
                for (int i = 1; i <= steps; i++)
                {
                    Recommendation recommendation = Recommendation.CloseAll;
                    var            newQuantVal    = quant.Close + symb.QuantSize * sign * i;
                    var            newQuant       = new Quant()
                    {
                        TickId         = tick.Id,
                        Close          = newQuantVal,
                        Ind            = quant.Ind + i,
                        Recommendation = recommendation
                    };

                    if (network != null)
                    {
                        network.QuantsProcessed++;

                        if (i == steps)
                        {
                            var inputQuants = _context.Quants.Where(q => q.SymbolId == symb.Id).OrderByDescending(q => q.Ind).Take(24).Reverse().ToList();
                            inputQuants.Add(newQuant);
                            if (inputQuants.Count == 25)
                            {
                                var predictor = (BasicNetwork)EncogDirectoryPersistence.LoadObject(new FileInfo(network.FileName));

                                BasicNeuralData input = GenerateInputNeuralData(inputQuants);

                                var predictData = predictor.Compute(input)[0];
                                newQuant.Recommendation = predictData < 0 ? Recommendation.Sell : Recommendation.Buy;
                            }

                            if (network.QuantsProcessed > 200)
                            {
                                _context.NetworkCalculationTasks.Add(new NetworkCalculationTask()
                                {
                                    ShouldStartAt = DateTime.Today.AddHours(18).AddMinutes(10),
                                    Status        = TaskStatus.New,
                                    SymbolId      = symb.Id
                                });
                            }
                        }
                    }

                    _context.Quants.Add(newQuant);
                    _context.SaveChanges();
                }
            }

            return("ok");
        }