public static OrderAgent GetUfxAgent(this ProviderManager manager)
        {
            var ufx   = GetUfx(manager);
            var agent = GetAgent(manager, OrderAgent.DefaultName);

            if (agent == null)
            {
                agent = new OrderAgent(ProviderManagerFrameworkField.Getter(manager));
                manager.AddNew(agent);
            }
            agent.ExecutionProvider = ufx;
            return(agent);
        }
Beispiel #2
0
        /// <summary>
        /// 获取订单助手,使用指定服务器、用户的CTP插件
        /// </summary>
        /// <returns></returns>
        public static (OrderAgent, XProvider) NewCtpAgent(this ProviderManager manager, string server, string user, string password)
        {
            var name  = OrderAgent.DefaultName + $"({server}_{user})";
            var agent = GetAgent(manager, name);

            if (agent == null)
            {
                agent = new OrderAgent(ProviderManagerFrameworkField.Getter(manager), name);
                manager.AddNew(agent);
            }
            var ctp = NewCtp(manager, server, user, password);

            agent.ExecutionProvider = ctp;
            //agent.DataProvider = ctp;
            return(agent, ctp);
        }
Beispiel #3
0
        public static IDataProvider GetDataProvider(this Strategy strategy, Instrument inst = null)
        {
            if (inst?.DataProvider != null)
            {
                return(inst.DataProvider);
            }

            IDataProvider p = null;

            if (DataProviderField != null)
            {
                p = DataProviderField.Getter(strategy);
            }
            return(p);
        }
Beispiel #4
0
        public static IExecutionProvider GetExecutionProvider(this Strategy strategy, Instrument inst = null)
        {
            if (inst?.ExecutionProvider != null)
            {
                return(inst.ExecutionProvider);
            }

            IExecutionProvider p = null;

            if (ExecutionProviderField != null)
            {
                p = ExecutionProviderField.Getter(strategy);
            }
            return(p);
        }
