internal RiskData(BusinessRecord parent) { this._necessary = BusinessItemFactory.Create("Necessary", 0m, PermissionFeature.Sound, parent); this._netNecessary = BusinessItemFactory.Create("NetNecessary", 0m, PermissionFeature.Dumb, parent); this._hedgeNecessary = BusinessItemFactory.Create("HedgeNecessary", 0m, PermissionFeature.Dumb, parent); this._minEquityAvoidRiskLevel1 = BusinessItemFactory.Create("MinEquityAvoidRiskLevel1", 0m, PermissionFeature.Dumb, parent); this._minEquityAvoidRiskLevel2 = BusinessItemFactory.Create("MinEquityAvoidRiskLevel2", 0m, PermissionFeature.Dumb, parent); this._minEquityAvoidRiskLevel3 = BusinessItemFactory.Create("MinEquityAvoidRiskLevel3", 0m, PermissionFeature.Dumb, parent); this._necessaryFillingOpenOrder = BusinessItemFactory.Create("NecessaryFillingOpenOrder", 0m, PermissionFeature.Dumb, parent); this._necessaryFillingCloseOrder = BusinessItemFactory.Create("NecessaryFillingCloseOrder", 0m, PermissionFeature.Dumb, parent); this._tradePLFloat = BusinessItemFactory.Create("TradePLFloat", 0m, PermissionFeature.Dumb, parent); this._interestPLFloat = BusinessItemFactory.Create("InterestPLFloat", 0m, PermissionFeature.Dumb, parent); this._storagePLFloat = BusinessItemFactory.Create("StoragePLFloat", 0m, PermissionFeature.Dumb, parent); this._valueAsMargin = BusinessItemFactory.Create("ValueAsMargin", 0m, PermissionFeature.Dumb, parent); this._tradePLNotValued = BusinessItemFactory.Create("TradePLNotValued", 0m, PermissionFeature.Dumb, parent); this._interestPLNotValued = BusinessItemFactory.Create("InterestPLNotValued", 0m, PermissionFeature.Dumb, parent); this._storagePLNotValued = BusinessItemFactory.Create("StoragePLNotValued", 0m, PermissionFeature.Dumb, parent); this._lockOrderTradePLFloat = BusinessItemFactory.Create("LockOrderTradePLFloat", 0m, PermissionFeature.Dumb, parent); this._feeForCutting = BusinessItemFactory.Create("FeeForCutting", 0m, PermissionFeature.Dumb, parent); this._riskCredit = BusinessItemFactory.Create("RiskCredit", 0m, PermissionFeature.Dumb, parent); _partialPaymentPhysicalNecessary = BusinessItemFactory.Create("PartialPaymentPhysicalNecessary", 0m, PermissionFeature.Dumb, parent); _totalPaidAmount = BusinessItemFactory.Create("TotalPaidAmount", 0m, PermissionFeature.Dumb, parent); _credit = BusinessItemFactory.Create("Credit", 0m, PermissionFeature.Dumb, parent); _shortMargin = BusinessItemFactory.Create("ShortMargin", 0m, PermissionFeature.Dumb, parent); }
internal FakeAccount(Guid id, string code) : base("Account", 10) { _trans = new BusinessRecordDictionary <Guid, FakeTransaction>("Transactions", this); _id = BusinessItemFactory.Create("Id", id, PermissionFeature.Key, this); _code = BusinessItemFactory.Create("Code", code, PermissionFeature.ReadOnly, this); }
internal OrderResetItem(Guid id, bool isBuy) : base("Order", 5) { _isBuy = BusinessItemFactory.Create("IsBuy", isBuy, PermissionFeature.ReadOnly, this); _id = BusinessItemFactory.Create("ID", id, PermissionFeature.Key, this); _bills = new BusinessRecordList <ResetBill>("Bills", this, 10); }
internal ResetBalance(DateTime tradeDay, Guid accountId, Guid currencyId, decimal value) : base("Balance", 3) { _tradeDay = BusinessItemFactory.Create("TradeDay", tradeDay, PermissionFeature.Key, this); _value = BusinessItemFactory.Create("Value", value, PermissionFeature.Sound, this); _currencyId = BusinessItemFactory.Create("CurrencyID", currencyId, PermissionFeature.Key, this); _accountId = BusinessItemFactory.Create("AccountID", accountId, PermissionFeature.Key, this); }
internal DeliveryRequestSpecification(DeliveryRequest owner, Protocal.Physical.DeliveryRequestSpecificationData specification) : base("DeliveryRequestSpecification", 2) { owner.AddDeliveryRequestSpecification(this, OperationType.AsNewRecord); _quantity = BusinessItemFactory.Create("Quantity", specification.Quantity, PermissionFeature.ReadOnly, this); _size = BusinessItemFactory.Create("Size", specification.Size, PermissionFeature.ReadOnly, this); _unitId = BusinessItemFactory.Create("UnitId", specification.UnitId, PermissionFeature.ReadOnly, this); }
internal FundContent(BusinessRecord parent, decimal?balance, decimal?frozenFund, Account account) { _totalDeposit = BusinessItemFactory.Create("TotalDeposit", 0m, PermissionFeature.Sound, parent); _balance = BusinessItemFactory.Create(FundBusinessItemNames.Balance, balance, PermissionFeature.Sound, parent); _frozenFund = BusinessItemFactory.Create(FundBusinessItemNames.FrozenFund, frozenFund, PermissionFeature.Sound, parent); this._riskRawData = new RiskData(parent); _account = account; }
internal OrderFloating(Order order, CalculateParams calculateParams) { _owner = order; _calculateParams = calculateParams; _interestPLFloat = BusinessItemFactory.Create("InterestPLFloat", 0m, PermissionFeature.Dumb, order); _storagePLFloat = BusinessItemFactory.Create("StoragePLFloat", 0m, PermissionFeature.Dumb, order); _tradePLFloat = BusinessItemFactory.Create("TradePLFloat", 0m, PermissionFeature.Dumb, order); _livePrice = BusinessItemFactory.Create("LivePrice", (Price)null, PermissionFeature.Dumb, order); }
internal FakeTransaction(Guid id, string code, FakeAccount parent, OperationType type = OperationType.None) : base("Transaction", 5) { _id = BusinessItemFactory.Create("Id", id, PermissionFeature.Key, this); _code = BusinessItemFactory.Create("Code", code, PermissionFeature.ReadOnly, this); _updateTime = BusinessItemFactory.Create("UpdateTime", DateTime.Now, PermissionFeature.Sound, this); _orders = new BusinessRecordList <FakeOrder>("Orders", this); parent.AddTran(this, type); }
internal ResetBill(Guid orderId, decimal value, ResetBillType type, DateTime tradeDay) : base("Bill", 20) { _id = BusinessItemFactory.Create("ID", Guid.NewGuid(), PermissionFeature.Key, this); _value = BusinessItemFactory.Create("Value", value, PermissionFeature.Sound, this); _tradeDay = BusinessItemFactory.Create("TradeDay", tradeDay, PermissionFeature.ReadOnly, this); _type = BusinessItemFactory.Create("Type", type, PermissionFeature.ReadOnly, this); _updateTime = BusinessItemFactory.Create("UpdateTime", DateTime.Now, PermissionFeature.ReadOnly, this); _orderId = BusinessItemFactory.Create("OrderID", orderId, PermissionFeature.Key, this); }
internal FakeOrder(FakeTransaction tran, Guid id, string code, decimal lot, decimal lotBalance, OperationType type = OperationType.None) : base("Order", 5) { tran.AddOrder(this, type); _id = BusinessItemFactory.Create("Id", id, PermissionFeature.Key, this); _code = BusinessItemFactory.Create("Code", code, PermissionFeature.ReadOnly, this); _lot = BusinessItemFactory.Create("Lot", lot, PermissionFeature.ReadOnly, this); _lotBalance = BusinessItemFactory.Create("LotBalance", lotBalance, PermissionFeature.Sound, this); _phase = BusinessItemFactory.Create("Phase", OrderPhase.Placed, PermissionFeature.Sound, this); }
internal TradingBill(Guid id, Guid accountId, Guid currencyId, decimal value, TradingBillType type, DateTime updateTime) : base("TradingBill", 6) { _id = BusinessItemFactory.Create("ID", id, PermissionFeature.Key, this); _accountId = BusinessItemFactory.Create("AccountId", accountId, PermissionFeature.ReadOnly, this); _currencyId = BusinessItemFactory.Create("CurrencyId", currencyId, PermissionFeature.ReadOnly, this); _value = BusinessItemFactory.Create("Value", value, PermissionFeature.Sound, this); _updateTime = BusinessItemFactory.Create("updateTime", updateTime, PermissionFeature.Sound, this); _type = BusinessItemFactory.Create("Type", type, PermissionFeature.ReadOnly, this); }
public SubFund(Account account, Guid currencyId, decimal balance, decimal frozenFund, OperationType asAdded) : base(BusinessRecordNames.Fund, 10) { this._owner = account; this._currencyId = BusinessItemFactory.Create(FundBusinessItemNames.CurrencyId, currencyId, PermissionFeature.Key, this); _accountId = BusinessItemFactory.Create("AccountID", account.Id, PermissionFeature.Key, this); BusinessItemFactory.CreateVolatileItem("CurrencyCode", () => Settings.Setting.Default.GetCurrency(currencyId).Code, this); _equityItem = BusinessItemFactory.CreateVolatileItem("Equity", this.CalculateEquity, this); this.Initialize(balance, frozenFund, account); account.AddSubFund(this, asAdded); }
internal DeliveryRequestOrderRelation(DeliveryRequest request, Protocal.Physical.DeliveryRequestOrderRelationData orderRelationData) : base(BusinessRecordNames.DeliveryRequestOrderRelation, DEFAULT_ITEMS_FACTOR) { this._owner = request; var key = orderRelationData.OpenOrderId; this._deliveryRequestId = BusinessItemFactory.Create(DeliveryRequestRelationBusinessItemNames.DeliveryRequestId, request.Id, PermissionFeature.Key, this); this._openOrderId = BusinessItemFactory.Create(DeliveryRequestRelationBusinessItemNames.OpenOrderId, key, PermissionFeature.Key, this); this._deliveryQuantity = BusinessItemFactory.Create(DeliveryRequestRelationBusinessItemNames.DeliveryQuantity, orderRelationData.DeliveryQuantity, PermissionFeature.Dumb, this); this._deliveryLot = BusinessItemFactory.Create(DeliveryRequestRelationBusinessItemNames.DeliveryLot, orderRelationData.DeliveryLot, PermissionFeature.Dumb, this); request.AddDeliveryRequestOrderRelation(this, OperationType.AsNewRecord); }
internal DeliveryRequestOrderRelation(DeliveryRequest request, IDBRow dataRow) : base(BusinessRecordNames.DeliveryRequestOrderRelation, DEFAULT_ITEMS_FACTOR) { this._owner = request; var key = (Guid)dataRow["OpenOrderId"]; this._deliveryRequestId = BusinessItemFactory.Create(DeliveryRequestRelationBusinessItemNames.DeliveryRequestId, (Guid)dataRow["DeliveryRequestId"], PermissionFeature.Key, this); this._openOrderId = BusinessItemFactory.Create(DeliveryRequestRelationBusinessItemNames.OpenOrderId, key, PermissionFeature.Key, this); this._deliveryQuantity = BusinessItemFactory.Create(DeliveryRequestRelationBusinessItemNames.DeliveryQuantity, (decimal)dataRow["DeliveryQuantity"], PermissionFeature.Dumb, this); this._deliveryLot = BusinessItemFactory.Create(DeliveryRequestRelationBusinessItemNames.DeliveryLot, (decimal)dataRow["DeliveryLot"], PermissionFeature.Dumb, this); request.AddDeliveryRequestOrderRelation(this, OperationType.None); }
private void CreateBusinessItems(Guid orderId, int period, decimal principal, decimal interest, decimal debitInterest, DateTime?paymentDateTimeOnPlan, decimal interestRate, DateTime?paidDateTime, DateTime?updateTime, decimal?lotBalance, Guid?updatePersonId) { _orderId = BusinessItemFactory.Create("OrderId", orderId, PermissionFeature.Key, this); _period = BusinessItemFactory.Create("Period", period, PermissionFeature.Key, this); _principal = BusinessItemFactory.Create("Principal", principal, PermissionFeature.Sound, this); _interest = BusinessItemFactory.Create("Interest", interest, PermissionFeature.Sound, this); _debitInterest = BusinessItemFactory.Create("DebitInterest", debitInterest, PermissionFeature.Sound, this); _paymentDateTimeOnPlan = BusinessItemFactory.Create("PaymentDateTimeOnPlan", paymentDateTimeOnPlan, PermissionFeature.Sound, this); _paidDateTime = BusinessItemFactory.Create("PaidDateTime", paidDateTime, PermissionFeature.Sound, this); _updateTIme = BusinessItemFactory.Create("UpdateTime", updateTime ?? DateTime.Now, PermissionFeature.Sound, this); _interestRate = BusinessItemFactory.Create("InterestRate", interestRate, PermissionFeature.Sound, this); _lotBalance = BusinessItemFactory.Create("LotBalance", lotBalance, PermissionFeature.Sound, this); _updatePersonId = BusinessItemFactory.Create("UpdatePersonId", updatePersonId, PermissionFeature.Sound, this); }
private void Initialize(DateTime tradeDay, Guid accountId, Guid instrumentId, decimal balance, decimal floatingPL, decimal interestPLNotValued, decimal storagePLNotValued, decimal tradePLNotValued, decimal necessary) { _tradeDay = BusinessItemFactory.Create("TradeDay", tradeDay, PermissionFeature.Key, this); _accountId = BusinessItemFactory.Create("AccountID", accountId, PermissionFeature.Key, this); _instrumentId = BusinessItemFactory.Create("InstrumentID", instrumentId, PermissionFeature.Key, this); _resetBalance = BusinessItemFactory.Create("ResetBalance", balance, PermissionFeature.Sound, this); _floatingPL = BusinessItemFactory.Create("FloatingPL", floatingPL, PermissionFeature.Sound, this); _interestPLNotValued = BusinessItemFactory.Create("InterestPLNotValued", interestPLNotValued, PermissionFeature.Sound, this); _storagePLNotValued = BusinessItemFactory.Create("StoragePLNotValued", storagePLNotValued, PermissionFeature.Sound, this); _tradePLNotValued = BusinessItemFactory.Create("TradePLNotValued", tradePLNotValued, PermissionFeature.Sound, this); _necessary = BusinessItemFactory.Create("Necessary", necessary, PermissionFeature.Sound, this); _buyPrice = BusinessItemFactory.Create <Price>("BuyPrice", null, PermissionFeature.Sound, this); _sellPrice = BusinessItemFactory.Create <Price>("SellPrice", null, PermissionFeature.Sound, this); }
internal Instrument(Account owner, Guid id, QuotationBulk initQuotation, InstrumentServiceFactory factory) : base("Instrument", 15) { _owner = owner; this.Id = id; this.QuotationBulk = initQuotation; _orderCollector = new Lazy <OrderCollector>(() => factory.CreateOrderCollector(this)); _lotCalculator = new Lazy <LotCalculator>(() => factory.CreateLotCalculator(this)); _calculator = new Lazy <InstrumentCalculator>(() => factory.CreateInstrumentCalculator(this)); _riskRawData = new RiskData(null); _cuttingFee = new CuttingFee(this); _lastResetDay = BusinessItemFactory.Create <DateTime?>("LastResetDay", null, PermissionFeature.Sound, this); _id = BusinessItemFactory.Create("ID", id, PermissionFeature.Key, this); _accountId = BusinessItemFactory.Create("AccountID", owner.Id, PermissionFeature.Key, this); _resetItemHistoryDict = new BusinessRecordDictionary <DateTime, InstrumentResetItem>("ResetItemHistory", this); _currencyRate = this.DoGetCurrencyRate(null); _waitingForHitOrders = new CacheData <List <Order> >(_orderCollector.Value.CollectWaitingForHitOrders); _executedAndHasPositionOrders = new CacheData <List <Order> >(_orderCollector.Value.CollectExecutedAndHasPositionOrders); _totalBuyQuantity = new CacheData <decimal>(_lotCalculator.Value.CalculateBuyQuantity); _TotalSellQuantity = new CacheData <decimal>(_lotCalculator.Value.CalculateSellQuantity); _quotationManager = new QuotationManager(owner, this, initQuotation); }
internal Order(Transaction owner, OrderConstructParams constructParams, OrderServiceFactoryBase serviceFactory) : base(BusinessRecordNames.Order, ATTRIBUTE_ITEMS_CAPACITY) { this.ConstructParams = constructParams; this.ServiceFactory = serviceFactory; _pairOrderIsHit = false; this.IsHitReseted = false; _owner = owner; _orderSettings = serviceFactory.CreateOrderSettings(this, constructParams); if (owner != null) { owner.AddOrder(this, constructParams.OperationType); } _orderRelations = new BusinessRecordDictionary <Guid, OrderRelation>(BusinessRecordCollectionNames.OrderRelations, this, ORDER_RELATION_CAPACITY); _feeCalculator = new Lazy <OrderFeeCalculatorBase>(() => serviceFactory.CreateOrderFeeCalculator(this, _orderSettings)); _openOrderCalculator = new Lazy <OpenOrderCalculatorBase>(() => serviceFactory.CreateOpenOrderCalculator(this, _orderSettings)); _closeOrderCalculator = new Lazy <CloseOrderCalculator>(() => serviceFactory.CreateCloseOrderCalculator(this, _orderSettings)); _executeService = new Lazy <OrderExecuteServiceBase>(() => serviceFactory.CreateOrderExecuteService(this, _orderSettings)); _precheckServcie = new Lazy <OrderPreCheckServiceBase>(() => serviceFactory.CreatePreCheckService(this)); _valuedPLCalculator = new Lazy <ValuedPLCalculatorBase>(() => serviceFactory.CreateValuedPLCalculator(this)); _currencyId = BusinessItemFactory.Create("CurrencyID", owner.CurrencyId, PermissionFeature.ReadOnly, this); }
private void Initialize(DeliveryRequestConstructParams constructParams) { _id = BusinessItemFactory.Create(DeliveryRequestBusinessItemNames.Id, constructParams.Id, PermissionFeature.Key, this); _accountId = BusinessItemFactory.Create(DeliveryRequestBusinessItemNames.AccountId, constructParams.AccountId, PermissionFeature.ReadOnly, this); _instrumentId = BusinessItemFactory.Create(DeliveryRequestBusinessItemNames.InstrumentId, constructParams.InstrumentId, PermissionFeature.ReadOnly, this); _code = BusinessItemFactory.Create(DeliveryRequestBusinessItemNames.Code, constructParams.Code, PermissionFeature.ReadOnly, this); _printingCode = BusinessItemFactory.Create("PrintingCode", constructParams.PrintingCode, PermissionFeature.ReadOnly, this); _ask = BusinessItemFactory.Create(DeliveryRequestBusinessItemNames.Ask, constructParams.Ask, PermissionFeature.Sound, this); _bid = BusinessItemFactory.Create(DeliveryRequestBusinessItemNames.Bid, constructParams.Bid, PermissionFeature.Sound, this); _deliveryRequestStatus = BusinessItemFactory.Create(DeliveryRequestBusinessItemNames.Status, constructParams.DeliveryRequestStatus, PermissionFeature.Sound, this); _requireQuantity = BusinessItemFactory.Create(DeliveryRequestBusinessItemNames.RequireQuantity, constructParams.RequireQuantity, PermissionFeature.ReadOnly, this); _requireLot = BusinessItemFactory.Create(DeliveryRequestBusinessItemNames.RequireLot, constructParams.RequireLot, PermissionFeature.ReadOnly, this); _submitTime = BusinessItemFactory.Create(DeliveryRequestBusinessItemNames.SubmitTime, constructParams.SubmitTime, PermissionFeature.ReadOnly, this); _submitorId = BusinessItemFactory.Create("SubmitorId", constructParams.SubmitorId, PermissionFeature.ReadOnly, this); _deliveryTime = BusinessItemFactory.Create(DeliveryRequestBusinessItemNames.DeliveryTime, constructParams.DeliveryTime, PermissionFeature.Sound, this); _availableDeliveryTime = BusinessItemFactory.Create("AvailableDeliveryTime", (DateTime?)null, PermissionFeature.Sound, this); _charge = BusinessItemFactory.Create(DeliveryRequestBusinessItemNames.Charge, constructParams.Charge, PermissionFeature.Sound, this); _chargeCurrencyId = BusinessItemFactory.Create(DeliveryRequestBusinessItemNames.ChargeCurrencyId, constructParams.ChargeCurrencyId, PermissionFeature.Sound, this); _deliveryAddressId = BusinessItemFactory.Create(DeliveryRequestBusinessItemNames.DeliveryAddressId, constructParams.DeliveryAddressId, PermissionFeature.Sound, this); _deliveryRequestOrderRelations = new BusinessRecordDictionary <Guid, DeliveryRequestOrderRelation>(BusinessRecordCollectionNames.DeliveryRequestOrderRelations, this); _specifications = new BusinessRecordList <DeliveryRequestSpecification>("DeliveryRequestSpecifications", this, 2); }
internal Fund() : base("Fund", 2) { _balance = BusinessItemFactory.Create("Balance", 97103540.86m, PermissionFeature.Sound, this); }
internal BusinessItem <T> CreateSoundItem <T>(string name, BusinessRecord parent) { return(BusinessItemFactory.Create <T>(name, default(T), PermissionFeature.Sound, parent)); }
internal SystemResetter(Account account, InstrumentManager instrumentManager) { _account = account; _instrumentManager = instrumentManager; _lastResetDay = BusinessItemFactory.Create <DateTime?>("LastResetDay", null, PermissionFeature.Sound, account); }
internal PhysicalFloating(PhysicalOrder order, PhysicalCalculateParams calculateParams) : base(order, calculateParams) { _marketValue = BusinessItemFactory.Create("MarketValue", 0m, PermissionFeature.Dumb, order); _valueAsMargin = BusinessItemFactory.Create("ValueAsMargin", 0m, PermissionFeature.Dumb, order); }
internal CloseTradingBill(Guid id, Guid accountId, Guid currencyId, decimal value, TradingBillType type, DateTime updateTime, Guid closeOrderId, Guid openOrderId) : base(id, accountId, currencyId, value, type, updateTime) { _closeOrderId = BusinessItemFactory.Create("CloseOrderId", closeOrderId, PermissionFeature.ReadOnly, this); _openOrderId = BusinessItemFactory.Create("OpenOrderId", openOrderId, PermissionFeature.ReadOnly, this); }
internal Fund(Account account) { _owner = account; _content = new FundContent(account, null, null, account); _equityItem = BusinessItemFactory.CreateVolatileItem("Equity", this.CalculateEquity, account); }