static string GetShortTitle(MarketState phase, string nicheName) { var description = ""; switch (phase) { case MarketState.Death: description = $"{nicheName} are DYING."; break; case MarketState.Decay: description = $"{nicheName} are in DECAY."; break; case MarketState.Innovation: description = $"{nicheName} - future or just a moment?"; break; case MarketState.MassGrowth: case MarketState.MassUsage: description = $"{nicheName} are EVERYWHERE."; break; case MarketState.Trending: description = $"{nicheName} are TRENDING."; break; } return($"TRENDS change: {description}"); }
string GetMarketStateDescription(MarketState state) { switch (state) { case MarketState.Death: return("This market is DEAD. People don't need these apps anymore!"); case MarketState.Decay: return("This market's peak has gone. Reduce your expenses and prepare for market death"); case MarketState.Idle: return("We don't know if people need this or not. Maybe you'll be the innovator"); case MarketState.Innovation: return("Some people had shown their interest in these apps! Be first in new market!"); case MarketState.Trending: return("This market grows extremely fast"); case MarketState.MassGrowth: return("People need these apps, but will it last long?"); default: return("??? " + state.ToString()); } }
private void OnMarketStateChanged(MarketState marketState) { if (MarketStateChanged != null) { MarketStateChanged(this, marketState); } }
/// <summary> /// Simulate a day in the market. /// </summary> public void Simulate() { if (CurrentDate != EndDate) { CurrentDate = CurrentDate.AddDays(1); StockDay = DataManager.IsStockDay(CurrentDate); // before we even bother with any calculations, we need to // make sure the stock market was open on this given day if (StockDay) { UpdateMarketState(); StockDays.Add(CurrentDate); Log("Stockday on " + CurrentDate + ", proceeding..."); // how has our equity changed over postmarket and premarket for (int i = 0; i < Positions.Count; i++) { List <BarData> history = MarketState.FirstOrDefault(x => x.Key == Positions[i].Symbol).Value; // how much has the stock changed in value overnight? double change = history.Last().Open - history[history.Count - 2].Close; // change our equity! Equity += change * Positions[i].Shares; } // process orders ProcessAllOrders(); // with our new positions, how will our equity change today? for (int i = 0; i < Positions.Count; i++) { List <BarData> history = MarketState.FirstOrDefault(x => x.Key == Positions[i].Symbol).Value; // how much has the stock changed in value overnight? double change = history.Last().Close - history.Last().Open; // change our equity! Equity += change * Positions[i].Shares; // update the position value Positions[i].PriceHistory.Add(new Tuple <DateTime, double, double>(CurrentDate, history.Last().Close, change)); } // allow the strategy to make calls for the next day Strategy.Update(this); // process all logs for the day ProcessLogs(); } EquityHistory.Add(new Tuple <DateTime, double>(CurrentDate, Equity)); BuyingPowerHistory.Add(new Tuple <DateTime, double>(CurrentDate, BuyingPower)); } else { throw new Exception("Simulation is already complete."); } }
public void OpenMarket() { if (MarketState != MarketState.Open) { _logger.LogCritical("Market opened."); MarketState = MarketState.Open; } }
public void CloseMarket() { if (MarketState != MarketState.Closed) { _logger.LogCritical("Market closed."); MarketState = MarketState.Closed; } }
public void ReplaceNicheState(MarketState newPhase, int newDuration) { var index = GameComponentsLookup.NicheState; var component = (NicheStateComponent)CreateComponent(index, typeof(NicheStateComponent)); component.Phase = newPhase; component.Duration = newDuration; ReplaceComponent(index, component); }
private void OnMarketStateChanged(MarketState e) { var handler = MarketStateChanged; if (handler != null) { handler(this, e); } }
public void WhenIInferTheMarketSStatus() { if (!ScenarioContext.Current.ContainsKey("Market")) { return; } Market market = ScenarioContext.Current["Market"] as Market; MarketState state = new MarketState(market, true); }
/// <summary> /// Using the current day, we update the market information. /// </summary> private void UpdateMarketState() { List <string> stocks = DataManager.GetStocks(HalfBake); MarketState.Clear(); for (int i = 0; i < stocks.Count; i++) { MarketState.Add(stocks[i], DataManager.GetBars(stocks[i], StartDate, CurrentDate)); } }
void CalculateLockedVolume(AccountEntry account, MarketState state) { foreach (var asset in this.assets.Values) asset.LockedVolume = 0D; var cashAccount = new CashAccountInfo(account, this.assets.Values); using (var calculator = new CashAccountCalculator(cashAccount, state)) { } }
public void OpenMarket() { lock (marketStateLock) { if (MarketState != MarketState.Open) { timer = Observable.Timer(updateInterval, updateInterval, RxApp.MainThreadScheduler) .Subscribe(_ => UpdateStockPrices()); MarketState = MarketState.Open; } } }
public void Close() { // Ask salesmen to close their stall foreach (Person person in _people) { if (person is Salesman && person.Arrived) { ((Salesman)person).CloseStall(); } } _state = MarketState.Closed; OnChanged(String.Format("Market at {0} has ended", _location)); }
private void HandleMarketStateChanged(object sender, MarketState marketState) { switch (marketState) { case MarketState.Open: _clients.All.marketOpened(); break; case MarketState.Closed: _clients.All.marketClosed(); break; } }
private void BroadcastMarketStateChange(MarketState marketState) { switch (marketState) { case MarketState.Closed: Clients.All.marketClosed(); break; case MarketState.Open: Clients.All.marketOpened(); break; } }
public Task OpenMarket() { lock (_marketStateLock) { if (MarketState != MarketState.Open) { _timerStockUpdate = new Timer(UpdateStockPrices, null, _updateInterval, _updateInterval); MarketState = MarketState.Open; this.Callback?.OnMarketStateChanged(MarketState); } } return(Task.CompletedTask); }
public void OpenMarket() { lock (_marketStateLock) { if (MarketState != MarketState.Open) { _timer = new Timer(UpdateMarketDataPrices, null, _updateInterval, _updateInterval); MarketState = MarketState.Open; OnMarketStateChanged(MarketState.Open); } } }
public void OpenMarket() { lock (_marketStateLock) { if (MarketState != MarketState.Open) { _timer = new Timer(UpdateStockPrices, null, _updateInterval, _updateInterval); MarketState = MarketState.Open; BroadcastMarketStateChange(MarketState.Open); } } }
public CashAssets(IEnumerable<AssetInfo> assets, AccountEntry account, MarketState state) { var query = assets.Select(o => new Asset(account) { Currency = o.Currency, Volume = o.Balance, DepositCurrency = o.Balance, Rate = 1 }); this.assets = query.ToDictionary(o => o.Currency); this.CalculateLockedVolume(account, state); }
void CalculateLockedVolume(AccountEntry account, MarketState state) { foreach (var asset in this.assets.Values) { asset.LockedVolume = 0D; } var cashAccount = new CashAccountInfo(account, this.assets.Values); var orders = cashAccount.Orders.ToList(); using (var calculator = new CashAccountCalculator(cashAccount, state)) { } }
public CashAssets(IEnumerable <AssetInfo> assets, AccountEntry account, MarketState state) { var query = assets.Select(o => new Asset(account) { Currency = o.Currency, Volume = o.Balance, LockedVolume = o.LockedAmount, DepositCurrency = o.Balance, Rate = 1 }); this.assets = query.ToDictionary(o => o.Currency); this.CalculateLockedVolume(account, state); }
private void BroadcastMarketStateChange(MarketState marketState) { switch (marketState) { case MarketState.Open: Clients.All.marketStateChanged(marketState.ToString()); break; case MarketState.Closed: Clients.All.marketStateChanged(marketState.ToString()); break; default: break; } }
public void CloseMarket() { lock (marketStateLock) { if (MarketState == MarketState.Open) { if (timer != null) { timer.Dispose(); } MarketState = MarketState.Closed; } } }
public static float GetMarketStatePriceModifier(MarketState phase) { switch (phase) { case MarketState.Innovation: return(1); case MarketState.Trending: return(0.8f); case MarketState.MassGrowth: return(0.7f); case MarketState.MassUsage: return(0.65f); case MarketState.Decay: return(0.5f); default: return(0); } }
private string GetCurrentMenu(MarketState state, string reply = null) { var menu = new StringBuilder(); LastState = State; State = state; if (State != MarketState.View) { menu.AppendLine(GetReply(Check.NotNull(reply) ? reply : GetNextResponse())); } menu.AppendLine(GetMenuContent()); menu.Append(GetMenuFooter()); return(menu.ToString()); }
public void CloseMarket() { lock (_marketStateLock) { if (MarketState == MarketState.Open) { if (_timer != null) { _timer.Dispose(); } MarketState = MarketState.Closed; BroadcastMarketStateChange(MarketState.Closed); } } }
public bool OpenMarket(DateTime startDate, DateTime endDate, int interval) { lock (_marketStateLock) { if (MarketState != MarketState.Open) { LoadMarket(startDate, endDate, 10); _timer = new Timer(UpdateMarketRates, null, interval, interval); MarketState = MarketState.Open; BroadcastMarketStateChange(MarketState.Open); } } return(true); }
private async Task BroadcastMarketStateChange(MarketState marketState) { switch (marketState) { case MarketState.Open: await Hub.Clients.All.SendAsync("marketOpened"); break; case MarketState.Closed: await Hub.Clients.All.SendAsync("marketClosed"); break; default: break; } }
private static int GetNichePeriodDurationInMonths( MarketState phase, bool isFastGrowingOnStart = false, bool isSlowlyDecaying = false) { switch (phase) { case MarketState.Innovation: return(8); case MarketState.Trending: return(24); case MarketState.MassGrowth: return(60); //case MarketState.MassUsage: return case MarketState.Decay: return(24); default: return(1); } }
public static MarketState GetMarketState( this List <CompiledScheduleTimeInterval> compiledSchedule, string marketId, DateTime currentDateTime) { var currentInterval = compiledSchedule .Where(x => IsBetween(currentDateTime, x.Start, x.End)) .OrderByDescending(x => x.Schedule.Rank) .FirstOrDefault(); var isEnabled = currentInterval?.Enabled() ?? true; var result = new MarketState { Id = marketId, IsEnabled = isEnabled, }; return(result); }
public Task CloseMarket() { lock (_marketStateLock) { if (MarketState == MarketState.Open) { if (_timerStockUpdate != null) { _timerStockUpdate.Dispose(); } _timerStockUpdate = null; MarketState = MarketState.Closed; this.Callback?.OnMarketStateChanged(MarketState); } } return(Task.CompletedTask); }
public void CloseMarket() { if (MarketState == MarketState.Open || MarketState == MarketState.Opening) { lock (_marketStateLock) { if (MarketState == MarketState.Open || MarketState == MarketState.Opening) { MarketState = MarketState.Closing; if (_timer != null) { _timer.Dispose(); } MarketState = MarketState.Closed; BroadcastMarketStateChange(MarketState.Closed); } } } }
public static int GetMarketGrowth(MarketState phase) { switch (phase) { case MarketState.Idle: return(0); case MarketState.Innovation: return(1); case MarketState.Trending: return(5); case MarketState.MassGrowth: return(7); } return(5); }
private static void BroadcastMarketStateChange(MarketState marketState) { var clients = GetClients(); switch (marketState) { case MarketState.Open: clients.marketOpened(); break; case MarketState.Closed: clients.marketClosed(); break; case MarketState.Reset: clients.marketReset(); break; default: break; } }
public MarketStateChangeRequest(MarketState newState) { NewState = newState; }
public MarketStateChange(MarketState currentState) { CurrentState = currentState; }
private void BroadcastMarketStateChange(MarketState marketState) { switch (marketState) { case MarketState.Open: Clients.All.marketOpened(); break; case MarketState.Closed: Clients.All.marketClosed(); break; default: break; } }
public void Open() { _state = MarketState.Open; OnChanged(String.Format("Market starts at {0}", _location)); }