You need to enable JavaScript in order to visit our site!
 
Logo PTMC
NAVIGATION
CANCEL
 
or via PTMC account
Restore password
or via PTMC account
Logo PTMC
NAVIGATION
or via PTMC account
Restore password
or via PTMC account
or via PTMC account
Restore password
or via PTMC account

NewLevel2

event
Occurs when the new level2 quote by subscribed instrument is coming.

Syntax

public event Action<Instrument, Level2> NewLevel2

Example


 В следующем примере кода показано как можно использовать использовать event NewLevel2.
 
 using System;
 using System.Collections;
 using System.Collections.Generic;
 using System.Text;
 using System.Drawing;
 using PTLRuntime.NETScript;

 namespace InstrumentsCollection_
 {
     public class InstrumentsCollection_ : NETStrategy
     {
         int QuoteCounter = 0,
         TradeCounter = 0,
         Level2Counter = 0,
         MaintCount = 0;

         Instrument instr;
         Instrument[] instrArray, instrSortArray;
         string[] instrNames;

         int index = 10;

         public override void Init()
         {
             Instruments.NewTrade += OnTrade; //Создание event на новые сделки
             Instruments.NewQuote += OnQuote2; //Создание event на обновление lvl1 котировок
             Instruments.NewLevel2 += OnLevel2; //Создание event на обновление lvl2 котировок

             Instruments.InstrumentAdded += OnInstrumentAdd;//Создание event на добавление нового инструмента на сервере

             instr = Instruments.Current; //текущий инструмент
             Alert("Current instrument is: " + instr.Name);

             //Подписка на выбранный инстурмент
             Instruments.Subscribe(instr, QuoteTypes.Trade); //подписка на пройденные сделки
             Instruments.Subscribe(instr, QuoteTypes.Quote);
             Instruments.Subscribe(instr, QuoteTypes.Level2);

             instrArray = Instruments.GetInstruments();
             instrSortArray = Instruments.GetSortedInstruments();
             instrNames = Instruments.GetSortedInstrumentNames();

             Print(index + " instrument name in unsorte instrument name array is " + Instruments.GetInstrument(instrNames[index]).Name);
             Print(index + " instrument name in unsorted instrument array is " + Instruments.GetInstrument(instrArray[index].Symbol, instrArray[index].Route).Name);
             Print(index + " instrument name in sorted instrument array is " + Instruments.GetInstrument(instrSortArray[index].Symbol, instrSortArray[index].Route).Name);

             foreach (Instrument i in instrArray)
             {
                 if (i.Type == InstrumentType.Future)
                 {
                     instr = Instruments.GetInstrument(i.Symbol, i.Route, i.GetDerivativeSettings().ContractMonthDate);
                     Alert(instr.Name);
                 }
             }
         }

         private void OnQuote2(Instrument instr, Quote quote)
         {
             QuoteCounter++;
         }

         private void OnLevel2(Instrument instr, Level2 level2)
         {
             Level2Counter++;
         }

         private void OnTrade(Instrument instr, Trade trade)
         {
             TradeCounter++;
         }

         private void OnInstrumentAdd(Instrument instr)
         {
             Print("Add new instrument on server");
         }

         public override void OnQuote()
         {
             MaintCount++;
             Comment("#LVL1: " + QuoteCounter + "\t#LVL2: " + Level2Counter + "\t#LVL3: " + TradeCounter + "\t#OnQuote: " + MaintCount);
         }

         public override void Complete()
         {
             Instruments.NewTrade -= OnTrade;
             Instruments.NewQuote -= OnQuote2;
             Instruments.NewLevel2 -= OnLevel2;

             Instruments.InstrumentAdded -= OnInstrumentAdd;

             //Отписка от инструмента к которому подписывались вначале.
             Instruments.Unsubscribe(instr, QuoteTypes.Trade);
             Instruments.Unsubscribe(instr, QuoteTypes.Quote);
             Instruments.Unsubscribe(instr, QuoteTypes.Level2);
         }
     }
 }
 
Discussion
Join PTMC community to post your comments
No comments yet. Be the first.
PTMC 是一個專業的交易平台,結合了強大的圖表和分析工具,並可在不同的金融市場進行交易。 它是由 PFSOFT UK LTD 開發的,該公司是全球銀行和經紀商交易技術提供商
© 2024. PTMC 為基於 Protrader 技術的專業交易平台
地址
臺北市大安區羅斯福路3段273號5樓
聯絡我們
電話: +886-2-2367-8583
E-mail: service@kcdatanet.com
社群
© 2024. PTMC 為基於 Protrader 技術的專業交易平台