- ago
Hi

Can backtesting stocks in SQL databases ?

or ploting that timeseries ?

thx
0
1,535
13 Replies

Reply

Bookmark

Sort
- ago
#1
Hi,
Please search before posting, we've got a topic for this:
https://www.wealth-lab.com/Discussion/Database-SQL-data-provider-6063

Don't forget to vote for this request if you need it!
1
- ago
#2
@changhengyiu, do not create duplicate fake accounts nor use proxies. This bogus account asalwl99 is banned. You should use your recognized customer's account:
https://www.wealth-lab.com/profile/changhengyiu

I recall your interest to the Database provider. It's so simple to upvote a request rather than choose such sophisticated ways!
https://wl6.wealth-lab.com/Extensions/Forum/Posts/Database-provider-define-more-than-one-NamedSeries-38809
0
- ago
#3
Hi,

@Eugene

About the questions from the SQL database by the data provider, for convenience backtesting
WL7 doesn't have this function, does it ?

If I want to achieve the goal, do I need to use the relevant extension API ?
0
- ago
#4
Hi Hank,

QUOTE:
If I want to achieve the goal, do I need to use the relevant extension API ?

Yes, using this API:
https://www.wealth-lab.com/Support/ExtensionApi/HistoricalDataProvider

Optionally these APIs if your SQL table is updating in real-time and/or contains fundamental (event) items:
https://www.wealth-lab.com/Support/ExtensionApi/StreamingDataProvider
https://www.wealth-lab.com/Support/ExtensionApi/EventDataProvider

Don't forget to upvote the feature request topic linked in Post #1, if you haven't done so already.
0
- ago
#5
Hi Eugene,

QUOTE:

Yes, using this API:
https://www.wealth-lab.com/Support/ExtensionApi/HistoricalDataProvider


Have some sample code to start and learn.

QUOTE:

Don't forget to upvote the feature request topic linked in Post #1, if you haven't done so already.


upvoted !
0
- ago
#6
Here's a skeleton code of the data provider:
CODE:
using WealthLab.Core; using System; using WealthLab.Data; namespace WealthLab.Changhengyiu { public class ChangProvider : DataProviderBase { public ChangProvider() : base() { //this loads the saved configuration, and will assign the Parameters instances if they were already defined LoadConfig(); //if the parameter instances aren't there, it is a new install, so add them now if (Parameters.Count == 0) { Parameters.Add(new Parameter("Connection string", ParameterTypes.String, "Server=127.0.0.1;Database=myDataBase;User Id=username;Password=password;")); Configuration = Parameters.Persist(); } } //it's considered configured if "connection string" has a value public override bool IsConfigured { get { return Parameters[0].AsString.Trim() != ""; } } //return a page for the custom settings panel, use the built-in Parameters editor page class (ucDataProviderParameters) public override CustomSettingsPanel GetCustomSettingsPage() { if (_settingsPage == null) _settingsPage = new ucDataProviderParameters(); return _settingsPage; } //any required initialization would go here public override void Initialize() { base.Initialize(); } //provider friendly name public override string Name => "ChangProvider"; //TODO create your own provider glyph! public override System.Drawing.Bitmap Glyph => new Bitmap(10,10); public override string HelpDescription => "Returns historical data from SQL database for backtesting."; public override bool UsesPersistentStorage => true; //TODO adjust to your requirements public override bool SupportsScale(HistoryScale scale) { if (scale.Scale == HistoryScales.Daily || scale.Scale == HistoryScales.Minute || scale.Scale == HistoryScales.Hour) return true; return false; } //get history from SQL... protected override BarHistory GetHistoryInternal(string symbol, HistoryScale scale, DateTime startDate, DateTime endDate, int maxBars) { //supports daily and several intraday scales bool scaleSupported = false; if (scale.Scale == HistoryScales.Daily || scale.Scale == HistoryScales.Minute || scale.Scale == HistoryScales.Hour) scaleSupported = true; if (!scaleSupported) return null;          //TODO your database reading logic BarHistory bh = ... return bh; } //private variables private ucDataProviderParameters _settingsPage = null; } }
1
- ago
#7
Eugene, thanks for this code.

Extensions look much less frightening for a non-programer if you start with this point.
0
- ago
#8
Hi Eugene,

It's Hard work!

QUOTE:
Here's a skeleton code of the data provider:


In code :

CODE:
public override Bitmap Glyph => new Bitmap(10, 10);




Bitmap is in using System.Drawing;

but Class library project targets .NET Core 3.1 not included "System.Drawing"

Link : https://www.nuget.org/packages/System.Drawing.Common/

This is need ? PM > Install-Package System.Drawing.Common -Version 5.0.2

How to work ?
0
- ago
#9
Hmm I don't think so,
CODE:
using System.Drawing;
should be enough.
0
- ago
#10
QUOTE:
public override Bitmap Glyph => new Bitmap(10, 10);

Yes, I had some issuers (I couldn't overcome) with this too.
0
- ago
#11
U can ?

I can't ...

https://github.com/dotnet/runtime/issues/37866
0
- ago
#12
Whatever works for you is fine with me. To close this offtopic discussion:
https://www.wealth-lab.com/Discussion/Error-adding-System-Drawing-Common-package-to-custom-extension-6351
0
Glitch8
 ( 12.53% )
- ago
#13
You’ll need to reference System.Drawing.Common in NuGet. Be sure to reference the same version of the assembly included in the WL7 folder.
0

Reply

Bookmark

Sort