Example #1
0
        public override void DoWork(OverridedQ[] item)
        {
            QuotationBulk bulk = new QuotationBulk(item);

            TradingSetting.Default.DoParallelForAccounts(a => a.UpdateQuotation(bulk));
            TradingSetting.Default.DoParallelForAccounts(a => a.Hit(bulk));
            MarketManager.Default.UpdateQuotation(bulk);
            PriceAlert.Manager.Default.SetQuotation(item);
        }
Example #2
0
 internal void SetQuotation(QuotationBulk quotationBulk)
 {
     lock (_mutex)
     {
         Parallel.ForEach(_accounts.Values, account =>
         {
             account.UpdateQuotation(quotationBulk);
         });
     }
 }
Example #3
0
        internal AccountClass.Instrument CreateInstrument(Account owner, Guid id, QuotationBulk initQuotation)
        {
            var settingInstrument = Settings.Setting.Default.GetInstrument(id);

            if (settingInstrument.Category == iExchange.Common.InstrumentCategory.Physical)
            {
                return(_physicalServiceFactory.Value.CreateInstrument(owner, id, initQuotation));
            }
            else
            {
                return(_generalServiceFactory.Value.CreateInstrument(owner, id, initQuotation));
            }
        }
 public void UpdateQuotation(QuotationBulk quotationBulk)
 {
     lock (_mutex)
     {
         foreach (var eachInstrument in _instruments.Values)
         {
             QuotePolicy2QuotationDict dict;
             if (quotationBulk.TryGetValue(eachInstrument.Id, out dict))
             {
                 eachInstrument.UpdateQuotation(quotationBulk);
             }
         }
     }
 }
Example #5
0
            internal bool UpdateQuotationAndCheckIsRiskRised(QuotationBulk bulk, Quotation quotation, DateTime baseTime)
            {
                Quotation lastQuotation = this.GetQuotation(_account);

                _bulk = bulk;
                if (lastQuotation != null)
                {
                    QuotationTrend trend = quotation.CalculateTrend(lastQuotation);
                    if ((_instrument.TotalBuyQuantity > _instrument.TotalSellQuantity && trend == QuotationTrend.Down) ||
                        (_instrument.TotalSellQuantity > _instrument.TotalBuyQuantity && trend == QuotationTrend.Up))
                    {
                        return(true);
                    }
                    return(false);
                }
                return(true);
            }
Example #6
0
        internal void HitOrders(Agent.AccountClass.Instrument instrument, QuotationBulk bulk)
        {
            foreach (var eachOrder in instrument.WaitingForHitOrders)
            {
                Quotation quotation;
                if (bulk.TryGetQuotation(instrument.Id, eachOrder.Owner.SubmitorQuotePolicyProvider, out quotation))
                {
                    this.HitPlacedOrder(eachOrder, quotation);
                }
            }

            foreach (Order eachOrder in instrument.ExecutedAndHasPositionOrders)
            {
                Quotation quotation;
                if (bulk.TryGetQuotation(instrument.Id, _account, out quotation))
                {
                    this.HitExecutedOrder(eachOrder, quotation);
                }
            }
        }
Example #7
0
 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);
 }
Example #8
0
 internal bool UpdateQuotationAndCheckIsRiskRised(QuotationBulk bulk, Quotation quotation, DateTime baseTime)
 {
     return(_quotationManager.UpdateQuotationAndCheckIsRiskRised(bulk, quotation, baseTime));
 }
Example #9
0
 internal QuotationManager(Account account, Instrument instrument, QuotationBulk bulk)
 {
     _account    = account;
     _instrument = instrument;
     _bulk       = bulk;
 }
 internal override Instrument CreateInstrument(Account owner, Guid id, QuotationBulk initQuotation)
 {
     return(new PhysicalInstrument(owner, id, initQuotation, this));
 }
 internal abstract Instrument CreateInstrument(Account owner, Guid id, QuotationBulk initQuotation);
Example #12
0
 internal PhysicalInstrument(Account owner, Guid id, QuotationBulk initQuotation, InstrumentServiceFactory factory)
     : base(owner, id, initQuotation, factory)
 {
     _physicalLotCalculator        = this.LotCalculator as PhysicalLotCalculator;
     _physicalInstrumentCalculator = this.Calculator as PhysicalInstrumentCalculator;
 }
Example #13
0
 public void UpdateQuotation(QuotationBulk bulk)
 {
     _bulk = bulk;
 }