Posts

Stock prediction using Azure Machine Learning

Image
I like dabbling in the stock market, and wondered if artificial intelligence could help predict when I should buy/sell stock. Using one of the FANG stocks (Facebook, Amazon, Netflix, Google) I'll choose Netflix for the purposes of this blog post. Here is what Netflix has done in the last 3 months: The top graph is Fast Stochastics (12,26) As you can see, predicting the future is not easy. So my first step was to not use AI at all, but to write a program to help me decide which values of %K and %D I should use for the Fast Stochastics graph, using the last 5 years of stock history for Netflix. Historical data This can be obtained from Yahoo finance . Change the Time period to 5Y and press Apply. Then click the download data link to obtain your CSV file. Best %K %D Fast Stochastics values for Netflix The program I wrote takes into account that buying stock and selling stock incur a fee, and that the buy and sell values are not the same (bid/ask difference). The...

Calling SQL Server stored procedures from Entity Framework

Using the methods below, you can obtain the stored procedure return value , along with your data, which I've not seen in other blogs. A stored proc should return 0 for success, and any other value for a failure. Here is an example table, filled with data: CREATE TABLE DemoData ( id INT NOT NULL PRIMARY key, someValue DECIMAL(4,4) NOT NULL ) GO INSERT INTO DemoData(id, someValue) VALUES (1, 1.23), (2, 2.34), (3, 3.45), (4, 4.56) Here are our example stored procedures: CREATE PROCEDURE GetDemoData(@maxId INT) AS BEGIN SET NOCOUNT ON; SELECT id, someValue FROM DemoData WHERE id <= @maxId END GO CREATE PROCEDURE AddTwoValues(@a INT, @b INT) AS BEGIN SET NOCOUNT ON; RETURN @a + @b -- Don't do this. Stored procs should return -- 0 for success, and any other value for failure. END GO CREATE PROCEDURE AddTwoValuesWithResult(@a INT, @b INT, @result INT OUTPUT, @result2 INT OUTPUT) AS BEGIN SET NOCOUNT ON; SET @result = @a +...

Pregenerated Views for Entity Framework 6

When Entity Framework starts, it first builds a set of internal views that describes the database in an agnostic way. All further processing (queries, updates etc.) EF does, is performed against these views. Generating views however can be costly and will impact start up time of the application. The startup time for a 1000 table context can be in excess of minutes. However, this can be worked around by generating views at design time by using EFInteractiveViews Nuget Package. It allows you to pre-generate and save the generated views to a file. Neat! Install the Nuget package: https://www.nuget.org/packages/EFInteractiveViews Source code and documentation: https://github.com/moozzyk/EFInteractiveViews

I'm in MSDN Magazine this month :-)

I am in the August 2014 edition of MSDN Magasine, Data Points section. The article is written by Julie Lerman on the EntityFramework Reverse POCO Generator I created. MSDN link: http://msdn.microsoft.com/en-us/magazine/dn759438.aspx

SQL Datetime comparison gotcha

I discovered a problem when inserting data in our database. My insert statement was checking for the existence of data in the WHERE clause to prevent duplicate data being inserted. None was detected , and the INSERT happend. However, the unique constraint rejected the data as it already existed in the database. The problem was the data to be inserted was DATETIMEOFFSET(2) and the database field being inserted into was DATETIME. To show you want I'm talking about, run the following: DECLARE @dt DATETIME = '2014-07-07 09:49:33.000'; DECLARE @dto DATETIMEOFFSET(2) = '2014-07-07 09:49:33.00 +07:00'; PRINT CASE WHEN @dt = @dto THEN 'Equals matches' ELSE 'Equals does not match' END PRINT CASE WHEN @dt = CAST(@dto AS DATETIME) THEN 'Cast matches' ELSE 'Cast does not match' END Results in the following: Equals does not match Cast matches The comparison (=) operator does not perform th...

A new tutorial video

I have released a new and updated tutorial video for Entity Framework Reverse POCO generator. It is available to stream or download at: www.reversepoco.com

Entityframework reverse POCO generator V2.4 released

Download:   here Whats new in v2.4.0 Removed use of System.Data.Entity.DLL from the installation template as it is no longer required for EF 6. Moved spatial types from System.Data.Spatial to System.Data.Entity.Spatial for EF 6. Singular names and camel casing configuration were accidentally combined by using the UseCamelCase boolean. Thanks to Rune Gulbrandsen . Added new flag IncludeComments . This controls the generation of comments in the output. Fixed bug in constructor where a UNIQUEIDENTIFIER column had default value. Thanks to gonglei .