private static void AccountRiskLimits() { Configuration.Default = new Configuration(new ApiClient(DemoUrl)); Configuration.Default.ApiKey.Add("Authorization", AccessToken); Configuration.Default.ApiKeyPrefix.Add("Authorization", "Bearer"); var account = Accounting.GetAccount(MyUserId); Console.WriteLine("\nSHOWING ACCOUNT RISK LIMITS"); Risks.ShowRiskLimits(account); Risks.SetMaxOverallPositionLimit(account, 9); Risks.SetDailyLossLimit(account, 1210.0); }
private static void OrganizationExample() { Configuration.Default = new Configuration(new ApiClient(LiveUrl)); Configuration.Default.ApiKey.Add("Authorization", AccessToken); Configuration.Default.ApiKeyPrefix.Add("Authorization", "Bearer"); var randomId = (new Random()).Next(); var newUsername = $"{MyUsername}_{randomId}"; var password = $"{MyUsername}+{randomId}+A"; Console.WriteLine($"Creating a user {newUsername} for our organization (should be done in LIVE environment)"); var newUser = Organization.CreateUser(newUsername, password); Organization.ChangePassword(newUser.Id.Value, password + "+", MyPassword); var membershipPlan = "GLABRYBA_PLAN"; Console.WriteLine($"Assigning membership plan {membershipPlan} to {newUser.Name}"); Organization.AssignPracticeTradovatePlan(newUser, membershipPlan); Console.WriteLine("Switching to DEMO environment"); Configuration.Default = new Configuration(new ApiClient(DemoUrl)); Configuration.Default.ApiKey.Add("Authorization", AccessToken); Configuration.Default.ApiKeyPrefix.Add("Authorization", "Bearer"); var accountName = $"APITEST{randomId}"; Console.WriteLine($"Creating a practice account {accountName} and granting permissions to {newUser.Name}"); var account = Organization.CreatePracticeAccount(accountName, 50000.0, newUser); Console.WriteLine($"Practice account created with ID=${account.Id}. Adding initial risk limits (max overall exposure = 3)"); Risks.SetMaxOverallPositionLimit(account, 3); Risks.SetDailyLossLimit(account, 1000.0); var account2 = Organization.CreatePracticeAccount("DUP" + accountName, 50000.0, newUser); Console.WriteLine($"Practice account created with ID=${account2.Id}. Adding initial risk limits (max overall exposure = 3)"); Risks.SetMaxOverallPositionLimit(account2, 3); Risks.SetDailyLossLimit(account2, 1000.0); }