Beispiel #5
0
        public static Strategy_ FindStrategy(this StrategyManager_ manager, int id)
        {
            var s = StrategiesField1.Getter(manager)[id];

            if (s != null && s.Id == id)
            {
                return(s);
            }
            s = StrategiesField2.Getter(manager)[id];
            if (s != null && s.Id == id)
            {
                return(s);
            }
            return(null);
        }
        public BsonValue ToBson(ExecutionReport cmd)
        {
            var doc = new BsonDocument();

            doc["account"]         = account.Getter(cmd);
            doc["algoId"]          = algoId.Getter(cmd);
            doc["avgPx"]           = avgPx.Getter(cmd);
            doc["clId"]            = clId.Getter(cmd);
            doc["clientId"]        = clientId.Getter(cmd);
            doc["clientID"]        = clientID.Getter(cmd);
            doc["clOrderId"]       = clOrderId.Getter(cmd);
            doc["commission"]      = commission.Getter(cmd);
            doc["cumQty"]          = cumQty.Getter(cmd);
            doc["currencyId"]      = (int)currencyId.Getter(cmd);
            doc["dateTime"]        = dateTime.Getter(cmd);
            doc["execId"]          = execId.Getter(cmd);
            doc["execInst"]        = execInst.Getter(cmd);
            doc["execType"]        = (int)execType.Getter(cmd);
            doc["expireTime"]      = expireTime.Getter(cmd);
            doc["id"]              = id.Getter(cmd);
            doc["instrumentId"]    = instrumentId.Getter(cmd);
            doc["isLoaded"]        = isLoaded.Getter(cmd);
            doc["lastPx"]          = lastPx.Getter(cmd);
            doc["lastQty"]         = lastQty.Getter(cmd);
            doc["leavesQty"]       = leavesQty.Getter(cmd);
            doc["minQty"]          = minQty.Getter(cmd);
            doc["oCA"]             = oCA.Getter(cmd);
            doc["orderId"]         = orderId.Getter(cmd);
            doc["ordQty"]          = ordQty.Getter(cmd);
            doc["ordStatus"]       = (int)ordStatus.Getter(cmd);
            doc["ordType"]         = (int)ordType.Getter(cmd);
            doc["pegDifference"]   = pegDifference.Getter(cmd);
            doc["portfolioId"]     = portfolioId.Getter(cmd);
            doc["price"]           = price.Getter(cmd);
            doc["providerId"]      = (int)providerId.Getter(cmd);
            doc["providerOrderId"] = providerOrderId.Getter(cmd);
            doc["routeId"]         = (int)routeId.Getter(cmd);
            doc["side"]            = (int)side.Getter(cmd);
            doc["stopPx"]          = stopPx.Getter(cmd);
            doc["strategyId"]      = strategyId.Getter(cmd);
            doc["subSide"]         = (int)subSide.Getter(cmd);
            doc["text"]            = text.Getter(cmd);
            doc["timeInForce"]     = (int)timeInForce.Getter(cmd);
            doc["transactTime"]    = transactTime.Getter(cmd);
            doc["typeId"]          = (int)typeId.Getter(cmd);
            return(doc);
        }
        public static List <byte> Unsubscribe(this SubscriptionManager manager, Instrument inst)
        {
            var list = new List <byte>();
            var dict = SubscriptionManagerSubscriptionsField.Getter(manager);

            foreach (var item in dict)
            {
                if (item.Value.ContainsKey(inst))
                {
                    list.Add((byte)item.Key);
                }
            }
            foreach (var id in list)
            {
                manager.Unsubscribe(id, inst);
            }
            return(list);
        }
        public BsonValue ToBson(ExecutionCommand cmd)
        {
            var doc = new BsonDocument();

            doc["account"]              = account.Getter(cmd);
            doc["algoId"]               = algoId.Getter(cmd);
            doc["clId"]                 = clId.Getter(cmd);
            doc["clientId"]             = clientId.Getter(cmd);
            doc["clientID"]             = clientID.Getter(cmd);
            doc["clOrderId"]            = clOrderId.Getter(cmd);
            doc["currencyId"]           = (int)currencyId.Getter(cmd);
            doc["dateTime"]             = dateTime.Getter(cmd);
            doc["execInst"]             = execInst.Getter(cmd);
            doc["executionCommandType"] = (int)executionCommandType.Getter(cmd);
            doc["expireTime"]           = expireTime.Getter(cmd);
            doc["id"]              = id.Getter(cmd);
            doc["instrumentId"]    = instrumentId.Getter(cmd);
            doc["isLoaded"]        = isLoaded.Getter(cmd);
            doc["minQty"]          = minQty.Getter(cmd);
            doc["oCA"]             = oCA.Getter(cmd);
            doc["orderId"]         = orderId.Getter(cmd);
            doc["ordType"]         = (int)ordType.Getter(cmd);
            doc["pegDifference"]   = pegDifference.Getter(cmd);
            doc["portfolioId"]     = portfolioId.Getter(cmd);
            doc["price"]           = price.Getter(cmd);
            doc["providerId"]      = (int)providerId.Getter(cmd);
            doc["providerOrderId"] = providerOrderId.Getter(cmd);
            doc["qty"]             = qty.Getter(cmd);
            doc["routeId"]         = (int)routeId.Getter(cmd);
            doc["side"]            = (int)side.Getter(cmd);
            doc["stopPx"]          = stopPx.Getter(cmd);
            doc["strategyId"]      = strategyId.Getter(cmd);
            doc["subSide"]         = (int)subSide.Getter(cmd);
            doc["symbol"]          = symbol.Getter(cmd);
            doc["text"]            = text.Getter(cmd);
            doc["timeInForce"]     = (int)timeInForce.Getter(cmd);
            doc["transactTime"]    = transactTime.Getter(cmd);
            doc["typeId"]          = (int)typeId.Getter(cmd);
            WriteTable(doc, cmd);
            return(doc);
        }
Beispiel #9
0
 public static SmartQuant.IdArray <Strategy> GetStrategies(this Strategy s)
 {
     return(StrategyByIdField?.Getter(s));
 }
 public static Framework GetFramework(this Strategy s)
 {
     return(StrategyFrameworkField.Getter(s));
 }
 public static Framework GetFramework(this InstrumentManager manager)
 {
     return(InstrumentManagerFrameworkField.Getter(manager));
 }
 public static Framework GetFramework(this Instrument inst)
 {
     return(InstrumentFrameworkField.Getter(inst));
 }
 public static Framework GetFramework(this EventDispatcher manager)
 {
     return(EventDispatcherFrameworkField.Getter(manager));
 }
 public static Framework GetFramework(this DataManager manager)
 {
     return(DataManagerFrameworkField.Getter(manager));
 }
 public static Framework GetFramework(this Provider provider)
 {
     return(ProviderFrameworkField.Getter(provider));
 }
 public static Framework GetFramework(this Portfolio portfolio)
 {
     return(PortfolioFrameworkField.Getter(portfolio));
 }