コード例 #1
0
        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);
        }
コード例 #2
0
 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);
 }
コード例 #3
0
        public Form1(MarketModel market)
        {
            InitializeComponent();

            this.market = market;
            CreateComponents();

            MarketTimer.Interval = RefreshInterval;
            MarketTimer.Enabled  = true;
            Text = "Burza";
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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;
            }
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        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);
            }
        }
コード例 #8
0
 public CashBox(TcpClient client, MarketModel market)
 {
     tcpClient   = client;
     this.market = market;
 }