﻿CREATE TABLE [dbo].[Signals] (
    [KnokId]                        BIGINT          IDENTITY (1, 1) NOT NULL,
    [Currency1]                          VARCHAR (30)    NOT NULL,
	[Currency2]                          VARCHAR(30) NOT NULL, 
	[Currency]                         VARCHAR(30) NOT NULL, 
    [ExchangeId]                      SMALLINT        NOT NULL,
    [TickerId]                        INT             NOT NULL,
    [CreatorUserId]                   BIGINT          NOT NULL,
    [EntryPriceFrom]                   DECIMAL (22, 8) NOT NULL,
    [EntryPriceTo]                     DECIMAL (22, 8) NOT NULL,
    [ExitPriceFrom]                    DECIMAL (22, 8) NOT NULL,
    [ExitPriceTo]                      DECIMAL (22, 8) NOT NULL,
	[StopLoss]                      DECIMAL (22, 8) NOT NULL,
	[HasTechnical]                    BIT DEFAULT 0 NOT NULL,
    [Technical_Header]      NVARCHAR (300)  NULL ,
    [Technical_Description] NVARCHAR (MAX)  NULL,
	[Technical_References] NVARCHAR (MAX)  NULL,
    [Technical_Image_Url]      NVARCHAR (MAX)  NULL ,
    [Technical_Image_FileName] NVARCHAR (1000)  NULL,
	[HasFundamental]      BIT DEFAULT 0 NOT NULL,
    [Fundamental_Header]      NVARCHAR (300)  NULL,
    [Fundamental_Description] NVARCHAR (MAX)  NULL,
	[Fundamental_References] NVARCHAR (MAX)  NULL,
    [CreateDate]                      DATETIME2 (7)   CONSTRAINT [DF_Signals_CreateDate] DEFAULT (getdate()) NOT NULL,
    [PublishedDate]                   DATETIME2 (7)   NULL,
    [Duration] INT NOT NULL DEFAULT 10, 
    [PotentialProfitValue] DECIMAL(22, 8) NULL, 
    [PotentialProfit] INT NULL, 
	[KnokStatusId] INT NOT NULL DEFAULT 0, 
    [SellFinishDate] DATETIME2 NULL, 
	[Price] DECIMAL(22, 8) NULL, 
    [EntryPriceTouched] BIT NOT NULL DEFAULT 0, 
	[ExitPriceTouched] BIT NOT NULL DEFAULT 0, 
	[StopLossTouched] BIT NOT NULL DEFAULT 0, 
    [Ranks] DECIMAL NULL, 
	[HighRate] DECIMAL(22, 8) NOT NULL DEFAULT 0, 
	[LowRate] DECIMAL(22, 8) NOT NULL DEFAULT 0, 
    [UserReview] DECIMAL(22, 2) NULL, 
    [DistanceFromTarget] DECIMAL(22, 2) NULL, 
    [CloseDate] DATETIME NULL, 
    [CloseRate] DECIMAL(22, 8) NULL, 
    CONSTRAINT [PK_Signals] PRIMARY KEY CLUSTERED ([KnokId] ASC),
	CONSTRAINT [FK_Signals_Exchanges] FOREIGN KEY ([ExchangeId]) REFERENCES [dbo].[Exchanges] ([ExchangeId]),
	CONSTRAINT [FK_Signals_Tickers] FOREIGN KEY ([TickerId]) REFERENCES [dbo].[Tickers] ([TickerId]),
	CONSTRAINT [FK_Signals__KnokStatuses] FOREIGN KEY ([KnokStatusId]) REFERENCES [dbo].[_KnokStatuses] ([KnokStatusId])
);

