マーケット深度

cBots (自動売買)

Summary

Access to MarketDepth Ask Entries, Bid Entries, and the event at which the market depth gets updated.

Signature

1
public abstract interface MarketDepth

 

Namespace

cAlgo.API

Examples

 1
                                     2
                                     3
                                     4
                                     5
                                     6
                                     7
                                     8
                                     9
                                    10
                                    11
                                    12
                                    13
                                    14
                                    15
                                    16
                                    17
                                    18
                                    19
                                    20
                                    21
                                    22
                                    23
                                    24
                                    25
                                    26
                                    27
                                    28
                                    29
                                    30
                                    31
                                    32
                                    33
                                    34
                                    35
                                    36
                                    37
                                    38
                                    39
                                    40
                                    41
                                    42
                                    43
                                    44
                                    45
                                    46
                                    47
                                    48
                                    49
                                    50
                                    51
                                    52
                                    53

    using System;
    using System.Text;
    using cAlgo.API;
    namespace cAlgo.Indicators
    {
        [Indicator]
        public class MarketDepthIndicator : Indicator
        {
            private MarketDepth _marketDepth;
            public override void Calculate(int index){}
            protected override void Initialize()
            {
              //  Get Market Depth
                _marketDepth = MarketData.GetMarketDepth(Symbol);
              // subscribe to event Updated
                _marketDepth.Updated += MarketDepthUpdated;
            }
            void MarketDepthUpdated()
            {
              // Draw Market Depth Entries in the indicator panel
                var se = new StringBuilder();
                se.Append("Bid");
                se.Append("                              ");
                se.Append("Ask");
                ChartObjects.DrawText("DOM", se.ToString(), StaticPosition.TopLeft, Colors.White);
                se.Clear();
                se.AppendLine();
                se.AppendLine();
                foreach (var entry in _marketDepth.BidEntries)
                {
                    double dVolume  = Math.Round(entry.Volume / 1000000.0, 2);
                    string volume = string.Format("{0}{1}", dVolume, "m");
                    double entryPrice = entry.Price;
                    string askText = string.Format("{0}    {1}", entryPrice.ToString("0.00000"), volume);
                    se.AppendLine(askText);
                }
                ChartObjects.DrawText("Bid", se.ToString(), StaticPosition.TopLeft, Colors.Red);
                se.Clear();
                se.AppendLine();
                se.AppendLine();
                foreach (var entry in _marketDepth.AskEntries)
                {
                    double dVolume = Math.Round(entry.Volume / 1000000.0, 2);
                    string volume = string.Format("{0}{1}", dVolume, "m");
                    double entryPrice = entry.Price;
                    se.Append("                                    ");
                    string bidText = string.Format("{0}     {1}", entryPrice.ToString("0.00000"), volume);
                    se.AppendLine(bidText);
                }
                ChartObjects.DrawText("Ask", se.ToString(), StaticPosition.TopLeft, Colors.Turquoise);
            }
        }
    }

Properties

AskEntries

Summary

The total number of Ask entries.

Signature

1
public abstract IReadonlyList<MarketDepthEntry> AskEntries {get;}

 

Return Value

IReadonlyList

Examples

1
2
3
4
5

 foreach (var entry in _marketDepth.AskEntries)
 {
      volume  = entry.Volume;
      entryPrice = entry.Price;
 }

BidEntries

Summary

The total number of Bid entries.

Signature

1

public abstract IReadonlyList<MarketDepthEntry> BidEntries {get;}

 

Return Value

IReadonlyList

Examples

1
2
3
4
5

 foreach (var entry in _marketDepth.BidEntries)
 {
      volume  = entry.Volume;
      entryPrice = entry.Price;
 }

Events

Updated

Summary

The event at which the market depth gets updated.

Signature

1
public abstract event Action Updated;

 

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12

MarketDepth _marketDepth;
 protected override void Initialize()
 {
     _marketDepth = MarketData.GetMarketDepth(Symbol);
     // subscribe to event Updated
     _marketDepth.Updated += MarketDepthUpdated;
 }
 // user defined function MarketDepthUpdated
 void MarketDepthUpdated()
 {
     // Do something
 }
目次

このページについて