public void Awake() { _enemies = new List<EnemyView>(); _enemyTimer = TimeKeeper.GetTimer(1); _enemyTimer.OnTimer += SpawnEnemy; }
public void UpdatesAfterCorrectPeriodElapses() { const int periods = 3; var periodSpan = Time.OneMinute; var reference = new DateTime(2016, 04, 06, 12, 0, 0); var referenceUtc = reference.ConvertToUtc(TimeZones.NewYork); var timeKeeper = new TimeKeeper(referenceUtc); var config = new SubscriptionDataConfig(typeof (TradeBar), Symbols.SPY, Resolution.Minute, TimeZones.NewYork, TimeZones.NewYork, true, false, false); var security = new Security(SecurityExchangeHours.AlwaysOpen(TimeZones.NewYork), config, new Cash("USD", 0, 0), SymbolProperties.GetDefault("USD")); security.SetLocalTimeKeeper(timeKeeper.GetLocalTimeKeeper(TimeZones.NewYork)); var model = new RelativeStandardDeviationVolatilityModel(periodSpan, periods); security.VolatilityModel = model; var first = new IndicatorDataPoint(reference, 1); security.SetMarketPrice(first); Assert.AreEqual(0m, model.Volatility); const decimal value = 0.471404520791032M; // std of 1,2 is ~0.707 over a mean of 1.5 var second = new IndicatorDataPoint(reference.AddMinutes(1), 2); security.SetMarketPrice(second); Assert.AreEqual(value, model.Volatility); // update should not be applied since not enough time has passed var third = new IndicatorDataPoint(reference.AddMinutes(1.01), 1000); security.SetMarketPrice(third); Assert.AreEqual(value, model.Volatility); var fourth = new IndicatorDataPoint(reference.AddMinutes(2), 3m); security.SetMarketPrice(fourth); Assert.AreEqual(0.5m, model.Volatility); }
void Start() { RecordedFrames = new List<StateFrame>(); TimeKeeper = TimeKeeper.Instance; TimeKeeper.PhaseChanged += OnPhaseChanged; }
public void MarketOrderFillsAtBidAsk(OrderDirection direction) { var symbol = Symbol.Create("EURUSD", SecurityType.Forex, "fxcm"); var exchangeHours = SecurityExchangeHours.AlwaysOpen(TimeZones.NewYork); var quoteCash = new Cash("USD", 1000, 1); var symbolProperties = SymbolProperties.GetDefault("USD"); var security = new Forex(symbol, exchangeHours, quoteCash, symbolProperties); var reference = DateTime.Now; var referenceUtc = reference.ConvertToUtc(TimeZones.NewYork); var timeKeeper = new TimeKeeper(referenceUtc); security.SetLocalTimeKeeper(timeKeeper.GetLocalTimeKeeper(TimeZones.NewYork)); var brokerageModel = new FxcmBrokerageModel(); var fillModel = brokerageModel.GetFillModel(security); const decimal bidPrice = 1.13739m; const decimal askPrice = 1.13746m; security.SetMarketPrice(new Tick(DateTime.Now, symbol, bidPrice, askPrice)); var quantity = direction == OrderDirection.Buy ? 1 : -1; var order = new MarketOrder(symbol, quantity, DateTime.Now); var fill = fillModel.MarketFill(security, order); var expected = direction == OrderDirection.Buy ? askPrice : bidPrice; Assert.AreEqual(expected, fill.FillPrice); }
private Security GetSecurity(Symbol symbol, DataNormalizationMode mode) { var symbolProperties = SymbolPropertiesDatabase.FromDataFolder() .GetSymbolProperties(symbol.ID.Market, symbol.Value, symbol.ID.SecurityType, CashBook.AccountCurrency); Security security; if (symbol.ID.SecurityType == SecurityType.Equity) { security = new QuantConnect.Securities.Equity.Equity( SecurityExchangeHours.AlwaysOpen(TimeZones.NewYork), new SubscriptionDataConfig(typeof(TradeBar), symbol, Resolution.Minute, TimeZones.NewYork, TimeZones.NewYork, true, true, false), new Cash(CashBook.AccountCurrency, 0, 1m), symbolProperties); } else { security = new QuantConnect.Securities.Forex.Forex( SecurityExchangeHours.AlwaysOpen(TimeZones.NewYork), new Cash(CashBook.AccountCurrency, 0, 1m), new SubscriptionDataConfig(typeof(TradeBar), symbol, Resolution.Minute, TimeZones.NewYork, TimeZones.NewYork, true, true, false), symbolProperties); } var TimeKeeper = new TimeKeeper(DateTime.Now.ConvertToUtc(TimeZones.NewYork), new[] { TimeZones.NewYork }); security.SetLocalTimeKeeper(TimeKeeper.GetLocalTimeKeeper(TimeZones.NewYork)); security.SetDataNormalizationMode(mode); return security; }
void Start() { sprite = transform.Find("Visual").GetComponent<SpriteRenderer>(); clearColor = sprite.color = color; clearColor.a = 0; tk = GetComponent<TimeKeeper>(); }
protected void Awake() { AttackCollider.enabled = false; _attackTimer = TimeKeeper.GetTimer(0.3f, 1, "AttackTimer"); _attackTimer.OnTimerComplete += OnAttackTimer; _attackTimer.transform.parent = gameObject.transform; }
public void Awake() { CanShoot = true; _tweening = false; _arrowTimer = TimeKeeper.GetTimer(1, 1); _arrowTimer.OnTimerComplete += OnArrowTimerComplete; }
public void AddingDuplicateTimeZoneDoesntAdd() { var reference = new DateTime(2000, 01, 01); var timeKeeper = new TimeKeeper(reference, new[] { TimeZones.NewYork }); var localTimeKeeper = timeKeeper.GetLocalTimeKeeper(TimeZones.NewYork); timeKeeper.AddTimeZone(TimeZones.NewYork); Assert.AreEqual(localTimeKeeper, timeKeeper.GetLocalTimeKeeper(TimeZones.NewYork)); }
public void Awake() { _growlTimer = TimeKeeper.GetTimer(5); _growlTimer.transform.parent = transform; _growlTimer.OnTimer += OnGrowlTimer; _growlTimer.StartTimer(); _dieTimer = TimeKeeper.GetTimer(DieSound.clip.length, 1); _dieTimer.transform.parent = transform; _dieTimer.OnTimerComplete += OnDieTimerComplete; }
protected void Awake() { Health = 5; Hittable = true; HitRecoverSeconds = 0.8f; _hitRecoverTimer = TimeKeeper.GetTimer(HitRecoverSeconds, 1, "HitRecoverTimer"); _hitRecoverTimer.OnTimerComplete += OnHitRecoverTimer; _hitRecoverTimer.transform.parent = gameObject.transform; }
public Butler(string version, IKeepTheTime timekeeper ) { Version = version; if ( timekeeper != null ) TimeKeeper = timekeeper; else TimeKeeper = new TimeKeeper( null ); Historian = new Historian(); Logger = LogManager.GetCurrentClassLogger(); Logger.Info( "ver:{0}", Version); }
public CallProcessor() { // email to list m_emailList = System.Configuration.ConfigurationManager.AppSettings["EMailList"]; // get the time to sleep between failed file open operations m_ReportInterval = 1000 * Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["ReportIntervalInSecs"]); // get our db interface m_db = new CdrDbProcessor(); m_keeper = new TimeKeeper(); m_processor = new ReportDataProcessor(); _reportFormatter = new ReportFormatter(); }
public void TimeKeeperReportsUpdatedLocalTimes() { var reference = new DateTime(2000, 01, 01); var timeKeeper = new TimeKeeper(reference, new[] { TimeZones.NewYork }); var localTime = timeKeeper.GetTimeIn(TimeZones.NewYork); timeKeeper.SetUtcDateTime(reference.AddDays(1)); Assert.AreEqual(localTime.AddDays(1), timeKeeper.GetTimeIn(TimeZones.NewYork)); timeKeeper.SetUtcDateTime(reference.AddDays(2)); Assert.AreEqual(localTime.AddDays(2), timeKeeper.GetTimeIn(TimeZones.NewYork)); }
public void DoesntUpdateOnZeroPrice() { const int periods = 3; var reference = new DateTime(2016, 04, 06, 12, 0, 0); var referenceUtc = reference.ConvertToUtc(TimeZones.NewYork); var timeKeeper = new TimeKeeper(referenceUtc); var config = new SubscriptionDataConfig(typeof(TradeBar), Symbols.SPY, Resolution.Minute, TimeZones.NewYork, TimeZones.NewYork, true, false, false); var security = new Security( SecurityExchangeHours.AlwaysOpen(TimeZones.NewYork), config, new Cash(Currencies.USD, 0, 0), SymbolProperties.GetDefault(Currencies.USD), ErrorCurrencyConverter.Instance ); security.SetLocalTimeKeeper(timeKeeper.GetLocalTimeKeeper(TimeZones.NewYork)); var model = new StandardDeviationOfReturnsVolatilityModel(periods); security.VolatilityModel = model; var first = new IndicatorDataPoint(reference, 1); security.SetMarketPrice(first); Assert.AreEqual(0m, model.Volatility); var second = new IndicatorDataPoint(reference.AddDays(1), 2); security.SetMarketPrice(second); Assert.AreEqual(0, model.Volatility); // update should not be applied since not enough time has passed var third = new IndicatorDataPoint(reference.AddDays(1.01), 1000); security.SetMarketPrice(third); Assert.AreEqual(0, model.Volatility); var fourth = new IndicatorDataPoint(reference.AddDays(2), 3); security.SetMarketPrice(fourth); Assert.AreEqual(5.6124, (double)model.Volatility, 0.0001); // update should not be applied as price is 0 var fifth = new IndicatorDataPoint(reference.AddDays(3), 0m); security.SetMarketPrice(fifth); Assert.AreEqual(5.6124, (double)model.Volatility, 0.0001); }
public void Update() { var valueDelta = CurrentValue - TargetValue; var speedDelta = TimeKeeper.GlobalTime(Speed); if (Math.Abs(valueDelta) > speedDelta) { CurrentValue -= speedDelta * Math.Sign(valueDelta); } else { CurrentValue = TargetValue; Complete = true; } }
public void LocalTimeKeepersGetTimeUpdates() { var reference = new DateTime(2000, 01, 01); var timeKeeper = new TimeKeeper(reference, new[] { TimeZones.NewYork }); var localTimeKeeper = timeKeeper.GetLocalTimeKeeper(TimeZones.NewYork); var localTime = localTimeKeeper.LocalTime; timeKeeper.SetUtcDateTime(reference.AddDays(1)); Assert.AreEqual(localTime.AddDays(1), localTimeKeeper.LocalTime); timeKeeper.SetUtcDateTime(reference.AddDays(2)); Assert.AreEqual(localTime.AddDays(2), localTimeKeeper.LocalTime); }
public IEnumerator StreamData() { var wait = new WaitForSeconds(1 / 10f); while (true) { SimManager.GetData(this); if (TimeKeeper.DeltaFrame() > Constants.CoroutineTimeSlice) { yield return(null); } yield return(wait); } }
public Game1() { graphics = new GraphicsDeviceManager(this); // The game terrain active_grid = new MainGrid(); // Receive messages from server and update the grid msghandler = new MessageHandler(active_grid); // Send messages to the server and play the game msgSender = new MessageSender(msghandler); // Initiating the Game AI gameAI = new GameAI(active_grid, msgSender); // Initiating timer timer = new TimeKeeper(active_grid); Content.RootDirectory = "Content"; }
public override void Die(Vector3 impactForce) { sndSrc.PlayOneShot(dead); TimeKeeper.Deregister(this); Rigidbody rb = modelTransform.gameObject.GetComponent <Rigidbody>(); if (rb != null) { int corpsesLayer = LayerMask.NameToLayer("Corpses"); gameObject.layer = corpsesLayer; modelTransform.gameObject.layer = corpsesLayer; rb.isKinematic = false; rb.AddForce(impactForce * deathForceMultiplier, ForceMode.Impulse); } }
public override void Update(List <Component> components) { // During update system picks up all the components on the scene at once. foreach (ActorComponent actor in components) { if (actor.Move) { // Retrieving the position component from entity. var position = actor.Owner.GetComponent <PositionComponent>(); position.PreviousPosition = position.Position; position.Position += TimeKeeper.GlobalTime(actor.Speed) * GameMath.DirectionToVector2(actor.Direction); } } }
public virtual void SpringLaunch(float?x = null, float?y = null, bool isSpring = false) { if (!isLaunching) { lastLaunch = TimeKeeper.GetTime(); isLaunching = true; hasLaunched = true; rb.velocity = new Vector2(x ?? LaunchX + rb.velocity.x, y ?? LaunchY); if (isSpring) { SoundEvents.Play("Bounce"); } onLaunch(); } }
void Awake() { if (instance == null || instance.Equals(null)) { instance = this; player = GetComponentInChildren <SongPlayer>(); loader = GetComponentInChildren <NoteLoader>(); timing = GetComponentInChildren <TimingManager>(); timekeeper = GetComponentInChildren <TimeKeeper>(); } else { Destroy(this); } }
IEnumerator UpdateAllCharacters() { Mover.MoveCharacter(player, out charInTheWay, true, player.currDir, Physics.DefaultRaycastLayers); yield return(new WaitForFixedUpdate()); for (int i = TimeKeeper.CharactersCount - 1; i >= 0; i--) { TimeKeeper.NextTurn(i); yield return(new WaitForFixedUpdate()); } player.currDir = MovDir.NONE; charInTheWay = null; isKillingMove = false; }
public static void then_should_add_one_to_month() { // Arrange var timeKeeper = new TimeKeeper(); var bound = It.IsAny <int>(); var numberGeneratorService = new Mock <INumberGeneratorService>().Object; timeKeeper.StartTrackingForest(new Forest(bound, numberGeneratorService)); // Act timeKeeper.Tick(); // Assert Assert.That(timeKeeper.Month, Is.EqualTo(2)); }
public GadgetWindow() { InitializeComponent(); timeKeeper = new TimeKeeper(new ProjectLogXmlRepository(fName), new LogSender()); timerManger = new TimerManger(); timerTextBlock.DataContext = timerManger; Topmost = true; Top = SystemParameters.WorkArea.Height - Height - 5; Left = SystemParameters.PrimaryScreenWidth - Width - 5; }
// Update is called once per frame void Update() { transform.position = new Vector3(cameraController.transform.position.x + offSet, transform.position.y, transform.position.z); if (transform.position.x > nextRoom) { nextRoom = transform.position.x + 30; SpawnSetPiece(); } if (TimeKeeper.GetTime() > nextEnemy) { Instantiate(enemy, new Vector3(transform.position.x, transform.position.y - 10, 0), Quaternion.identity); nextEnemy = TimeKeeper.GetTime() + Random.Range(enemyMin, enemyMax); } }
public void LocalTimeKeepersGetTimeUpdates() { var reference = new DateTime(2000, 01, 01); var timeKeeper = new TimeKeeper(reference, new[] { TimeZones.NewYork }); var localTimeKeeper = timeKeeper.GetLocalTimeKeeper(TimeZones.NewYork); var localTime = localTimeKeeper.LocalTime; timeKeeper.SetUtcDateTime(reference.AddDays(1)); Assert.AreEqual(localTime.AddDays(1), localTimeKeeper.LocalTime); timeKeeper.SetUtcDateTime(reference.AddDays(2)); Assert.AreEqual(localTime.AddDays(2), localTimeKeeper.LocalTime); }
public void Setup() { SymbolCache.Clear(); var timeKeeper = new TimeKeeper(new DateTime(2015, 12, 07)); _securityManager = new SecurityManager(timeKeeper); _securityTransactionManager = new SecurityTransactionManager(null, _securityManager); _securityPortfolioManager = new SecurityPortfolioManager(_securityManager, _securityTransactionManager); _subscriptionManager = new SubscriptionManager(); _subscriptionManager.SetDataManager(new DataManagerStub(timeKeeper)); _marketHoursDatabase = MarketHoursDatabase.FromDataFolder(); _symbolPropertiesDatabase = SymbolPropertiesDatabase.FromDataFolder(); _securityInitializer = SecurityInitializer.Null; }
public PacketHandler(TcpServer tcpServer, TimeKeeper timeKeeper, SimulationOwnership simulationOwnership) { this.defaultPacketProcessor = new DefaultServerPacketProcessor(tcpServer); var ProcessorArguments = new Dictionary <Type, object> { { typeof(TcpServer), tcpServer }, { typeof(TimeKeeper), timeKeeper }, { typeof(SimulationOwnership), simulationOwnership } }; authenticatedPacketProcessorsByType = PacketProcessor.GetProcessors(ProcessorArguments, p => p.BaseType.IsGenericType && p.BaseType.GetGenericTypeDefinition() == typeof(AuthenticatedPacketProcessor <>)); unauthenticatedPacketProcessorsByType = PacketProcessor.GetProcessors(ProcessorArguments, p => p.BaseType.IsGenericType && p.BaseType.GetGenericTypeDefinition() == typeof(UnauthenticatedPacketProcessor <>)); }
public PhysicsObject(PointF location, Mass mass, Force ownForce, Acceleration acceleration, Speed speed, DragProperties drag) { Location = location; Mass = mass; OwnForce = ownForce; ResutlingForce = ownForce; Acceleration = acceleration; Speed = speed; GravityForces = new List <Force>(); DragForces = new List <Force>(); Drag = drag; Diameter = 0; _lastRecalculation = TimeKeeper.Now(); }
/// <summary> /// Destorys the queue /// </summary> public async Task Destroy() { IsDestroyed = true; try { await TimeKeeper.Destroy(); OnMessageProduced.Dispose(); lock (PriorityMessagesList) PriorityMessagesList.Clear(); lock (MessagesList) MessagesList.Clear(); if (_ackSync != null) { _ackSync.Dispose(); _ackSync = null; } if (_listSync != null) { _listSync.Dispose(); } if (_pushSync != null) { _pushSync.Dispose(); } if (_triggerTimer != null) { await _triggerTimer.DisposeAsync(); _triggerTimer = null; } } finally { OnDestroyed?.Invoke(this); } _clients.Clear(); OnConsumerSubscribed.Dispose(); OnConsumerUnsubscribed.Dispose(); }
void Start() { if (Advertisement.isSupported) { Advertisement.Initialize("1648855", false); } else { Debug.Log("Platform is not supported00"); } catchSound = GameObject.Find("catchSound"); looseSound = GameObject.Find("looseSound"); timeKeeper = GameObject.Find("Cube").GetComponent <TimeKeeper>(); }
private void Awake() { Debug.Log("GameManager::Awake()"); instance = this; m_timeKeeper = GetComponent <TimeKeeper> (); // Event subscriptions TimeKeeper.onTimerChanged += UpdatePlayerLevelTime; ResultsUIManager.onContinueGame += ContinueGame; Debug.Assert(m_grid != null); Debug.Assert(m_gameObjectsHolder != null); Debug.Assert(m_playerPrefab != null); }
bool UpdateAnimation(StateMachine <ActorAnimationStates> stateMachine, StackableActorComponent actor, ActorAnimationStates newState) { actor.Animation += TimeKeeper.GlobalTime(actor.AnimationSpeed); if (actor.Animation >= 1 || actor.Animation < 0) { actor.Animation -= 1; if (newState != stateMachine.CurrentState) { stateMachine.ChangeState(newState); return(true); } } return(false); }
public void DoesntUpdateOnZeroPrice() { const int periods = 3; var periodSpan = Time.OneMinute; var reference = new DateTime(2016, 04, 06, 12, 0, 0); var referenceUtc = reference.ConvertToUtc(TimeZones.NewYork); var timeKeeper = new TimeKeeper(referenceUtc); var config = new SubscriptionDataConfig(typeof(TradeBar), Symbols.SPY, Resolution.Minute, TimeZones.NewYork, TimeZones.NewYork, true, false, false); var security = new Security( SecurityExchangeHours.AlwaysOpen(TimeZones.NewYork), config, new Cash(Currencies.USD, 0, 0), SymbolProperties.GetDefault(Currencies.USD), ErrorCurrencyConverter.Instance, RegisteredSecurityDataTypesProvider.Null, new SecurityCache() ); security.SetLocalTimeKeeper(timeKeeper.GetLocalTimeKeeper(TimeZones.NewYork)); var model = new RelativeStandardDeviationVolatilityModel(periodSpan, periods); security.VolatilityModel = model; var first = new IndicatorDataPoint(reference, 1); security.SetMarketPrice(first); Assert.AreEqual(0m, model.Volatility); const decimal value = 0.471404520791032M; // std of 1,2 is ~0.707 over a mean of 1.5 var second = new IndicatorDataPoint(reference.AddMinutes(1), 2); security.SetMarketPrice(second); Assert.AreEqual(value, model.Volatility); var third = new IndicatorDataPoint(reference.AddMinutes(2), 3m); security.SetMarketPrice(third); Assert.AreEqual(0.5m, model.Volatility); // update should not be applied as price is 0 var forth = new IndicatorDataPoint(reference.AddMinutes(3), 0m); security.SetMarketPrice(forth); Assert.AreEqual(0.5m, model.Volatility); }
public void PriceReturnsQuoteBarsIfPresent(OrderDirection orderDirection, decimal expected) { var time = new DateTime(2018, 9, 24, 9, 30, 0); var timeKeeper = new TimeKeeper(time.ConvertToUtc(TimeZones.NewYork), TimeZones.NewYork); var symbol = Symbol.Create("SPY", SecurityType.Equity, Market.USA); var configTradeBar = new SubscriptionDataConfig(typeof(TradeBar), symbol, Resolution.Minute, TimeZones.NewYork, TimeZones.NewYork, true, true, false); var configQuoteBar = new SubscriptionDataConfig(configTradeBar, typeof(QuoteBar)); var security = new Security( SecurityExchangeHoursTests.CreateUsEquitySecurityExchangeHours(), configQuoteBar, new Cash(Currencies.USD, 0, 1m), SymbolProperties.GetDefault(Currencies.USD), ErrorCurrencyConverter.Instance, RegisteredSecurityDataTypesProvider.Null, new SecurityCache() ); security.SetLocalTimeKeeper(timeKeeper.GetLocalTimeKeeper(TimeZones.NewYork)); var tradeBar = new TradeBar(time, symbol, 290m, 292m, 289m, 291m, 12345); security.SetMarketPrice(tradeBar); var quoteBar = new QuoteBar(time, symbol, new Bar(10, 15, 5, 11), 100, new Bar(20, 25, 15, 21), 100); security.SetMarketPrice(quoteBar); var configProvider = new MockSubscriptionDataConfigProvider(configQuoteBar); configProvider.SubscriptionDataConfigs.Add(configTradeBar); var testFillModel = new TestFillModel(); testFillModel.SetParameters(new FillModelParameters(security, null, configProvider, TimeSpan.FromDays(1))); var result = testFillModel.GetPricesPublic(security, orderDirection); Assert.AreEqual(expected, result.Close); }
public void TotalProfitIsCorrectlyEstimated(string ticker, decimal conversionRate, decimal minimumPriceVariation, int lotSize, decimal entryPrice, decimal pips, int entryQuantity) { // Arrange var timeKeeper = new TimeKeeper(DateTime.Now, TimeZones.NewYork); var symbol = Symbol.Create(ticker, SecurityType.Forex, Market.FXCM); var pairQuoteCurrency = symbol.Value.Substring(startIndex: 3); var cash = new Cash(pairQuoteCurrency, amount: 100000, conversionRate: conversionRate); var subscription = new SubscriptionDataConfig(typeof(QuoteBar), symbol, Resolution.Daily, TimeZones.NewYork, TimeZones.NewYork, fillForward: true, extendedHours: true, isInternalFeed: true); var pair = new QuantConnect.Securities.Forex.Forex( SecurityExchangeHours.AlwaysOpen(TimeZones.NewYork), cash, subscription, new SymbolProperties( "", pairQuoteCurrency, 1, minimumPriceVariation, lotSize, string.Empty ), ErrorCurrencyConverter.Instance, RegisteredSecurityDataTypesProvider.Null ); pair.SetLocalTimeKeeper(timeKeeper.GetLocalTimeKeeper(TimeZones.NewYork)); pair.SetFeeModel(new ConstantFeeModel(decimal.Zero)); var forexHolding = new ForexHolding(pair, new IdentityCurrencyConverter(Currencies.USD)); // Act forexHolding.SetHoldings(entryPrice, entryQuantity); var priceVariation = pips * 10 * minimumPriceVariation; forexHolding.UpdateMarketPrice(entryPrice + priceVariation); pair.SetMarketPrice(new Tick(DateTime.Now, pair.Symbol, forexHolding.Price, forexHolding.Price)); var actualPips = forexHolding.TotalCloseProfitPips(); // Assert Assert.AreEqual(pips, actualPips); }
public void TestCashFills() { // this test asserts the portfolio behaves according to the Test_Cash algo, see TestData\CashTestingStrategy.csv // also "https://www.dropbox.com/s/oiliumoyqqj1ovl/2013-cash.csv?dl=1" const string fillsFile = "TestData\\test_cash_fills.xml"; const string equityFile = "TestData\\test_cash_equity.xml"; var fills = XDocument.Load(fillsFile).Descendants("OrderEvent").Select(x => new OrderEvent( x.Get <int>("OrderId"), x.Get <string>("Symbol"), x.Get <OrderStatus>("Status"), x.Get <decimal>("FillPrice"), x.Get <int>("FillQuantity")) ).ToList(); var equity = XDocument.Load(equityFile).Descendants("decimal") .Select(x => decimal.Parse(x.Value, CultureInfo.InvariantCulture)) .ToList(); Assert.AreEqual(fills.Count + 1, equity.Count); // we're going to process fills and very our equity after each fill var subscriptions = new SubscriptionManager(TimeKeeper); var securities = new SecurityManager(TimeKeeper); var security = new Security(SecurityExchangeHours, subscriptions.Add(SecurityType.Base, "CASH", Resolution.Daily, "usa", TimeZones.NewYork), leverage: 10); securities.Add("CASH", security); var transactions = new SecurityTransactionManager(securities); var portfolio = new SecurityPortfolioManager(securities, transactions); portfolio.SetCash(equity[0]); for (int i = 0; i < fills.Count; i++) { // before processing the fill we must deduct the cost var fill = fills[i]; var time = DateTime.Today.AddDays(i); TimeKeeper.SetUtcDateTime(time.ConvertToUtc(TimeZones.NewYork)); // the value of 'CASH' increments for each fill, the original test algo did this monthly // the time doesn't really matter though security.SetMarketPrice(new IndicatorDataPoint("CASH", time, i + 1)); portfolio.ProcessFill(fill); Assert.AreEqual(equity[i + 1], portfolio.TotalPortfolioValue, "Failed on " + i); } }
private void Filter(ObservableCollection <BookViewModel> bookSource) { var bookAuthorSet = new HashSet <Guid>(bookSource.Select(b => b.AuthorID)); var timeKeeper = new TimeKeeper(); ProgressManager.UpdateProgress(0, AuthorCount.Count, timeKeeper); var i = 0; foreach (var authorCount in AuthorCount) { authorCount.IsVisible = bookAuthorSet.Contains(authorCount.Author.ID); ++i; ProgressManager.UpdateProgress(i, AuthorCount.Count, timeKeeper); } ProgressManager.Complete(); }
void OnEnable() { infoGetter = FindObjectOfType <InformationGetter>(); timeKeeper = FindObjectOfType <TimeKeeper>(); scoreKeeper = FindObjectOfType <ScoreKeeper>(); selfCommunication = FindObjectOfType <SelfCommunication>(); PropPlacement.OnMapCompleteEvent += GetExternalHandlers; PropPlacement.OnMapCompleteEvent += Test; PropPlacement.OnReadyToStartGamePlayEvent += ReadyToStartGamePlay; TurnController.GameOverEvent += SendFinalInfo; TurnController.GameOverQuitEvent += SendFinalInfo; #if UNITY_WEBGL && !UNITY_EDITOR Init(); #endif }
// Retrieve high score from file public static float[] LoadTimes() { if (File.Exists(Application.persistentDataPath + nameOfSaveFile)) { BinaryFormatter binaryFormatter = new BinaryFormatter(); FileStream fileStream = new FileStream(Application.persistentDataPath + nameOfSaveFile, FileMode.Open); TimeKeeper data = binaryFormatter.Deserialize(fileStream) as TimeKeeper; fileStream.Close(); return(data.GetTimes()); } else { return(ResetTimes()); } }
public static TimeKeeper GetTimer(float targetSeconds, float targetCycles = 0, string timerName = "TimeKeeper", bool destroyOnLoad = true) { GameObject go = new GameObject(); go.name = timerName; if (!destroyOnLoad) { DontDestroyOnLoad(go); } TimeKeeper timer = (TimeKeeper)go.AddComponent("TimeKeeper"); timer.TargetSeconds = targetSeconds; timer.TargetCycles = targetCycles; return(timer); }
public GroupReportProcessor() { // get the event log name m_eventLogName = System.Configuration.ConfigurationManager.AppSettings["EventLogFileName"]; // get the event log name // email to list m_emailList = System.Configuration.ConfigurationManager.AppSettings["EMailList"]; // get the time to sleep between failed file open operations m_ReportInterval = 1000 * Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["ReportIntervalInSecs"]); // get our db interface m_db = new CdrDbProcessor(); m_keeper = new TimeKeeper(); m_processor = new GroupReportDataProcessor(); _reportFormatter = new ReportFormatter(); }
public override void Update() { if (_mode == ShootingMode.Auto) { _initialDelayAlarm.Update(); if (!_initialDelayAlarm.Running && _fireAlarm.Update()) { Shoot(); } } if (_mode == ShootingMode.Trigger) { if (_myButton != null) { if (_myButton.Pressed) { Shoot(); } } else { if (TryGetComponent(out LinkComponent link)) { if (link.Pair != null) { _myButton = (Button)link.Pair.Owner; RemoveComponent <LinkComponent>(); } } } } if (_shootingAnimationRunning) { _shootingAnimationProgress += TimeKeeper.GlobalTime(_shootingAnimationSpeed); if (_shootingAnimationProgress > 1) { _shootingAnimationRunning = false; _shootingAnimationProgress = 0; } } }
public void UpdatesOnCustomConfigurationParametersOneMinute() { const int periods = 5; var reference = new DateTime(2016, 04, 06, 12, 0, 0); var referenceUtc = reference.ConvertToUtc(TimeZones.NewYork); var timeKeeper = new TimeKeeper(referenceUtc); var config = new SubscriptionDataConfig(typeof(TradeBar), Symbols.SPY, Resolution.Minute, TimeZones.NewYork, TimeZones.NewYork, true, false, false); var security = new Security( SecurityExchangeHours.AlwaysOpen(TimeZones.NewYork), config, new Cash(Currencies.USD, 0, 0), SymbolProperties.GetDefault(Currencies.USD), ErrorCurrencyConverter.Instance, RegisteredSecurityDataTypesProvider.Null, new SecurityCache() ); security.SetLocalTimeKeeper(timeKeeper.GetLocalTimeKeeper(TimeZones.NewYork)); var model = new StandardDeviationOfReturnsVolatilityModel(periods, Resolution.Minute, TimeSpan.FromMinutes(1)); for (var i = 0; i < 5; i++) { if (i < 3) { Assert.AreEqual(0, model.Volatility); } else { Assert.AreNotEqual(0, model.Volatility); } model.Update(security, new TradeBar { Open = 11 + (i - 1), High = 11 + i, Low = 9 - i, Close = 11 + i, Symbol = security.Symbol, Time = reference.AddMinutes(i) }); } Assert.AreNotEqual(0, model.Volatility); }
private void SpawnEnemy(TimeKeeper timer) { if(_enemies.Count >= _spawnMax) return; string enemyPrefab = (Random.Range(0, 1.0f) < 0.2f ? "GoreSuckerView" : "SwarmerView"); EnemyView enemyView = UnityUtils.LoadResource<GameObject>("Prefabs/" + enemyPrefab, true).GetComponent<EnemyView>(); enemyView.OnEnemyDie += OnEnemyDie; Follow ai = enemyView.gameObject.GetComponent<Follow>(); ai.Target = GameManager.Instance.PlayerView.transform; float angle = Random.Range(0, 2 * Mathf.PI); float x = _spawnRadius * Mathf.Cos(angle); float z = _spawnRadius * Mathf.Sin(angle); enemyView.transform.position = new Vector3(x, 0, z); enemyView.transform.parent = transform; _enemies.Add(enemyView); }
public void NotifiesWhenSecurityAddedViaIndexer() { var timeKeeper = new TimeKeeper(new DateTime(2015, 12, 07)); var manager = new SecurityManager(timeKeeper); var security = new Security(SecurityExchangeHours.AlwaysOpen(TimeZones.NewYork), CreateTradeBarConfig(), new Cash(CashBook.AccountCurrency, 0, 1m), SymbolProperties.GetDefault(CashBook.AccountCurrency)); manager.CollectionChanged += (sender, args) => { if (args.NewItems.OfType<object>().Single() != security) { Assert.Fail("Expected args.NewItems to have exactly one element equal to security"); } else { Assert.IsTrue(args.Action == NotifyCollectionChangedAction.Add); Assert.Pass(); } }; manager[security.Symbol] = security; }
public void NotifiesWhenSecurityRemoved() { var timeKeeper = new TimeKeeper(new DateTime(2015, 12, 07)); var manager = new SecurityManager(timeKeeper); var security = new Security(SecurityExchangeHours.AlwaysOpen(TimeZones.NewYork), CreateTradeBarConfig()); manager.Add(security.Symbol, security); manager.CollectionChanged += (sender, args) => { if (args.OldItems.OfType<object>().Single() != security) { Assert.Fail("Expected args.NewItems to have exactly one element equal to security"); } else { Assert.IsTrue(args.Action == NotifyCollectionChangedAction.Remove); Assert.Pass(); } }; manager.Remove(security.Symbol); }
private void OnHitRecoverTimer(TimeKeeper timer) { UnityUtils.SetTransparency(gameObject, 1.0f); Hittable = true; }
void Awake() { Instance = this; }
void Awake() { if(_instance == null) { //If I am the first instance, make me the Singleton _instance = this; DontDestroyOnLoad(this); } else { //If a Singleton already exists and you find //another reference in scene, destroy it! if(this != _instance) Destroy(this.gameObject); } }
public TileCamera(TileMap gameMap, MovingObject montior, int width, int height, int startRow = 0, int startCol = 0) { scrollLock = ScrollLock.unlocked; this.map = gameMap; controller = this; Width = width; Height = height; minRowToStartDraw = 0; minColToStartDraw = 0; StartRow = (startRow < 0) ? 0 : startRow; StartCol = (startCol < 0) ? 0 : startCol; maxCol = (gameMap.Width - Width) / gameMap[0, 0].Width; maxCol = (maxCol < 0) ? 0 : maxCol; maxRow = (gameMap.Height - Height) / gameMap[0, 0].Height; maxRow = (maxRow < 0) ? 0 : maxRow; currentMaxCol = maxCol; currentMinCol = minColToStartDraw; currentMaxRow = maxRow; currentMinRow = minRowToStartDraw; horizontalScrollPoint = new Vector2(0, width); verticalScrollPoint = new Vector2(0, height); maxRowsToDraw = GetMaxRows(gameMap as ITileMap); maxColToDraw = GetMaxCols(gameMap as ITileMap); MonitorRectangle(montior); tk = new TimeKeeper(); timer = new ObjectTimer("mili", 400, true); _vScrolling = _hscrolling = false; }
/// <summary> /// Initialise the Generic Data Manager Class /// </summary> /// <param name="timeKeeper">The algoritm's time keeper</param> public SubscriptionManager(TimeKeeper timeKeeper) { _timeKeeper = timeKeeper; //Generic Type Data Holder: Subscriptions = new List<SubscriptionDataConfig>(); }
void OnApplicationQuit() { instance = null; }
private static DateRules GetDateRules() { var timeKeeper = new TimeKeeper(DateTime.Today, new List<DateTimeZone>()); var manager = new SecurityManager(timeKeeper); var securityExchangeHours = MarketHoursDatabase.FromDataFolder().GetExchangeHours(Market.USA, null, SecurityType.Equity); var config = new SubscriptionDataConfig(typeof(TradeBar), Symbols.SPY, Resolution.Daily, TimeZones.NewYork, TimeZones.NewYork, true, false, false); manager.Add(Symbols.SPY, new Security(securityExchangeHours, config, new Cash(CashBook.AccountCurrency, 0, 1m), SymbolProperties.GetDefault(CashBook.AccountCurrency))); var rules = new DateRules(manager); return rules; }
protected override void Start() { timeKeeper = GameObject.Find("Time").GetComponent<TimeKeeper>(); taskList = GameObject.Find("TaskList").GetComponent<TaskList>(); base.Start(); }
public void ConstructsLocalTimeKeepers() { var reference = new DateTime(2000, 01, 01); var timeKeeper = new TimeKeeper(reference, new[] { TimeZones.NewYork }); Assert.IsNotNull(timeKeeper.GetLocalTimeKeeper(TimeZones.NewYork)); }
new void Start() { base.Start(); if (tempData.Count == 0) { Debug.LogWarning("Event is empty: " + gameObject.name); return; } foreach (EventStepData data in tempData) { eventData.Enqueue(data); } tempData.Clear(); next = eventData.Dequeue(); keeper = new TimeKeeper(TimeKeeper.KeeperMode.FixedUpdate); }
private static TimeRules GetTimeRules(DateTimeZone dateTimeZone) { var timeKeeper = new TimeKeeper(DateTime.Today, new List<DateTimeZone>()); var manager = new SecurityManager(timeKeeper); var securityExchangeHours = SecurityExchangeHoursProvider.FromDataFolder().GetExchangeHours("usa", null, SecurityType.Equity); var config = new SubscriptionDataConfig(typeof(TradeBar), SecurityType.Equity, "SPY", Resolution.Daily, "usa", securityExchangeHours.TimeZone, true, false, false); manager.Add("SPY", new Security(securityExchangeHours, config, 1)); var rules = new TimeRules(manager, dateTimeZone); return rules; }