Oanda Live Data Not Coming Through?


Oanda Live Data Not Coming Through?
Atom
8/20/2020


Rob

Avatar
I've been trying to connect to an Oanda paper account for live candles using StockSharp.Oanda v5.0.27 but am not receiving updated candles. The historical candle load in the code below is successful and returns a day of history, but the live candles do not continue to come in. The same issue is seen for every lesson when I produce that code.

While debugging, I can see that
Code
IsSupportCandlesUpdates
is set to false and is read-only.

When I use the same Oanda API account in Shell#, and run a strategy, the live data works. So, it doesn't appear to be an account issue.

Can you confirm the Oanda adapter works for live data and advise what I'm missing in the code below to generate live candle data?

Thank you.

Code

class Program {

private static CandleSeries _candleSeries;
private static LogManager _logManager;
private static Connector _connector;
static void Main (string[] args) {

Console.WriteLine ("Init");

var security = new Security {
Id = "GBP/USD@OND",
Code = "GBP/USD",
PriceStep = 0.01m,
Board = ExchangeBoard.Ond
};

_connector = new Connector ();

_logManager = new LogManager ();
_logManager.Listeners.Add (new FileLogListener ("log.txt"));

var adapter = new OandaMessageAdapter (_connector.TransactionIdGenerator) {
Token = "the-api-key".To<SecureString> (),
Server = OandaServers.Practice,
};

_connector.Adapter.InnerAdapters.Add (adapter);
_connector.LogLevel = LogLevels.Debug;
_logManager.Sources.Add (_connector);

_connector.Connected += () => {
Console.WriteLine ("Connected");
};

_connector.ConnectionError += error => {
Console.WriteLine (error);
};

_connector.Error += error => {
Console.WriteLine (error);
};

_connector.NewSecurity += security => {
Console.WriteLine (security.Name);
};

_connector.NewTrade += trade => {
Console.WriteLine ("trade: {0}", trade);
};

_connector.NewPortfolio += portfolio => {
Console.WriteLine ("portfolio: {0}", portfolio.Name);
};

_connector.NewPosition += position => {
Console.WriteLine ("position: {0}", position);
};

_candleSeries = new CandleSeries (typeof (TimeFrameCandle), security, new TimeSpan (0, 1, 0)) {
BuildCandlesMode = MarketDataBuildModes.LoadAndBuild,
BuildCandlesFrom = MarketDataTypes.CandleTick,
};

_connector.CandleSeriesProcessing += (_candleSeries, candle) => {
Console.WriteLine (candle);
};

var subscription = _connector.SubscribeCandles (_candleSeries, DateTime.Today.Subtract (TimeSpan.FromDays (1)), DateTime.Now, adapter : adapter);

_connector.CandleReceived += (subscription, candle) => {
Console.WriteLine (candle);
};

_connector.TickTradeReceived += (subscription, trade) => {
Console.WriteLine (trade);
};

_connector.CandleSeriesError += (_candleSeries, error) => {
Console.WriteLine ("CandleSeriesError {0}", error);
};

_connector.Connect ();

Console.ReadLine ();

}
}



Thanks:


Rob

Avatar
Date: 8/21/2020
Reply


I was able to resolve this by downloading the completed lessons and comparing the code.
Thanks:

Support

Avatar
Date: 9/1/2020
Reply


Hello

As extra information, provided here https://stocksharp.com/posts/m/51282/ (not related to code from this topic)
Thanks:


Attach files by dragging & dropping, , or pasting from the clipboard.

loading
clippy