public async Task <bool> Request_all_symbols(FTClient client) { try { if (isRequestedSymbols) { return(true); } if (client == null) { return(false); } isRequestedSymbols = true; foreach (var plate in plates) { List <Contract> contracts = await client.RequestSymbols(plate); FillInSymbols(contracts); } return(true); } catch (Exception e) { return(false); } }
public async Task <bool> Request_all_symbols() { try { if (isRequestedSymbols) { return(true); } FTClient client = null; foreach (var ctrl in Controllers) { if (ctrl.ConnectionStatus.IsQotConnected) { client = ((FTController)ctrl).Client; } } if (client == null) { return(false); } foreach (var plate in plates) { List <Contract> contracts = await client.RequestSymbols(plate); FillInSymbols(contracts); } isRequestedSymbols = true; return(true); } catch (Exception e) { return(false); } }
private void Init() { Client = new FTClient(ConnParam.Host, ConnParam.Port); Client.QotConnCallback.InitConnected += QotConnCallback_InitConnected; Client.QotConnCallback.Disconnected += QotConnCallback_Disconnected; Client.TrdConnCallback.InitConnected += TrdConnCallback_InitConnected; Client.TrdConnCallback.Disconnected += TrdConnCallback_Disconnected; Client.TrdCallback.UnlockTrade += TrdCallback_UnlockTrade; }
public APIRestrictionParallel(FTClient client, Limitation lmt, Func <TRequest, Task <bool> > reqFunc, Func <Task <int> > getQuota = null) { this.client = client; limitation = lmt; GetQuota = getQuota; ReqFunc = reqFunc; reqQueue.CollectionChanged += ReqQueue_CollectionChanged; Start(); }
public string GetDocument(string serverIP, string documentName) { // make sure we have valid parameters // serverIP is the FT Server's IP address // documentName is the name of a directory on the FT Server // both should not be empty if (String.IsNullOrWhiteSpace(serverIP) || String.IsNullOrWhiteSpace(documentName)) { throw new Exception("Empty server IP or document Name!"); } // contact the PRS and lookup port for "FT Server" PRSClient prs = new PRSClient(prsIP, prsPort, "FT Server"); ushort ftPort = prs.LookupPort(); // connect to FT server by ipAddr and port FTClient ft = new FTClient(serverIP, ftPort); ft.Connect(); // get the files from the requested directory FTClient.FileContent[] files = ft.GetDirectory(documentName); // accumulate file contents in a result string StringBuilder builder = new StringBuilder(); foreach (FTClient.FileContent file in files) { // name, content and empty line for each file builder.AppendLine(file.Name); builder.AppendLine(file.Content); builder.AppendLine(); } // disconnect from server ft.Disconnect(); // return the content return(builder.ToString()); }
private async Task <bool> Scan(Quote item) { try { if (item.LastDate < DateTime.Now.AddDays(-10) || item.IsDirty) { ObservableCollection <OHLCBar> bars = KLines[item.Security]; FTClient client = null; // search in the quota foreach (var quota in HistoryQuota) { var tmp = quota.Value.DetailItems.FirstOrDefault(x => x.Security == item.Security); if (tmp != null) { client = ((FTController)quota.Key).Client; break; } } if (client == null) { foreach (var quota in HistoryQuota) { if (quota.Value.RemainQuota > 0) { client = ((FTController)quota.Key).Client; } } } if (client == null) { throw new OutOfQuotaException(); } // request history data client.RequestHistoryData(item.Security, DateTime.Now.AddDays(-5), DateTime.Now, QotCommon.KLType.KLType_Day); // request latest KLines List <QotCommon.KLine> kLines = await client.GetKL(item.Security, FTUtil.IntToKLType(Interval)); var quote = List.FirstOrDefault(x => item.Security == x.Security); foreach (var line in kLines) { DateTime time = DateTime.ParseExact(line.Time, dtFormat, CultureInfo.InvariantCulture); if (time > GetBarTime(DateTime.Now)) { break; } if (time.Date == DateTime.Now.Date) { bars.Add(new OHLCBar { Security = item.Security, Open = line.OpenPrice, High = line.HighPrice, Low = line.LowPrice, Close = line.ClosePrice, Volume = line.Volume, Time = GetBarTime(time) }); if (quote.DayHigh < line.HighPrice) { quote.DayHigh = line.HighPrice; } } } //client.RequestMarketData(item.Security, FTUtil.IntToSubType(Interval)); //client.RequestMarketData(item.Security, QotCommon.SubType.SubType_Ticker); } return(true); } catch (Exception e) { throw e; } }
public QotCallback(FTClient client) { ftClient = client; }
public ConnCallback(FTClient client) { ftClient = client; }
public CPlaceOrder(FTClient client, Limitation lmt, Func <QotRequestHistoryKL.Request, Task <bool> > reqFunc, Func <Task <int> > getQuota) : base(client, lmt, reqFunc, getQuota) { }