/// <inheritdoc/> public void Suits(ICaller caller) { using IDealData data = InstanceFactory.GetInstance <IDealData>(); if (data.AnySuit()) { return; } IList <string> suitNames = new List <string> { "Spades", "Hearts", "Diamonds", "Clubs" }; short sortOrder = 1; foreach (string suitName in suitNames) { ISuit suit = new Suit( id: Guid.NewGuid(), code: suitName.Substring(0, 1), name: suitName, sortOrder: sortOrder++); data.CreateSuit(suit); } }
/// <inheritdoc/> public void Dealers(ICaller caller) { using IDealData data = InstanceFactory.GetInstance <IDealData>(); IList <IDealer> existingDealers = data.ReadAllDealers(); IList <string> dealerNames = new List <string> { "Steve", "Anne" }; foreach (string dealerName in dealerNames) { if (existingDealers.Any(d => d.Name == dealerName)) { continue; } IDealer dealer = new Dealer( id: Guid.NewGuid(), name: dealerName); data.CreateDealer(dealer); Console.WriteLine($@"Seeding Dealer: {dealerName}."); } }
/// <inheritdoc/> public void SetColours(ICaller caller) { using IDealData data = InstanceFactory.GetInstance <IDealData>(); if (data.AnySetColours()) { return; } IDictionary <string, string> setColourDetails = new Dictionary <string, string> { { "DK-BLUE", "Dark Blue" }, { "DK-GREEN", "Dark Green" }, { "LT-BLUE", "Light Blue" }, { "LT-GREEN", "Light Green" }, { "WHITE", "Off White" }, { "ORANGE", "Orange" }, { "PINK", "Pink" }, { "RED", "Red" }, { "YELLOW", "Yellow" }, { "RAINBOW", "Rainbow" } }; foreach (KeyValuePair <string, string> setColourDetail in setColourDetails) { ISetColour setColour = new SetColour( id: Guid.NewGuid(), code: setColourDetail.Key, name: setColourDetail.Value); data.CreateSetColour(setColour); } }
/// <inheritdoc/> public void Cards(ICaller caller) { using IDealData data = InstanceFactory.GetInstance <IDealData>(); if (data.AnyCard()) { return; } IList <ISuit> suits = data.ReadAllSuits(); if (suits.Count == 0) { throw new InvalidOperationException(ExceptionResource.MustSeedSuitsBeforeSeedingCards); } IList <IRank> ranks = data.ReadAllRanks(); if (suits.Count == 0) { throw new InvalidOperationException(ExceptionResource.MustSeedSuitsBeforeSeedingCards); } foreach (ISuit suit in suits) { foreach (IRank rank in ranks) { data.CreateCard(new Card( id: Guid.NewGuid(), suit: suit, rank: rank)); } } }
public bool runBackTest(ICaller caller, string name) { if (tradeSystem.vm.Count == 0) { runSingleBackTest(caller, new MonteCarlo(name)); return(true); } if (!config.useVars) { return(false); } totalLoops_ = 1; countLoops_ = 0; foreach (Variavel v in tradeSystem.vm.variaveis) { totalLoops_ *= v.steps; } if (config.useVars) { loopVariavel(caller, 0); } else { runMonteCarlo(caller, "MC Run"); } return(true); }
public void loopVariavel(ICaller caller, int id) { Variavel v = tradeSystem.vm.GetVariavel(id); v.reset(); while (!v.hasEnded()) { Utils.Info("loop da variavel " + v.name + " com vlr:" + v.vlrAtual); if (id + 1 < tradeSystem.vm.Count) { loopVariavel(caller, id + 1); } else { countLoops_++; runMonteCarlo(caller, getVarsValues()); } v.next(); //runSingleBackTest(); } }
/// <inheritdoc/> public void Organisers(ICaller caller) { using IDealData data = InstanceFactory.GetInstance <IDealData>(); IList <IOrganiser> existingOrganisers = data.ReadAllOrganisers(); IDictionary <string, string> organiserDetails = new Dictionary <string, string> { { "LCBA", "LCBA" }, { "CBC", "County Bridge Club" }, { "BRADGATE", "Bradgate Bridge Club" }, { "GLENFIELD", "Glenfield Bridge Club" }, { "CBT", "Charnwood Bridge Teachers" } }; foreach (KeyValuePair <string, string> organiserDetail in organiserDetails) { if (existingOrganisers.Any(o => o.Code == organiserDetail.Key)) { continue; } IOrganiser organiser = new Organiser( id: Guid.NewGuid(), code: organiserDetail.Key, name: organiserDetail.Value); data.CreateOrganiser(organiser); Console.WriteLine($@"Seeding Dealer: {organiser.Name}."); } }
public EditTaskForm(TaskModel task, ICaller caller) { callingForm = caller; this.task = task; InitializeComponent(); InitializeList(); InitializeControls(); }
public EditPersonForm(PersonModel person, ICaller caller) { callingForm = caller; customer = person; InitializeComponent(); InitializeControls(); InitializeLists(); }
public AddTaskForm(ICaller caller, PersonModel person) { callingForm = caller; InitializeComponent(); InitializeList(); customer_combobox.SelectedItem = person; customer_combobox.Text = person.RepresentByLastNameShort; }
public TaskByPerson(PersonModel person, ICaller caller) { InitializeComponent(); callingForm = caller; InitializeCombobox(); InitializeTaskList(); customer = person; customer_combobox.SelectedItem = customer; customer_combobox.Text = customer.RepresentByLastNameShort; }
private int Run(ICaller caller) { var counter = 0; for (int i = 0; i < this.initialValuesArray.Length; i++) { counter += caller.Test(this.initialValuesArray[i]); } return(counter); }
public void Shutdown() { _caller.Shutdown(); _caller = null; UnInit(); if (sInstance == this) { sInstance = null; } }
public static T Summon <T>(ICaller caller) { var task = Task.Run(() => { var guid = Guid.NewGuid(); while (Callers.TryAdd(guid, caller)) { } }); var t = Activator.CreateInstance <T>(); return(t); }
/// <inheritdoc/> public void ErrorReasons(ICaller caller) { using IDealData data = InstanceFactory.GetInstance <IDealData>(); if (data.AnyErrorReason()) { return; } IList <IErrorReasonGroup> errorReasonGroups = data.ReadAllErrorReasonGroups(); IErrorReasonGroup errorReasonGroupSet = errorReasonGroups .Single(erg => erg.Code == "SET"); IErrorReasonGroup errorReasonGroupPack = errorReasonGroups .Single(erg => erg.Code == "PACK"); IDictionary <string, string> errorReasonDetails = new Dictionary <string, string> { { "MULTIJAM", "Multi-card jam" }, { "INVERTED", "Inverted card" }, { "MISCOUNT", "Wrong number of cards in a hand" }, { "MISSING", "Missing card" }, }; foreach (KeyValuePair <string, string> errorReasonGroupDetail in errorReasonDetails) { IErrorReason errorReason = new ErrorReason( id: Guid.NewGuid(), code: errorReasonGroupDetail.Key, name: errorReasonGroupDetail.Value, errorReasonGroup: errorReasonGroupSet); data.CreateErrorReason(errorReason); } errorReasonDetails = new Dictionary <string, string> { { "NOTKNOWN", "Card not recognised" }, { "ALREADY-DEALT", "Card already dealt" }, { "JAM", "Card jammed" } }; foreach (KeyValuePair <string, string> errorReasonGroupDetail in errorReasonDetails) { IErrorReason errorReason = new ErrorReason( id: Guid.NewGuid(), code: errorReasonGroupDetail.Key, name: errorReasonGroupDetail.Value, errorReasonGroup: errorReasonGroupPack); data.CreateErrorReason(errorReason); } }
static void Main(string[] args) { Smartphone smartphone = new Smartphone(); ICaller caller = smartphone; string[] phoneNumbers = Console.ReadLine().Split(); caller.Call(phoneNumbers); IBrowser browser = smartphone; string[] urls = Console.ReadLine().Split(); browser.Browse(urls); }
/* public void printMonteCarlo() * { * for (int i = 0; i < monteCarlo.Count; i++) * { * MonteCarlo mC = monteCarlo[i]; * mC.printPerformance("MC(" + i + ")"); * } * }*/ /* public void ordernaMonteCarlo(Consts.OrdemEstatistica ordem) * { * for (int i = 0; i < monteCarlo.Count - 1; i++) * { * * for (int j = i + 1; j < monteCarlo.Count; j++) * { * MonteCarlo statI = monteCarlo[i]; * float vI = 0; * MonteCarlo statJ = monteCarlo[j]; * float vJ = 0; * if (ordem == Backtester.backend.Consts.OrdemEstatistica.CAPITAL_FINAL) vI = statI.getCapitalFinal(); * if (ordem == Backtester.backend.Consts.OrdemEstatistica.CAPITAL_FINAL) vJ = statJ.getCapitalFinal(); * if (vI > vJ) * { * monteCarlo[j] = statI; * monteCarlo[i] = statJ; * } * } * * } * * }*/ public Carteira runMonteCarlo(ICaller caller, String name) { MonteCarlo mC = new MonteCarlo(name); Utils.println("runMonteCarlo:" + name); Estatistica stat = runSingleBackTest(caller, mC).estatistica; stat.setDesc(getVarsValues()); mC.setEstatistica(stat); mC.FinishStats(facade.formulaManager, carteira); mC.printPerformance(""); caller.UpdateApplication(carteira, mC, countLoops_, totalLoops_); //monteCarlo.Add(mC); return(carteira); }
/// <inheritdoc /> public void Sets(ICaller caller) { using IDealData data = InstanceFactory.GetInstance <IDealData>(); IList <ISet> existingSets = data.ReadAllSets(); ISetWithPacksFactory setFactory = new SetWithPacksFactory( owners: data.ReadAllOwners(), packColours: data.ReadAllPackColours(), setPurposes: data.ReadAllSetPurposes(), setColours: data.ReadAllSetColours()); IList <ISetWithPacks> setsWithPacks = new List <ISetWithPacks> { setFactory.Create32BoardSet("BRADGATE", "EVENTS", "LT-BLUE", "Blue"), setFactory.Create32BoardSet("BRADGATE", "EVENTS", "PINK", "Pink"), setFactory.Create32BoardSet("BRADGATE", "EVENTS", "LT-GREEN", "Green"), setFactory.Create32BoardSet("BRADGATE", "EVENTS", "WHITE", "White"), setFactory.Create32BoardSet("GLENFIELD", "EVENTS", "DK-BLUE", "Black"), setFactory.Create32BoardSet("GLENFIELD", "EVENTS", "LT-BLUE", "Blue"), setFactory.Create32BoardSet("GLENFIELD", "EVENTS", "DK-GREEN", "Green"), setFactory.Create32BoardSet("GLENFIELD", "EVENTS", "LT-GREEN", "Lime"), setFactory.Create32BoardSet("LCBA", "EVENTS", "DK-BLUE", "Black"), setFactory.Create32BoardSet("LCBA", "EVENTS", "ORANGE", "Orange"), setFactory.Create32BoardSet("LCBA", "EVENTS", "RED", "Red"), setFactory.Create32BoardSet("LCBA", "EVENTS", "YELLOW", "Yellow"), setFactory.Create32BoardSet("WRIGHT", "EVENTS", "YELLOW", "Yellow"), }; foreach (ISetWithPacks setWithPacks in setsWithPacks) { if (existingSets.Where(es => es.Owner.Code == setWithPacks.Owner.Code) .Where(es => es.SetPurpose.Code == setWithPacks.SetPurpose.Code) .Where(es => es.SetColour.Code == setWithPacks.SetColour.Code) .Any(es => es.Description == setWithPacks.Description)) { continue; } data.CreateSet(setWithPacks); foreach (IPack pack in setWithPacks.Packs) { data.CreatePack(pack); } Console.WriteLine($@"Seeding Set: {setWithPacks.Owner.Code} {setWithPacks.Description}."); } }
public static bool Startup(ICaller caller, int poolSize) { if (sInstance != null) { return(false); } var s = new CrossStation(caller); if (!s.DoInit(poolSize)) { return(false); } sInstance = s; return(true); }
/* * Método principal que vai verificar as condições e fazer entradas (um integrador por assim dizer) */ public Carteira runSingleBackTest(ICaller caller, MonteCarlo mc) { Init(mc); Periodo periodo = periodoInicial; string mesA = ""; //int[] rd = GetRandomOrder(config.qtdPercPapeis); int[] rd = GetRandomOrder(80); while (periodo.proximoPeriodo != null) { BackTestePeriodo(caller, mc, ref periodo, ref mesA, rd); } carteira.FechaPosicoes(periodo); carteira.EndTurn(periodo, !mesA.Equals(periodo.GetMes())); Utils.println("Saldo final:" + carteira.GetCapital()); carteira.PrintEstatistica(); return(carteira); }
/// <inheritdoc/> public void Owners(ICaller caller) { using IDealData data = InstanceFactory.GetInstance <IDealData>(); if (data.AnyOwner()) { return; } IDictionary <string, string> ownerDetails = new Dictionary <string, string> { { "LCBA", "LCBA" }, { "CBC", "County Bridge Club" }, { "BRADGATE", "Bradgate Bridge Club" }, { "GLENFIELD", "Glenfield Bridge Club" }, { "CBT", "Charnwood Bridge Teachers" } }; foreach (KeyValuePair <string, string> ownerDetail in ownerDetails) { IOwner owner = new Owner( id: Guid.NewGuid(), code: ownerDetail.Key, name: ownerDetail.Value, isClub: true); data.CreateOwner(owner); } ownerDetails = new Dictionary <string, string> { { "WRIGHT", "Steve/Anne Wright" } }; foreach (KeyValuePair <string, string> ownerDetail in ownerDetails) { IOwner owner = new Owner( id: Guid.NewGuid(), code: ownerDetail.Key, name: ownerDetail.Value, isClub: false); data.CreateOwner(owner); } }
public ServiceState Execute(ServiceOptions options, ICaller caller) { ServiceState state = new ServiceState(this, options, caller); Service service = Services.FindCreateByKey <Service>(options.Namespace, options.Name); if (state.RuntimeError = (service == null) && options.FullInformation) { _errorlog.Pass(this, "service/missing", s => string.Format(s, options)); } else if (Execute(service, options, state) && state.Options.FullInformation) { _errorlog.Pass(this, "service/success", s => string.Format(s, service)); } else if (state.Options.FullInformation) { _errorlog.Pass(this, "service/failed", s => string.Format(s, service)); } return(state); }
public new int CallFunction(string name, IArguments args, ICaller caller = null) { if (this.FunctionTable.ContainsKey(name)) { return(this.FunctionTable.Call(name, args, caller ?? this)); } else { foreach (var plugin in this.pluginList.Values) { if (plugin.FunctionList.Contains(name)) { return(plugin.CallFunction(name, args, caller ?? this)); } } } return(-1); }
public void HandleCommand(string command, ICaller caller) { if (caller.Type.In(CallerType.Console)) { this.History.Add(command); } if (caller.Type.In(CallerType.Console, CallerType.Client)) { List <string> commandTextList = command.Split(Utility.CharWhiteSpace).ToList(); commandTextList.RemoveAll((s) => string.IsNullOrWhiteSpace(s)); if (commandTextList.Count > 0 && !string.IsNullOrWhiteSpace(commandTextList[0])) { if (this.CommandInfoListWithPlugin.ContainsKey(commandTextList[0])) { Arguments args = new Arguments(); for (int i = 1; i < commandTextList.Count; i++) { args.Put((i - 1).ToString(), commandTextList[i]); } args.Put("args", command.Substring(commandTextList[0].Length).Trim()); CallCommand(commandTextList[0], args, caller); if (commandTextList[0] != "say" && caller.Type == CallerType.Client) { IUser user = caller as IUser; if (caller != null) { this.Logger.Info(string.Format(this.lang.UserCommand, user.Name, command)); } } } else { caller.Logger.Error(this.lang.UnknownCommand); } } } }
protected int CallFunction(string name, IArguments args, ICaller caller) { try { CallBody call = new CallBody() { Call = name, Args = args as Arguments }; MessageBody message = new MessageBody() { Flag = MessageFlag.Message, Guid = this.Guid, Content = AESHelper.Encrypt(this.JsonSerialzation.Serialize(call), this.AESKey) }; string text = this.JsonSerialzation.Serialize(message); this.Send(text, this.TcpClient); return(0); } catch (SocketException ex) { SocketError?.Invoke(this, new SocketExcptionEventArgs(this.Guid, ex)); return(-1); } }
/// <inheritdoc/> public void Ranks(ICaller caller) { using IDealData data = InstanceFactory.GetInstance <IDealData>(); if (data.AnyRank()) { return; } IDictionary <string, string> rankDetails = new Dictionary <string, string> { { "A", "Ace" }, { "K", "King" }, { "Q", "Queen" }, { "J", "Jack" }, { "10", "Ten" }, { "9", "Nine" }, { "8", "Eight" }, { "7", "Seven" }, { "6", "Six" }, { "5", "Five" }, { "4", "Four" }, { "3", "Three" }, { "2", "Two" } }; short sortOrder = 1; foreach (KeyValuePair <string, string> rankDetail in rankDetails) { IRank rank = new Rank( id: Guid.NewGuid(), code: rankDetail.Key, name: rankDetail.Value, sortOrder: sortOrder++); data.CreateRank(rank); } }
/// <inheritdoc/> public void PackColours(ICaller caller) { using IDealData data = InstanceFactory.GetInstance <IDealData>(); if (data.AnyPackColour()) { return; } IList <string> colours = new List <string> { "Red", "Blue" }; foreach (string colour in colours) { IPackColour packColour = new PackColour( id: Guid.NewGuid(), code: colour.Substring(0, 1), colour: colour); data.CreatePackColour(packColour); } }
public void BackTestePeriodo(ICaller caller, MonteCarlo mc, ref Periodo periodo, ref string mesA, int[] rd) { caller.SimpleUpdate(); //System.out.println("Periodo:"+periodo.getPeriodo()); carteira.EndTurn(periodo, !mesA.Equals(periodo.GetMes())); mc.AnalizaPeriodo(carteira); if (!mesA.Equals(periodo.GetMes())) { mesA = periodo.GetMes() + ""; } for (int i = 0; i < rd.Length; i++) { Ativo ativo = ativos[rd[i]]; Candle candle = ativo.GetCandle(periodo); if (candle != null) { BackTestCandle(periodo, ativo, candle); } } periodo = periodo.proximoPeriodo; }
/// <inheritdoc/> public void SetPurposes(ICaller caller) { using IDealData data = InstanceFactory.GetInstance <IDealData>(); if (data.AnySetPurpose()) { return; } IDictionary <string, string> setPurposeDetails = new Dictionary <string, string> { { "TEACHING", "Teaching" }, { "EVENTS", "Events" } }; foreach (KeyValuePair <string, string> setPurposeDetail in setPurposeDetails) { ISetPurpose setPurpose = new SetPurpose( id: Guid.NewGuid(), code: setPurposeDetail.Key, name: setPurposeDetail.Value); data.CreateSetPurpose(setPurpose); } }
/// <inheritdoc /> public void ErrorReasonGroups(ICaller caller) { using IDealData data = InstanceFactory.GetInstance <IDealData>(); if (data.AnyErrorReasonGroup()) { return; } IDictionary <string, string> errorReasonGroupDetails = new Dictionary <string, string> { { "SET", "Set" }, { "PACK", "Pack" } }; foreach (KeyValuePair <string, string> errorReasonGroupDetail in errorReasonGroupDetails) { IErrorReasonGroup errorReasonGroup = new ErrorReasonGroup( id: Guid.NewGuid(), code: errorReasonGroupDetail.Key, name: errorReasonGroupDetail.Value); data.CreateErrorReasonGroup(errorReasonGroup); } }