public IList <double> GetNormalisedHistory(MarketModel model)
        {
            IList <double> h = new List <double>();

            for (int i = Math.Max(0, History.Count - 100); i < History.Count; i++)
            {
                h.Add(0.05 + 0.9 * (History[i] - MinValue) / (MaxValue - MinValue));
            }
            return(h);
        }
 public void Recalculate(MarketModel model)
 {
     //if (History.Count > 100) History.RemoveAt(0);
     if (model.BestCompanyValue < CurrentValue)
     {
         model.BestCompanyValue = CurrentValue;
     }
     CurrentValue = CurrentValue + Math.Max(-1, Math.Min(CHANGECOEF * (TargetValue - CurrentValue), 1));
     History.Add(CurrentValue);
 }
Ejemplo n.º 3
0
        public Form1(MarketModel market)
        {
            InitializeComponent();

            this.market = market;
            CreateComponents();

            MarketTimer.Interval = RefreshInterval;
            MarketTimer.Enabled  = true;
            Text = "Burza";
        }
        public IList <double> GetNormalisedHistory(MarketModel model)
        {
            IList <double> h   = new List <double>();
            double         max = History[History.Count - 1];

            for (int i = Math.Max(History.Count - 100, 0); i < History.Count; i++)
            {
                h.Add(0.05 + (History[i] / model.BestCompanyValue) * 0.9);
            }
            return(h);
        }
        public void Recalculate(MarketModel model)
        {
            CurrentValue += (NormalDistribution.GetRandomFromNormalDistribution(ExpectedValue, Variance) - CurrentValue) * CHANGECOEF;
            History.Add(CurrentValue);

            if (CurrentValue > MaxValue)
            {
                CurrentValue = MaxValue;
            }
            if (CurrentValue < MinValue)
            {
                CurrentValue = MinValue;
            }
        }
        static void Main()
        {
            MarketModel market = new MarketModel();

            market.LoadComodities("comodities.txt");
            market.LoadInvestors("investors.txt");
            Thread acceptingCashBoxes = new Thread(() => Listen(market));

            acceptingCashBoxes.IsBackground = true;
            acceptingCashBoxes.Start();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1(market));
        }
        static void Listen(MarketModel market)
        {
            TcpListener listener = new TcpListener(System.Net.IPAddress.Any, 14234);

            listener.Start();
            while (true)
            {
                TcpClient client  = listener.AcceptTcpClient();
                CashBox   cashBox = new CashBox(client, market);
                Thread    cb      = new Thread(() => { cashBox.Listen(); });
                cb.IsBackground = true;
                cb.Start();
                // market.AddCashBox(cashBox);
            }
        }
 public CashBox(TcpClient client, MarketModel market)
 {
     tcpClient   = client;
     this.market = market;
 }