// Outputs the final standings and results in Markdown format // Called after the session is over private void AfterSession(ISessionDataProvider sessionData) { using (StreamWriter outFile = new StreamWriter(StandingsFile)) { int i = 0; IMatchConfig cfg = sessionData.MatchConfig; // Header and update time outFile.WriteLine("# Standings"); outFile.WriteLine(); outFile.WriteLine($"Last update: {DateTime.Now.ToString("R")}"); outFile.WriteLine(); outFile.WriteLine("## Configuration"); outFile.WriteLine(); outFile.WriteLine("| Parameter | Value |"); outFile.WriteLine("|:-------------- | ----------------: |"); outFile.WriteLine($"| Rows | {cfg.Rows} |"); outFile.WriteLine($"| Cols | {cfg.Cols} |"); outFile.WriteLine($"| Win sequence | {cfg.WinSequence} |"); outFile.WriteLine($"| Round pieces | {cfg.RoundPiecesPerPlayer} |"); outFile.WriteLine($"| Square pieces | {cfg.SquarePiecesPerPlayer} |"); outFile.WriteLine($"| Time limit | {cfg.TimeLimitMillis}ms |"); outFile.WriteLine(); // Classification outFile.WriteLine("## Classification"); outFile.WriteLine(); outFile.WriteLine("| Pos. | AI Thinker | Points |"); outFile.WriteLine("|:----:| ---------- | -----: |"); foreach (KeyValuePair <string, int> tp in sessionData.Standings) { outFile.WriteLine($"| {++i} | {tp.Key} | {tp.Value} |"); } outFile.WriteLine(); // Results outFile.WriteLine("## Results"); outFile.WriteLine(); outFile.WriteLine("_Winner, if any, shown in bold_"); outFile.WriteLine(); outFile.WriteLine("| White | Red | Details |"); outFile.WriteLine("| -----:|:------- | :-----: |"); foreach (KeyValuePair <Match, Winner> mw in sessionData.Results) { string white = $"`{mw.Key.thinkerWhite}`"; string red = $"`{mw.Key.thinkerRed}`"; if (mw.Value == Winner.White) { white = $"**{white}**"; } else if (mw.Value == Winner.Red) { red = $"**{red}**"; } outFile.WriteLine("| {0} | {1} | [+]({2}/{3}) |", white, red, PlayoutsFolder, MatchPlayoutFileName(mw.Key)); } } }
/// <summary> /// Startup initialization procedure, called only once in the lifecycle of an object /// (only after initial construction, not upon serialization-deserialization). /// </summary> /// <param name="dataProvider"></param> /// <param name="orderExectionProvider"></param> public bool SetInitialParameters(ISessionDataProvider dataProvider, ISourceOrderExecution orderExectionProvider) { SystemMonitor.CheckThrow(_sessionDataProvider == null && _orderExecutionProvider == null, "Session already initialized."); _sessionDataProvider = dataProvider; _orderExecutionProvider = orderExectionProvider; return(true); }
// ///////////////////////////////// // // Methods for listening to sessions // // ///////////////////////////////// // // Lists matches to play before the session starts private void BeforeSession(ISessionDataProvider sessionData) { Console.WriteLine("Matches to play:"); foreach (Match match in sessionData.Matches) { Console.WriteLine($"\t{match}"); } Console.WriteLine(); }
// Shows the final standings after the session is over private void AfterSession(ISessionDataProvider sessionData) { int i = 0; Console.WriteLine("\nFinal standings:"); foreach (KeyValuePair <string, int> tp in sessionData.Standings) { Console.WriteLine($"\t{++i}. {tp.Key,-20} {tp.Value,8}"); } }
/// <summary> /// /// </summary> public void Initialize(ISessionDataProvider dataProvider, ISourceOrderExecution orderExecutionProvider) { if (dataProvider == null) { return; } lock (this) { _dataProvider = dataProvider; if (_dataProvider != null) { _dataProvider.CurrentDataBarProviderChangedEvent += new DataProviderUpdateDelegate(_dataProvider_CurrentDataBarProviderChangedEvent); CurrentDataBarProvider = _dataProvider.DataBars; if (_dataProvider.Quotes != null) { _dataProvider.Quotes.QuoteUpdateEvent += new QuoteProviderUpdateDelegate(Quotes_QuoteUpdateEvent); } } _orderExecutionProvider = orderExecutionProvider; if (_orderExecutionProvider != null) { IOrderSink executor = _orderExecutionProvider; if (executor != null) { executor.OrdersUpdatedEvent += new OrdersUpdateDelegate(executor_OrderUpdatedEvent); } ITradeEntityManagement management = _orderExecutionProvider.TradeEntities; if (management != null) { management.OrdersAddedEvent += new OrderManagementOrdersUpdateDelegate(management_OrdersAddedEvent); management.OrdersRemovedEvent += new OrderManagementOrdersUpdateDelegate(management_OrdersRemovedEvent); management.OrdersUpdatedEvent += new OrderManagementOrdersUpdateTypeDelegate(management_OrderUpdatedEvent); } } ComponentResourceManager resources = new ComponentResourceManager(typeof(ProviderTradeChartSeries)); _imageDown = ((Image)(resources.GetObject("imageDown"))); _imageUp = ((Image)(resources.GetObject("imageUp"))); _imageCross = ((Image)(resources.GetObject("imageCross"))); _buyDashedPen.DashPattern = new float[] { 5, 5 }; _buyDashedPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom; _priceLevelPen.DashPattern = new float[] { 3, 3 }; _priceLevelPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom; _sellDashedPen.DashPattern = new float[] { 5, 5 }; _sellDashedPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom; } }
// ///////////////////////////////// // // Methods for listening to sessions // // ///////////////////////////////// // // Outputs the final ranking after the session is over private void AfterSession(ISessionDataProvider sessionData) { using (StreamWriter outFile = new StreamWriter(RankingFile)) { // Classification foreach (KeyValuePair <string, int> tp in sessionData.Standings) { outFile.WriteLine($"{tp.Key}\t{tp.Value}"); } } }
public void Dispose() { if (_sessionDataProvider != null) { _sessionDataProvider.Dispose(); _sessionDataProvider = null; } if (_orderExecutionProvider != null) { _orderExecutionProvider = null; } }
// Shows match result after match is over private void AfterMatch(Match match, ISessionDataProvider sessionData) { string resultStr; if (sessionData.LastMatchResult == Winner.Draw) { resultStr = "It's a draw"; } else { resultStr = $"Winner is {sessionData.WinnerString}"; } Console.WriteLine($" - {resultStr}"); }
protected virtual void SessionCheckBox_CheckedChanged(object sender, EventArgs e) { if (this.SessionCheckBox.Checked) { if (this.expertHost == null) { if (platform.RegisterComponent(this.expertHost = new RemoteExpertHost(this.ExpertName, this.expertType))) { ISessionDataProvider provider = this.expertHost.CreateRemoteExpertSession( new DataSessionInfo( this.sessionGuid = Guid.NewGuid(), this.SessionName, new Symbol(this.SymbolName), this.LotSize, this.DecimalPlaces ), this.clientID ); if (provider != null) { provider.ObtainDataBarProvider(TimeSpan.FromMinutes(1)); this.SessionNameTextBox.Enabled = false; this.SymbolsComboBox.Enabled = false; this.LotTextBox.Enabled = false; this.DecimalPlacesTextBox.Enabled = false; this.Message = "Session Connected"; } } } } else { if (this.expertHost != null) { this.expertHost.UnInitialize(); this.expertHost = null; this.Message = "Session Lost"; } this.SessionNameTextBox.Enabled = true; this.SymbolsComboBox.Enabled = true; this.LotTextBox.Enabled = true; this.DecimalPlacesTextBox.Enabled = true; } }
public static ISessionDataProvider GetProvider(ISessionConfiguration configuration) { ISessionDataProvider retVal = null; switch (configuration.Provider) { case ProviderTypeOptions.Sql: retVal = new SqlSessionDataProvider(configuration.ConnStringNameOrValue); break; case ProviderTypeOptions.Redis: retVal = new RedisSessionDataProvider(configuration.ConnStringNameOrValue, configuration.ApplicationKey); break; case ProviderTypeOptions.AeroSpike: retVal = new AeroSpikeSessionDataProvider(configuration.ConnStringNameOrValue, configuration.ApplicationKey); break; case ProviderTypeOptions.DynamoDB: retVal = new DynamoDBSessionDataProvider(configuration.ConnStringNameOrValue, configuration.ApplicationKey); break; case ProviderTypeOptions.Custom: if (string.IsNullOrWhiteSpace(configuration.CustomProviderType)) { throw new SessionConfigurationException(SessionResources.CustomProvider_Missing); } var provider = configuration.CustomProviderType.Construct(); retVal = provider as ISessionDataProvider; if (retVal == null) { throw new SessionConfigurationException(string.Format(SessionResources.CustomProvider_InvalidType, typeof(ISessionDataProvider).FullName)); } break; } if (retVal != null) { retVal.Configuration = configuration; } return(retVal); }
public void UnInitialize() { lock (this) { _ordersArrows.Clear(); GeneralHelper.FireAndForget(SelectedOrderChangedEvent, _selectedOrder, null); _selectedOrder = null; CurrentDataBarProvider = null; if (_dataProvider != null) { if (_dataProvider.Quotes != null) { _dataProvider.Quotes.QuoteUpdateEvent += new QuoteProviderUpdateDelegate(Quotes_QuoteUpdateEvent); } _dataProvider.CurrentDataBarProviderChangedEvent -= new DataProviderUpdateDelegate(_dataProvider_CurrentDataBarProviderChangedEvent); _dataProvider = null; } if (_orderExecutionProvider != null) { IOrderSink executor = _orderExecutionProvider; ITradeEntityManagement management = _orderExecutionProvider.TradeEntities; if (executor != null) { executor.OrdersUpdatedEvent -= new OrdersUpdateDelegate(executor_OrderUpdatedEvent); } if (management != null) { management.OrdersAddedEvent -= new OrderManagementOrdersUpdateDelegate(management_OrdersAddedEvent); management.OrdersRemovedEvent -= new OrderManagementOrdersUpdateDelegate(management_OrdersRemovedEvent); management.OrdersUpdatedEvent -= new OrderManagementOrdersUpdateTypeDelegate(management_OrderUpdatedEvent); } _orderExecutionProvider = null; } _buyDashedPen.Dispose(); _sellDashedPen.Dispose(); } }
// ///////////////////////////////// // // Methods for listening to sessions // // ///////////////////////////////// // // Outputs the final standings and results after the session is over private void AfterSession(ISessionDataProvider sessionData) { int i = 0; // Header and update time Console.WriteLine("# Standings"); Console.WriteLine(); Console.WriteLine($"Last update: {DateTime.Now.ToString("R")}"); Console.WriteLine(); // Classification Console.WriteLine("## Classification"); Console.WriteLine(); Console.WriteLine("| Pos. | AI Thinker | Points |"); Console.WriteLine("|:----:| ---------- | -----: |"); foreach (KeyValuePair <string, int> tp in sessionData.Standings) { Console.WriteLine($"| {++i} | {tp.Key} | {tp.Value} |"); } Console.WriteLine(); // Results Console.WriteLine("## Results"); Console.WriteLine(); Console.WriteLine("_Winner, if any, shown in bold_"); Console.WriteLine(); Console.WriteLine("| White | Red |"); Console.WriteLine("| -----:|:------- |"); foreach (KeyValuePair <Match, Winner> mw in sessionData.Results) { string white = $"`{mw.Key.thinkerWhite}`"; string red = $"`{mw.Key.thinkerRed}`"; if (mw.Value == Winner.White) { white = $"**{white}**"; } else if (mw.Value == Winner.Red) { red = $"**{red}**"; } Console.WriteLine($"| {white} | {red} |"); } }
public async Task Setup() { await SetupTest(); _sessionDataProvider = new SessionDataProvider(Options); }
void _dataProvider_CurrentDataBarProviderChangedEvent(ISessionDataProvider dataProvider) { CurrentDataBarProvider = dataProvider.DataBars; }
// Awake is called when the script instance is being loaded private void Awake() { // Get reference to the session data sessionData = GetComponent <ISessionDataProvider>(); }
/// <summary> /// Startup initialization procedure, called only once in the lifecycle of an object /// (only after initial construction, not upon serialization-deserialization). /// </summary> /// <param name="dataProvider"></param> /// <param name="orderExectionProvider"></param> public bool SetInitialParameters(ISessionDataProvider dataProvider, ISourceOrderExecution orderExectionProvider) { SystemMonitor.CheckThrow(_sessionDataProvider == null && _orderExecutionProvider == null, "Session already initialized."); _sessionDataProvider = dataProvider; _orderExecutionProvider = orderExectionProvider; return true; }
public SessionStore(ISessionConfiguration configuration) { _configuration = configuration; _provider = configuration.GetProvider(); }
public SessionController(ISessionDataProvider sessionDataProvider) { _sessionDataProvider = sessionDataProvider; }
// ///////////////////////////////// // // Methods for listening to sessions // // ///////////////////////////////// // // Creates the folder where the match play out files will be placed // Called before the session starts private void BeforeSession(ISessionDataProvider sessionData) { Directory.CreateDirectory(PlayoutsFolder); }
// Closes the currently open match play out file and resets the // standard output to what it was previously // Called after a match finishes private void AfterMatch(Match match, ISessionDataProvider sessionData) { Console.SetOut(stdOutput); currPlayoutFile.Close(); }
void DataProvider_DataBarProviderCreatedEvent(ISessionDataProvider dataProvider, IDataBarHistoryProvider provider) { CurrentSession.DataProvider.DataBarProviderCreatedEvent -= new DataProviderBarProviderUpdateDelegate(DataProvider_DataBarProviderCreatedEvent); Start(); }
public SessionStore() { _configuration = SessionConfigurationManager.GetConfiguration(); _provider = _configuration.GetProvider(); }