示例#1
0
 private void StartGetData()
 {
     ServerLog.ClearList();
     for (int i = 0; i < SiArray.Count; i++)
     {
         if (!RunningST.ContainsKey(SiArray[i].Market))
         {
             string       market         = SiArray[i].Market;
             string       dllname        = TradeSDK.getDllName(market);
             Assembly     assembly       = Assembly.Load(TradeSDK.getSDK(dllname));
             Type         ClassTradeAPI  = assembly.GetType(string.Format("{0}.TradeAPI", dllname.Substring(0, dllname.Length - 4)));
             Object       ObjectTradeAPI = assembly.CreateInstance(ClassTradeAPI.FullName, true, BindingFlags.CreateInstance, null, new object[] { }, null, null);
             BaseTradeAPI bta            = ((BaseTradeAPI)ObjectTradeAPI);
             RunningST.Add(market, bta);
             TraderAccount sa = new TraderAccount(bta);
             bta.queryDataArrival += queryArrival;
             if (showTradeView)
             {
                 CurrentBalances.Insert(market);
                 Trader trader = Trader.CreateTrader(sa);
                 traders.Add(market, trader);
                 frm_TradeMonitor tradeform = new frm_TradeMonitor(trader);
                 tradeform.tradePolicyResult_Arrival    += PolicyResultArraival;
                 tradeform.tradeFunPolicyResult_Arrival += PolicyFunArraival;
                 tradeform.Left = 0;
                 tradeform.Top  = 3 * logform.Height;
                 tradeform.Show();
                 tradeform.ConnectTrade();
             }
         }
         foreach (var st in RunningST)
         {
             BaseTradeAPI bta = ((BaseTradeAPI)st.Value);
             if (bta.AbortedWs)
             {
                 bta.InitWebSocket();
             }
             if (bta.market == SiArray[i].Market)
             {
                 if (!bta.DicSi.ContainsKey(SiArray[i].Code))
                 {
                     bta.DicSi.Add(SiArray[i].Code, SiArray[i]);
                     CurrentTicker.Insert(SiArray[i].Market + SiArray[i].Code);
                 }
                 bta.Subscribe(SiArray[i].Code, "marketDepth", SiArray[i].Type);
                 bta.Subscribe(SiArray[i].Code, "trade", SiArray[i].Type);
                 if (showTradeView)
                 {
                     bta.Subscribe(SiArray[i].Code, "order", SiArray[i].Type);
                     bta.Subscribe(SiArray[i].Code, "account", SiArray[i].Type);
                     if (SiArray[i].Type != "spot")
                     {
                         bta.Subscribe(SiArray[i].Code, "position", SiArray[i].Type);
                     }
                 }
             }
         }
     }
 }