Norgate provides the following syntax:
However, Metadata does not appear to have a GetFundamentalItem method.
The syntax above appears to be for WL6, but I cannot find WL8 equivalent.
At the top, I put:
Is there something else I have missed?
CODE:
var a = Metadata.GetFundamentalItem(Bars.Count-1, Bars.Symbol, "<fundamental field>");
However, Metadata does not appear to have a GetFundamentalItem method.
The syntax above appears to be for WL6, but I cannot find WL8 equivalent.
At the top, I put:
CODE:
using NorgateData.Integration.WealthLab;
Is there something else I have missed?
Rename
It appears that Norgate's documentation is a bit outdated in this field if you're looking at this: https://norgatedata.com/wealth-lab-usage.php
Hi Curtis,
This functionality is exposed via WealthLab's EventProvider interface - apologies for this confusion - we'll revise our documentation.
I'll let you know when this is done.
This functionality is exposed via WealthLab's EventProvider interface - apologies for this confusion - we'll revise our documentation.
I'll let you know when this is done.
GetFundamentalItem is working in Build 8 of the Norgate Data extension, as described here:
https://norgatedata.com/wealth-lab-usage.php
https://norgatedata.com/wealth-lab-usage.php
Thank you. As you noted, I had to update the extension from build 7 to 8 before it worked. In the meantime, I had been able to get to the data another way:
However, your documented solution seems clearer:
Thanks again.
CODE:
List<EventDataPoint> fiList = equity.GetEventDataPoints("mktcap"); double fiValue = fiList[fiList.Count - 1].Value;
However, your documented solution seems clearer:
CODE:
var fiValue = Metadata.GetFundamentalItem(equity.Symbol, "mktcap");
Thanks again.
Could you tell me why I am not set to an instance of an Object pls.
Thank you very much.
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; using System.Reflection.Metadata; using WealthLab.Norgate; using TeeChart.Xaml.WPF.Series; using finantic.Indicators; using ScottPlot.Plottable; namespace WealthScript3 { public class MyStrategy : UserStrategyBase { Fundamental fundamentalItem_fcf; public MyStrategy() { AddParameter("fcf_limit", ParameterType.Double, 5, 1, 10, 1); } // Create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) { // Define the fundamental item you want to use var pfcfpershare = "aprfcfps"; var fundamentalItem_fcf = Metadata.GetFundamentalItem(bars.Symbol, pfcfpershare); StartIndex = 11; } // Execute the strategy rules here, this is executed once for each bar in the backtest history public override void Execute(BarHistory bars, int idx) { // Buy condition if (!HasOpenPosition(bars, PositionType.Long) && fundamentalItem_fcf[idx] < Parameters.FindName("fcf_limit").AsInt) { PlaceTrade(bars, TransactionType.Buy, OrderType.Market, 0, "B@M"); } // Sell condition (after 10 days) Position p = LastPosition; { if (idx - p.EntryBar > 10) { ClosePosition(p, OrderType.Market, 0, "Sell@10Days"); } } } } }
Thank you very much.
You forgot the ELSE statement in the Execute{block}.
Also it's very execution inefficient to do a run-time FindName search. For speed, always use a compile-time construct instead. For example, assign a variable name to the parameter in question as shown.
Also it's very execution inefficient to do a run-time FindName search. For speed, always use a compile-time construct instead. For example, assign a variable name to the parameter in question as shown.
CODE:The bad news is that this doesn't answer your original question, which is why you have an unassigned reference. I don't know because I don't use Norgate. My "guess" is the
namespace WealthScript5 { public class MyStrategy : UserStrategyBase { Fundamental fundamentalItem_fcf; Parameter fcf_limit; public MyStrategy() { fcf_limit = AddParameter("fcf_limit", ParameterType.Double, 5, 1, 10, 1); } public override void Initialize(BarHistory bars) { // Define the fundamental item you want to use string pfcfpershare = "aprfcfps"; var fundamentalItem_fcf = Metadata.GetFundamentalItem(bars.Symbol, pfcfpershare); StartIndex = 11; } public override void Execute(BarHistory bars, int idx) { if (!HasOpenPosition(bars, PositionType.Long)) { // Buy condition if (fundamentalItem_fcf[idx] < fcf_limit.AsInt) { PlaceTrade(bars, TransactionType.Buy, OrderType.Market, 0, "B@M"); } } else { // Sell condition (after 10 days) Position p = LastPosition; if (idx - p.EntryBar > 10) { ClosePosition(p, OrderType.Market, 0, "Sell@10Days"); } } } } }
CODE:line is throwing the error. Try replacing that line with something else to see if the error goes away. Maybe the pfcfpershare string value is wrong?
Metadata.GetFundamentalItem(bars.Symbol, pfcfpershare);
I'll try; thank you.
I sent the easiest code I could craft.
Thank you again.
I sent the easiest code I could craft.
Thank you again.
There are a few problems with the variable declarations. The reason for the object error is that you declared an instance-scoped variable fundamentalItem_fcf as "FundamentaL", never assigned it to anything, then refered to it in the Execute(). You declared another fundamentalItem_fcf locally in Initialize() with "var", but didn't use the value anywhere.
Norgate's Metadata.GetFundamentalItem returns a nullable double value (hover the mouse over it) not a Fundamental object. This implies that it's only a single most-recent value, especially since you can't identify a date (or bars index).
Therefore, you can't backtest with Norgate fundamentals, but they may be worthwhile for screening like this -
Norgate's Metadata.GetFundamentalItem returns a nullable double value (hover the mouse over it) not a Fundamental object. This implies that it's only a single most-recent value, especially since you can't identify a date (or bars index).
Therefore, you can't backtest with Norgate fundamentals, but they may be worthwhile for screening like this -
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Collections.Generic; using WealthLab.Norgate; namespace WealthScript5 { public class MyStrategy : UserStrategyBase { Parameter fcf_limit; const string pfcfpershare = "aprfcfps"; public MyStrategy() { fcf_limit = AddParameter("fcf_limit", ParameterType.Double, 5, 1, 10, 1); } public override void Initialize(BarHistory bars) { StartIndex = 11; } public override void Execute(BarHistory bars, int idx) { if (idx == bars.Count - 1) { // Buy condition (signal only) var fundamentalItem_fcf = Metadata.GetFundamentalItem(bars.Symbol, pfcfpershare); if (fundamentalItem_fcf < fcf_limit.AsDouble) { PlaceTrade(bars, TransactionType.Buy, OrderType.Market, 0, "B@M"); } } } } }
Thank you....
How does this see the fcf double at idx?
Would I not have to convert this list of doubles to a series and index them to idx?
Maybe in my next life I will understand C#...
How does this see the fcf double at idx?
Would I not have to convert this list of doubles to a series and index them to idx?
Maybe in my next life I will understand C#...
QUOTE:
How does this see the fcf double at idx?
The line
CODE:only returns a single double value, not an array double[] of values. Norgate is only returning the most recent fundamental value.
double fundamentalItem_fcf = Metadata.GetFundamentalItem(bars.Symbol, pfcfpershare);
If you want a List<fundamentalItem> of fundamentals over time for backtesting, then you need to subscribe to a "real" fundamental data provider such as YCharts or EODHD.
Thank you... I was confused.
Kinda useless from Norgate...
I guess I could download the data every day from them and create a dartabase of my own.
Thank you once again.
Kinda useless from Norgate...
I guess I could download the data every day from them and create a dartabase of my own.
Thank you once again.
QUOTE:
I guess I could download the data every day from them and create a dartabase of my own.
Ha, ha. Sounds like madness. :-)
There is a "free" version of YCharts with some fundamentals; however, it's very slow. I disable the YCharts event provider at the beginning of each trading day when Strategy Monitor is downloading data. If you're integrating fundamentals into your trading strategy, then you probably want to buy the paid version.
I'm a trader, not an investor, so although fundamentals appear on my Chart, they are not integrated into my trading strategy. So I settle for the free version.
Your Response
Post
Edit Post
Login is required