Add IQFeed host and port configuration settings
This commit is contained in:
parent
9e1e8e387f
commit
5603353cc5
@ -48,14 +48,14 @@ namespace NinjaTrader.NinjaScript.Indicators
|
||||
{"12", "Z"}
|
||||
};
|
||||
|
||||
public static async Task StreamMarketDepth(Instrument instrument, int maxLevels)
|
||||
public static async Task StreamMarketDepth(Instrument instrument, int maxLevels, string host, int port)
|
||||
{
|
||||
Asks.Clear();
|
||||
Bids.Clear();
|
||||
|
||||
string symbol = GetIQFeedSymbol(instrument);
|
||||
|
||||
using (TcpClient client = new TcpClient("127.0.0.1", 9200))
|
||||
using (TcpClient client = new TcpClient(host, port))
|
||||
using (NetworkStream stream = client.GetStream())
|
||||
{
|
||||
StringBuilder data = new StringBuilder();
|
||||
@ -179,13 +179,15 @@ namespace NinjaTrader.NinjaScript.Indicators
|
||||
IsSuspendedWhileInactive = false;
|
||||
MaxLevels = 0;
|
||||
MaxWidth = 500;
|
||||
Host = "127.0.0.1";
|
||||
Port = 9200;
|
||||
}
|
||||
else if (State == State.Configure)
|
||||
{
|
||||
}
|
||||
else if (State == State.DataLoaded)
|
||||
{
|
||||
Task.Run(() => MarketDepthProcessor.StreamMarketDepth(Instrument, MaxLevels));
|
||||
Task.Run(() => MarketDepthProcessor.StreamMarketDepth(Instrument, MaxLevels, Host, Port));
|
||||
}
|
||||
else if (State == State.Historical)
|
||||
{
|
||||
@ -253,6 +255,14 @@ namespace NinjaTrader.NinjaScript.Indicators
|
||||
[Display(Name = "Max Width", Description = "The maximum width of the market depth levels in pixels", Order = 2, GroupName = "Market Depth")]
|
||||
public int MaxWidth
|
||||
{ get; set; }
|
||||
|
||||
[NinjaScriptProperty]
|
||||
[Display(Name = "IQFeed Host", Description = "The host on which the IQFeed connection is running", Order = 3, GroupName = "Market Depth")]
|
||||
public string Host { get; set; }
|
||||
|
||||
[NinjaScriptProperty]
|
||||
[Display(Name = "IQFeed Port", Description = "The port on which the IQFeed connection is listening", Order = 4, GroupName = "Market Depth")]
|
||||
public int Port { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,18 +273,18 @@ namespace NinjaTrader.NinjaScript.Indicators
|
||||
public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
|
||||
{
|
||||
private MarketDepth[] cacheMarketDepth;
|
||||
public MarketDepth MarketDepth(int maxLevels, int maxWidth)
|
||||
public MarketDepth MarketDepth(int maxLevels, int maxWidth, string host, int port)
|
||||
{
|
||||
return MarketDepth(Input, maxLevels, maxWidth);
|
||||
return MarketDepth(Input, maxLevels, maxWidth, host, port);
|
||||
}
|
||||
|
||||
public MarketDepth MarketDepth(ISeries<double> input, int maxLevels, int maxWidth)
|
||||
public MarketDepth MarketDepth(ISeries<double> input, int maxLevels, int maxWidth, string host, int port)
|
||||
{
|
||||
if (cacheMarketDepth != null)
|
||||
for (int idx = 0; idx < cacheMarketDepth.Length; idx++)
|
||||
if (cacheMarketDepth[idx] != null && cacheMarketDepth[idx].MaxLevels == maxLevels && cacheMarketDepth[idx].MaxWidth == maxWidth && cacheMarketDepth[idx].EqualsInput(input))
|
||||
if (cacheMarketDepth[idx] != null && cacheMarketDepth[idx].MaxLevels == maxLevels && cacheMarketDepth[idx].MaxWidth == maxWidth && cacheMarketDepth[idx].Host == host && cacheMarketDepth[idx].Port == port && cacheMarketDepth[idx].EqualsInput(input))
|
||||
return cacheMarketDepth[idx];
|
||||
return CacheIndicator<MarketDepth>(new MarketDepth(){ MaxLevels = maxLevels, MaxWidth = maxWidth }, input, ref cacheMarketDepth);
|
||||
return CacheIndicator<MarketDepth>(new MarketDepth(){ MaxLevels = maxLevels, MaxWidth = maxWidth, Host = host, Port = port }, input, ref cacheMarketDepth);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -283,14 +293,14 @@ namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
|
||||
{
|
||||
public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
|
||||
{
|
||||
public Indicators.MarketDepth MarketDepth(int maxLevels, int maxWidth)
|
||||
public Indicators.MarketDepth MarketDepth(int maxLevels, int maxWidth, string host, int port)
|
||||
{
|
||||
return indicator.MarketDepth(Input, maxLevels, maxWidth);
|
||||
return indicator.MarketDepth(Input, maxLevels, maxWidth, host, port);
|
||||
}
|
||||
|
||||
public Indicators.MarketDepth MarketDepth(ISeries<double> input , int maxLevels, int maxWidth)
|
||||
public Indicators.MarketDepth MarketDepth(ISeries<double> input , int maxLevels, int maxWidth, string host, int port)
|
||||
{
|
||||
return indicator.MarketDepth(input, maxLevels, maxWidth);
|
||||
return indicator.MarketDepth(input, maxLevels, maxWidth, host, port);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -299,14 +309,14 @@ namespace NinjaTrader.NinjaScript.Strategies
|
||||
{
|
||||
public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
|
||||
{
|
||||
public Indicators.MarketDepth MarketDepth(int maxLevels, int maxWidth)
|
||||
public Indicators.MarketDepth MarketDepth(int maxLevels, int maxWidth, string host, int port)
|
||||
{
|
||||
return indicator.MarketDepth(Input, maxLevels, maxWidth);
|
||||
return indicator.MarketDepth(Input, maxLevels, maxWidth, host, port);
|
||||
}
|
||||
|
||||
public Indicators.MarketDepth MarketDepth(ISeries<double> input , int maxLevels, int maxWidth)
|
||||
public Indicators.MarketDepth MarketDepth(ISeries<double> input , int maxLevels, int maxWidth, string host, int port)
|
||||
{
|
||||
return indicator.MarketDepth(input, maxLevels, maxWidth);
|
||||
return indicator.MarketDepth(input, maxLevels, maxWidth, host, port);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user