Esempio n. 1
0
        public Market(IOptionModel model)
        {
            this.model = model;
            Board      = new Dictionary <string, MarketItem>();

            var mr  = new MarketRecordReader();
            var mrr = mr.Read();

            foreach (var v in model.Contracts.Where(a => a.IsDel == false))
            {
                var vr = mrr.Where(a => a.ContractId == v.Id).FirstOrDefault();
                if (vr == null)
                {
                    if (!Board.ContainsKey(v.Name))
                    {
                        Board.Add(v.Name, new MarketItem(v));
                    }
                }
                else
                {
                    if (!Board.ContainsKey(v.Name))
                    {
                        Board.Add(v.Name, new MarketItem(vr, v));
                    }
                }
            }
            deals      = new MarketDeals(model);
            mrs        = new MarketRecordSaver();
            t          = new Timer();
            t.Interval = 30 * 1000;
            t.Elapsed += t_Elapsed;
            t.Start();
        }
Esempio n. 2
0
        public SpotService(IOptionModel om)
        {
            isStop    = Com.BitsQuan.Miscellaneous.AppSettings.Read <bool>("isDisableBtcTrade", true);
            model     = new SpotModel(om);
            pre       = new SpotPre();
            post      = new SpotPost();
            Market    = new SpotMarket();
            match     = new SpotMatch(model);
            creator   = new SpotOrderCreator(model);
            KlinePool = new KlineDataPool(
                new Func <int, Contract>((i) => {
                return(new Contract {
                    Code = "-2", Name = "BTC"
                });
            }));
            KlineDataPoolInitor.InitSpot(KlinePool);
            ohlcGen = new OhlcGenarator();
            OhlcMaker.OnOhlcMaked += OhlcMaker_OnOhlcMaked;

            match.OnDeal   += match_OnDeal;
            match.OnFinish += match_OnFinish;
            foreach (var v in model.SpotOrders.ToList())
            {
                match.Match(v);
            }
            var qc = om.Coins.Where(a => a.Name.ToLower() == "btc").FirstOrDefault();

            DeepPool = new DeepDataPool3(match.Container.Get(qc));
            SetMaxId();
        }
Esempio n. 3
0
 public OrderSvcImp(IOptionModel Model,
                    OrderPreHandler preHandler,
                    OrderPostHandler postHandler,
                    OrderMatcher Matcher,
                    TextLog log,
                    Func <Order, bool> IsAcceptByFuse)
 {
     this.Model   = Model; this.preHandler = preHandler; this.postHandler = postHandler;
     this.Matcher = Matcher; this.log = log; this.IsAcceptByFuse = IsAcceptByFuse;
 }
Esempio n. 4
0
        public SpotModel(IOptionModel model)
        {
            this.Model = model;
            SpotOrders = new List <SpotOrder>();
            sds        = new SpotDealSaver();
            sos        = new SpotOrderSaver();
            tos        = new TempSpotOrderSaver();

            RestoreOrders();
        }
Esempio n. 5
0
        public KlineSvc(IOptionModel Model)
        {
            this.Model = Model;

            ohlcGen   = new OhlcGenarator();
            ohlcSaver = new OhlcSaver();
            kdp       = new KlineDataPool((cid) =>
            {
                return(Model.Contracts.Where(a => a.Id == cid && a.IsDel == false).FirstOrDefault());
            });
        }
Esempio n. 6
0
        public Blaster(IMatch match, Market m, IOptionModel model)
        {
            this.Market  = m;
            this.matcher = match;
            this.model   = model;
            this.fehc    = new ReorderCollection(this.matcher);

            this.sellor = new BlastSellor(this.positionType, Log, CreateSellOrder, RaiseSell, match);

            this.executor = new BlastExecutor(this.Market, this.CreateRecord,
                                              this.OnBlasting, this.OnBlasted, this.positionType, Log, sellor, CalRatio, fehc, (s) => model.Contracts.Where(a => a.Code == s).FirstOrDefault());
        }
Esempio n. 7
0
        public OrderMonitor(IMatch matcher, Market m, IOptionModel model)
        {
            this.traders = model.Traders;
            this.m       = m;
            prepare      = new BlasterPrePare(matcher, m);
            dutyBlaster  = new DutyBlaster(matcher, m, model);
            rightBlaster = new RightBlaster(matcher, m, model);

            watcher               = new Watcher(Monitor, Clear);
            monitorTimer          = new System.Timers.Timer();
            monitorTimer.Interval = 5 * 1000;
            monitorTimer.Elapsed += monitorTimer_Elapsed;
        }
Esempio n. 8
0
 ////public ProductModel(ITypeModel typeModel, IAlternateIdModel alternateIdModel, IKitModel kitModel, ICustomFieldModel customFieldModel, IOptionModel optionModel, IUnitModel unitModel, IInventoryModel inventoryModel, IExternalIdModel externalIdModel, IVariantModel variantModel, IWebhookModel webHookModel, IBaseContextModel contextModel, ICategoryAssignmentModel categoryAssignmentModel)
 public ProductModel(ICustomFieldModel customFieldModel, ITypeModel typeModel, IAlternateIdModel alternateIdModel, IKitModel kitModel, IOptionModel optionModel, IUnitModel unitModel, IInventoryModel inventoryModel, IExternalIdModel externalIdModel, IVariantModel variantModel, IWebhookModel webHookModel, IBaseContextModel contextModel, ICategoryAssignmentModel categoryAssignmentModel, IOptions <Sheev.Common.Models.MongoDbSetting> mongoDbSettings, IOptions <Sheev.Common.Models.ApiUrlSetting> apiSettings)
 {
     _categoryAssignmentModel = categoryAssignmentModel;
     _webHookModel            = webHookModel;
     context = new Models.ContextModel(mongoDbSettings, apiSettings);
     ////context = contextModel;
     _variantModel     = variantModel;
     _externalIdModel  = externalIdModel;
     _inventoryModel   = inventoryModel;
     _unitModel        = unitModel;
     _optionModel      = optionModel;
     _customFieldModel = customFieldModel;
     _kitModel         = kitModel;
     _alternateIdModel = alternateIdModel;
     _typeModel        = typeModel;
 }
Esempio n. 9
0
 public EntitySvcImp(IOptionModel Model)
 {
     this.Model = Model;
 }
Esempio n. 10
0
 public DeepDataPool2(IOptionModel model,
                      IMatcherDataContainer container)
 {
     this.model     = model;
     this.container = container;
 }
Esempio n. 11
0
 public RightBlaster(IMatch match, Market m, IOptionModel model)
     : base(match, m, model)
 {
 }
Esempio n. 12
0
 public MarketDeals(IOptionModel model)
 {
     this.model = model;
     dic        = new Dictionary <string, List <Deal> >();
 }
Esempio n. 13
0
 public static Contract GetContract(this PositionSummary p, IOptionModel model)
 {
     return(model.Contracts.Where(a => a.Code == p.CCode).FirstOrDefault());
 }