public async Task LimitOrder() { // Create, modify and cancel limit order TTAccount account = await _client.GetAccountAsync(); if ((account.AccountingType == TTAccountingTypes.Gross) || (account.AccountingType == TTAccountingTypes.Net)) { // Create limit order var limit = await _client.CreateTradeAsync(new TTTradeCreate { Type = TTOrderTypes.Limit, Side = TTOrderSides.Buy, Symbol = (account.AccountingType == TTAccountingTypes.Gross) ? "EURUSD" : "EUR/USD", Amount = 10000, Price = 1.0M, Comment = "Buy limit from Web API sample" }); // Modify limit order limit = await _client.ModifyTradeAsync(new TTTradeModify { Id = limit.Id, Comment = "Modified limit from Web API sample" }); // Cancel limit order await _client.CancelTradeAsync(limit.Id); } }
public async Task GetPositions() { // Account positions TTAccount account = await _client.GetAccountAsync(); List <TTPosition> positions = null; if (account.AccountingType == TTAccountingTypes.Net) { if (string.IsNullOrEmpty(PositionId)) { positions = await _client.GetAllPositionsAsync(); } else { try { TTPosition position = await _client.GetPositionAsync(PositionId); positions = new List <TTPosition>(new[] { position }); } catch (Exception) { } } } Positions = positions != null ? new ObservableCollection <TTPosition>(positions) : null; }
public async Task GetAssets() { // Account assets TTAccount account = await _client.GetAccountAsync(); List <TTAsset> assets = null; if (account.AccountingType == TTAccountingTypes.Cash) { if (string.IsNullOrEmpty(AssetCurrency)) { assets = await _client.GetAllAssetsAsync(); } else { try { TTAsset asset = await _client.GetAssetAsync(AssetCurrency); assets = new List <TTAsset>(new[] { asset }); } catch (Exception) { } } } Assets = assets != null ? new ObservableCollection <TTAsset>(assets) : null; }
public async Task GetAccount() { AccountInfo.Clear(); // Account info TTAccount account = await _client.GetAccountAsync(); AccountInfo.Add(new KeyValuePair <string, object>(nameof(account.Id), account.Id)); AccountInfo.Add(new KeyValuePair <string, object>(nameof(account.Group), account.Group)); AccountInfo.Add(new KeyValuePair <string, object>(nameof(account.AccountingType), account.AccountingType)); AccountInfo.Add(new KeyValuePair <string, object>(nameof(account.Name), account.Name)); AccountInfo.Add(new KeyValuePair <string, object>(nameof(account.Email), account.Email)); AccountInfo.Add(new KeyValuePair <string, object>(nameof(account.Comment), account.Comment)); AccountInfo.Add(new KeyValuePair <string, object>(nameof(account.Registered), account.Registered.ToString("u"))); AccountInfo.Add(new KeyValuePair <string, object>(nameof(account.IsBlocked), account.IsBlocked)); AccountInfo.Add(new KeyValuePair <string, object>(nameof(account.IsReadonly), account.IsReadonly)); AccountInfo.Add(new KeyValuePair <string, object>(nameof(account.IsValid), account.IsValid)); AccountInfo.Add(new KeyValuePair <string, object>(nameof(account.IsWebApiEnabled), account.IsWebApiEnabled)); AccountInfo.Add(new KeyValuePair <string, object>(nameof(account.Leverage), account.Leverage)); AccountInfo.Add(new KeyValuePair <string, object>(nameof(account.Balance), account.Balance)); AccountInfo.Add(new KeyValuePair <string, object>(nameof(account.BalanceCurrency), account.BalanceCurrency)); AccountInfo.Add(new KeyValuePair <string, object>(nameof(account.Equity), account.Equity)); AccountInfo.Add(new KeyValuePair <string, object>(nameof(account.Margin), account.Margin)); AccountInfo.Add(new KeyValuePair <string, object>(nameof(account.MarginLevel), account.MarginLevel)); AccountInfo.Add(new KeyValuePair <string, object>(nameof(account.MarginCallLevel), account.MarginCallLevel)); AccountInfo.Add(new KeyValuePair <string, object>(nameof(account.StopOutLevel), account.StopOutLevel)); IsAccountCash = account.AccountingType == TTAccountingTypes.Cash; IsAccountNet = account.AccountingType == TTAccountingTypes.Net; }
public static void GetAccount(TickTraderWebClient client) { // Account info TTAccount account = client.GetAccount(); Console.WriteLine("Account Id: {0}", account.Id); Console.WriteLine("Account name: {0}", account.Name); Console.WriteLine("Account group: {0}", account.Group); }
private void RefreshTables() { // Refresh account _account = WebClient.GetAccount(); // Refresh symbols table _symbols = WebClient.GetAllSymbols().ToDictionary(s => s.Symbol); // Refresh feed ticks table _ticks = WebClient.GetAllTicks().ToDictionary(t => t.Symbol); }
public static void GetPositions(TickTraderWebClient client) { // Account positions TTAccount account = client.GetAccount(); if (account.AccountingType == TTAccountingTypes.Net) { List <TTPosition> positions = client.GetAllPositions(); foreach (var p in positions) { Console.WriteLine("{0} position: {1} {2}", p.Symbol, p.LongAmount, p.ShortAmount); } } }
public static void GetAssets(TickTraderWebClient client) { // Account assets TTAccount account = client.GetAccount(); if (account.AccountingType == TTAccountingTypes.Cash) { List <TTAsset> assets = client.GetAllAssets(); foreach (var a in assets) { Console.WriteLine("{0} asset: {1}", a.Currency, a.Amount); } } }