private void OnRspQryTradingAccount_callback(object sender, ref AccountField account, int size1, bool bIsLast) { if (null != OnRspQryTradingAccount) { OnRspQryTradingAccount(this, new OnRspQryTradingAccountEventArgs(ref account, size1, bIsLast)); } }
private string AccountMsg_Long(AccountField current, AccountField last) { double risk = current.CurrMargin * 100.0 / current.Balance; double balance_1 = (current.Balance - current.Deposit + current.Withdraw) - current.PreBalance; double balance_2 = current.Balance - last.Balance; string str = $"{risk:F2}%/{current.PositionProfit:F0}/{balance_1:F0}/{balance_2:F0}" + $"\n{current.CloseProfit:F0}/{current.Commission:F0}/{current.Available:F0}" + $"\n风险度/持仓盈亏/日间权益差/区间权益差" + $"\n平仓盈亏/手续费/可用资金\n" + $"\n{current.Withdraw:F0}/{current.Deposit:F0}" + $"\n出/入金" + $"\n" + $"\n{current.Balance:F0}-*+*-{current.PreBalance:F0}=*" + $"\n(动态权益-入金+出金)-昨结权益=日间权益差" + $"\n动态权益-上期动态权益=区间权益差" + $"\n" + $"\n{current.CurrMargin:F0}/*=*" + $"\n占用保证金/动态权益=风险度" + $"\n" + $"\n>>AccountID:{current.AccountID}<<" + $"\n>>{DateTime.Now.ToLongTimeString()}<<"; return(str); }
private List <string> MergeAccounts(SortedDictionary <string, AccountField> dict_curr, SortedDictionary <string, AccountField> dict_last) { var list = new List <string>(); // 交集 { var keys = dict_curr.Keys.Intersect(dict_last.Keys); foreach (var key in keys) { var curr = dict_curr[key]; var last = dict_last[key]; list.Add(AccountMsg_Long(curr, last)); } } // 差集,表示新增 { var keys = dict_curr.Keys.Except(dict_last.Keys); foreach (var key in keys) { var curr = dict_curr[key]; var last = new AccountField(); list.Add(AccountMsg_Long(curr, last)); } } return(list); }
private void XApi_OnRspQryTradingAccount(object sender, ref AccountField account, int size1, bool bIsLast) { if (onReturnAccount != null) { AccountInfo accountInfo = StructTransfer.TransferAccountInfo(account); onReturnAccount(this, ref accountInfo); } }
internal void OnMessage(AccountField data) { if (data != null) { _convertor.ProcessAccount(data); Logger.Info(data.DebugInfo()); } }
internal void OnMessage(AccountField data, bool isLast) { if (data != null) { _convertor.ProcessAccount(data, isLast); logger.Info(data.DebugInfo()); } }
internal void OnMessage(AccountField data) { if (data != null) { _convertor.ProcessAccount(data); Logger.Info(data.DebugInfo()); } _timer.EnableQueryPosition = true; }
private void OnRspQryTradingAccount_callback(object sender, ref AccountField account, int size1, bool bIsLast) { if (size1 <= 0) { (sender as XApi).GetLog().Info("OnRspQryTradingAccount"); } else { if (IsLogOnRspQryTradingAccount) { (sender as XApi).GetLog().Info("OnRspQryTradingAccount:" + account.ToFormattedString()); } } // 由策略来收回报 if (OnRspQryTradingAccount != null) { OnRspQryTradingAccount(sender, ref account, size1, bIsLast); } if (size1 <= 0) { return; } if (!IsConnected) { return; } string currency = "CNY"; AccountData ad = new AccountData(DateTime.Now, AccountDataType.AccountValue, account.AccountID, this.id, this.id); Type type = typeof(AccountField); FieldInfo[] fields = type.GetFields(BindingFlags.Public | BindingFlags.Instance); foreach (FieldInfo field in fields) { ad.Fields.Add(field.Name, currency, field.GetValue(account)); } // 将对像完全设置进去,等着取出 ad.Fields.Add(AccountDataFieldEx.USER_DATA, currency, account); ad.Fields.Add(AccountDataFieldEx.DATE, currency, GetDate(DateTime.Today)); try { EmitAccountData(ad); } catch (Exception ex) { (sender as XApi).GetLog().Error(ex); } }
private void _OnRspQryTradingAccount(IntPtr ptr1, int size1, double double1) { if (OnRspQryTradingAccount_ == null) { return; } AccountField obj = PInvokeUtility.GetObjectFromIntPtr <AccountField>(ptr1); OnRspQryTradingAccount_(this, ref obj, size1, double1 != 0); }
public void ProcessAccount(AccountField account) { var data = new AccountData(DateTime.Now, AccountDataType.AccountValue, account.AccountID, _provider.Id, _provider.Id); foreach (var field in AccountFields) { data.Fields.Add(field.Name, field.GetValue(account)); } data.Fields.Add(QBHelper.UserDataName, account); _provider.ProcessAccount(data); }
internal bool SignUp(string username, string password) { if (database.ContainsKey(username)) { return(false); } var account = new AccountField(password, false); database.Add(username, account); this.Save(); return(true); }
internal void Load() { var accounts = XDocument.Load("accounts.xml"); database = new Dictionary<string, AccountField>(); foreach (var account in accounts.Descendants("account")) { var key = account.Attribute("name").Value; var value = new AccountField(null, false); value.password = account.Attribute("password").Value; value.isLoggedIn = false; database.Add(key, value); } }
internal void Load() { var accounts = XDocument.Load("accounts.xml"); database = new Dictionary <string, AccountField>(); foreach (var account in accounts.Descendants("account")) { var key = account.Attribute("name").Value; var value = new AccountField(null, false); value.password = account.Attribute("password").Value; value.isLoggedIn = false; database.Add(key, value); } }
private void OnRspQryTradingAccount_callback(object sender, [In] ref AccountField account, int size1, bool bIsLast) { if (null == OnRspQryTradingAccount) { return; } AccountField field = account; AccountClass cls = new AccountClass(); cls.ClientID = field.ClientID; cls.AccountID = field.AccountID; cls.CurrencyID = field.CurrencyID; cls.PreBalance = field.PreBalance; cls.CurrMargin = field.CurrMargin; cls.CloseProfit = field.CloseProfit; cls.PositionProfit = field.PositionProfit; cls.Balance = field.Balance; cls.Available = field.Available; cls.Deposit = field.Deposit; cls.Withdraw = field.Withdraw; cls.WithdrawQuota = field.WithdrawQuota; cls.FrozenTransferFee = field.FrozenTransferFee; cls.FrozenStampTax = field.FrozenStampTax; cls.FrozenCommission = field.FrozenCommission; cls.FrozenCash = field.FrozenCash; cls.StampTax = field.StampTax; cls.Commission = field.Commission; cls.CashIn = field.CashIn; if (null == OnRspQryTradingAccount) { QueueData qd = new QueueData(); qd.Type = (int)ResponseType.OnRspQryTradingAccount; qd.Type_String = Enum <XAPI.ResponseType> .ToString(ResponseType.OnRspQryTradingAccount); qd.Sender = this; qd.Data1 = cls; qd.Data2 = size1; qd.Data3 = bIsLast; MessageQueue.Enqueue(qd); } else { OnRspQryTradingAccount(this, cls, size1, bIsLast); } }
private string AccountMsg_Short(AccountField current, AccountField last) { double risk = current.CurrMargin * 100.0 / current.Balance; double balance_1 = (current.Balance - current.Deposit + current.Withdraw) - current.PreBalance; double balance_2 = current.Balance - last.Balance; string str = ""; str += string.Format("{0:F2}%/{1:F0}/{2:F0}/{3:F0}", risk, current.PositionProfit, balance_1, balance_2); str += string.Format("\n{0:F0}/{1:F0}/{2:F0}", current.CloseProfit, current.Commission, current.Available); str += string.Format("\n{0:F0}", current.Balance); str += string.Format("\n风险度/持仓盈亏/日间权益差/区间权益差"); str += string.Format("\n平仓盈亏/手续费/可用资金"); str += string.Format("\n动态权益"); str += string.Format("\n>>AccountID:{0}<<", current.AccountID); return(str); }
public OnRspQryTradingAccountEventArgs(ref AccountField account, int size1, bool bIsLast) { this.account = account; this.size1 = size1; this.bIsLast = bIsLast; }
/// <summary> /// The order by field account. /// </summary> /// <param name="entity"> /// The entity. /// </param> /// <param name="order"> /// The order. /// </param> /// <param name="orderByProperty"> /// The order by property. /// </param> /// <returns> /// The <see cref="IQueryable"/>. /// </returns> public static IQueryable <AccountEntity> OrderByFieldAccount(this IQueryable <AccountEntity> entity, SortOrder order, AccountField orderByProperty) { switch (order) { case SortOrder.Ascending: switch (orderByProperty) { case AccountField.Description: entity = entity.OrderBy(x => x.Description); break; default: entity = entity.OrderBy(x => x.CreatedAt); break; } break; case SortOrder.Descending: switch (orderByProperty) { case AccountField.Description: entity = entity.OrderByDescending(x => x.Description); break; default: entity = entity.OrderByDescending(x => x.CreatedAt); break; } break; } return(entity); }
internal bool SignUp(string username, string password) { if (database.ContainsKey(username)) { return false; } var account = new AccountField(password, false); database.Add(username, account); this.Save(); return true; }
protected virtual void OnRspQryAccount(object sender, AccountField account, bool isLast) { Provider.OnMessage(account); }
private void OnRspQryTradingAccount_callback(object sender, ref AccountField account, int size1, bool bIsLast) { if (null == OnRspQryTradingAccount) return; AccountField field = account; AccountClass cls = new AccountClass(); cls.ClientID = field.ClientID; cls.AccountID = field.AccountID; cls.CurrencyID = field.CurrencyID; cls.PreBalance = field.PreBalance; cls.CurrMargin = field.CurrMargin; cls.CloseProfit = field.CloseProfit; cls.PositionProfit = field.PositionProfit; cls.Balance = field.Balance; cls.Available = field.Available; cls.Deposit = field.Deposit; cls.Withdraw = field.Withdraw; cls.WithdrawQuota = field.WithdrawQuota; cls.FrozenTransferFee = field.FrozenTransferFee; cls.FrozenStampTax = field.FrozenStampTax; cls.FrozenCommission = field.FrozenCommission; cls.FrozenCash = field.FrozenCash; cls.StampTax = field.StampTax; cls.Commission = field.Commission; cls.CashIn = field.CashIn; if (null == OnRspQryTradingAccount) { QueueData qd = new QueueData(); qd.Type = (int)ResponeType.OnRspQryTradingAccount; qd.Type_String = Enum<XAPI.ResponeType>.ToString(ResponeType.OnRspQryTradingAccount); qd.Sender = this; qd.Data1 = cls; qd.Data2 = size1; qd.Data3 = bIsLast; MessageQueue.Enqueue(qd); } else { OnRspQryTradingAccount(this, ref cls, size1, bIsLast); } }