Гидра. S# 4.0
Atom
9/29/2011


В последней версии Гидры были изменения в SQL. Нужно прогнать следующий скрипт, чтобы новая Гидра смогла работать со старой БД:

Code
alter proc [dbo].[Security_UpdateById]
	@Id as nvarchar(256),
	@Name as nvarchar(512),
	@Code as nvarchar(256),
	@Class as nvarchar(256),
	@ShortName as nvarchar(256),
	@MinStepSize decimal(18,7),
	@MinStepPrice decimal(18,7),
	@MinLotSize real,
	@Decimals real,
	@OpenPrice decimal(18,7),
	@ClosePrice decimal(18,7),
	@LowPrice decimal(18,7),
	@HighPrice decimal(18,7),
	@State int,
	@Type int,
	@MinPrice decimal(18,7),
	@MaxPrice decimal(18,7),
	@MarginBuy decimal(18,7),
	@MarginSell decimal(18,7),
	@ExpiryDate datetime,
	@SettlementDate datetime,
	@ExtensionInfo nvarchar(max),
	@LastTradeId bigint = null,
	@LastTradeTime datetime2(7) = null,
	@LastTradePrice decimal(18,7) = null,
	@LastTradeVolume decimal(18,7) = null,
	@LastTradeOrderDirection int = null,
	@BestBidPrice decimal(18,7) = null,
	@BestBidVolume decimal(18,7) = null,
	@BestBidOrderDirection int = null,
	@BestAskPrice decimal(18,7) = null,
	@BestAskVolume decimal(18,7) = null,
	@BestAskOrderDirection int = null,
	@Exchange nvarchar(64),
	@UnderlyingSecurityId nvarchar(256),
	@Strike decimal(18,7),
	@OptionType int,
	@Volatility decimal(18,7),
	@TheorPrice decimal(18,7)
as
begin transaction

declare @ExtensionInfoXml xml
set @ExtensionInfoXml = convert(xml, @ExtensionInfo, 1)

declare @FinamMarketId bigint
declare @FinamSecurityId bigint
declare @Source nvarchar(128)
declare @TradeSource nvarchar(128)
declare @DepthSource nvarchar(128)
declare @IsSelected bit
declare @TradeCount int
declare @DepthCount int
declare @LastUpdateTime datetime

set @FinamMarketId = @ExtensionInfoXml.value(N'(/IDictionaryBeginObjectAndObjectEnd/KeyValuePairBeginObjectAndObjectEnd[key/Value = "FinamMarketId"]/value/Value)[1]', 'bigint')
set @FinamSecurityId = @ExtensionInfoXml.value(N'(/IDictionaryBeginObjectAndObjectEnd/KeyValuePairBeginObjectAndObjectEnd[key/Value = "FinamSecurityId"]/value/Value)[1]', 'bigint')
set @Source = @ExtensionInfoXml.value(N'(/IDictionaryBeginObjectAndObjectEnd/KeyValuePairBeginObjectAndObjectEnd[key/Value = "Source"]/value/Value)[1]', 'nvarchar(128)')
set @TradeSource = @ExtensionInfoXml.value(N'(/IDictionaryBeginObjectAndObjectEnd/KeyValuePairBeginObjectAndObjectEnd[key/Value = "TradeSource"]/value/Value)[1]', 'nvarchar(128)')
set @DepthSource = @ExtensionInfoXml.value(N'(/IDictionaryBeginObjectAndObjectEnd/KeyValuePairBeginObjectAndObjectEnd[key/Value = "DepthSource"]/value/Value)[1]', 'nvarchar(128)')
set @IsSelected = IsNull(@ExtensionInfoXml.value(N'(/IDictionaryBeginObjectAndObjectEnd/KeyValuePairBeginObjectAndObjectEnd[key/Value = "IsSelected"]/value/Value)[1]', 'bit'), 0)
set @TradeCount = IsNull(@ExtensionInfoXml.value(N'(/IDictionaryBeginObjectAndObjectEnd/KeyValuePairBeginObjectAndObjectEnd[key/Value = "TradeCount"]/value/Value)[1]', 'int'), 0)
set @DepthCount = IsNull(@ExtensionInfoXml.value(N'(/IDictionaryBeginObjectAndObjectEnd/KeyValuePairBeginObjectAndObjectEnd[key/Value = "DepthCount"]/value/Value)[1]', 'int'), 0)
--set @LastUpdateTime = @ExtensionInfoXml.value(N'(/IDictionaryBeginObjectAndObjectEnd/KeyValuePairBeginObjectAndObjectEnd[key/Value = "LastUpdateTime"]/value/Value)[1]', 'datetime')

begin try
	if (exists(select * from [Security] where Id = @Id))
	begin
		update [Security]
		set
			Name = @Name,
			Code = @Code,
			Class = @Class,
			ShortName = @ShortName,
			MinStepSize = @MinStepSize,
			MinStepPrice = @MinStepPrice,
			MinLotSize = @MinLotSize,
			Decimals = @Decimals,
			OpenPrice = @OpenPrice,
			ClosePrice = @ClosePrice,
			LowPrice = @LowPrice,
			HighPrice = @HighPrice,
			[State] = @State,
			[Type] = @Type,
			MinPrice = @MinPrice,
			MaxPrice = @MaxPrice,
			MarginBuy = @MarginBuy,
			MarginSell = @MarginSell,
			ExpiryDate = @ExpiryDate,
			SettlementDate = @SettlementDate,
			ExtensionInfo = @ExtensionInfo,
			LastTradeId = @LastTradeId,
			LastTradeTime = @LastTradeTime,
			LastTradePrice = @LastTradePrice,
			LastTradeVolume = @LastTradeVolume,
			LastTradeOrderDirection = @LastTradeOrderDirection,
			BestBidPrice = @BestBidPrice,
			BestBidVolume = @BestBidVolume,
			BestBidOrderDirection = @BestBidOrderDirection,
			BestAskPrice = @BestAskPrice,
			BestAskVolume = @BestAskVolume,
			BestAskOrderDirection = @BestAskOrderDirection,
			Exchange = @Exchange,
			UnderlyingSecurityId = @UnderlyingSecurityId,
			Strike = @Strike,
			OptionType = @OptionType,
			Volatility = @Volatility,
			TheorPrice = @TheorPrice
		where
			Id = @Id

		update HydraSecurityInfo
		set
			FinamMarketId = @FinamMarketId,
			FinamSecurityId = @FinamSecurityId,
			[Source] = @Source,
			TradeSource = @TradeSource,
			DepthSource = @DepthSource,
			IsSelected = @IsSelected,
			TradeCount = @TradeCount,
			DepthCount = @DepthCount,
			LastUpdateTime = @LastUpdateTime
		where
			[Security] = @Id
	end
	else
	begin
		insert into [Security]
			(Id, Name, Code, Class, ShortName, MinStepSize, MinStepPrice, MinLotSize, Decimals,
			OpenPrice, ClosePrice, LowPrice, HighPrice, [State], [Type], MinPrice, MaxPrice, MarginBuy, MarginSell, ExpiryDate,
			SettlementDate, ExtensionInfo, LastTradeId, LastTradeTime, LastTradePrice, LastTradeVolume, LastTradeOrderDirection,
			BestBidPrice, BestBidVolume, BestBidOrderDirection, BestAskPrice, BestAskVolume, BestAskOrderDirection, Exchange,
			OptionType, Strike,UnderlyingSecurityId, Volatility, TheorPrice)
		values
			(@Id, @Name, @Code, @Class, @ShortName, @MinStepSize, @MinStepPrice, @MinLotSize, @Decimals,
			@OpenPrice, @ClosePrice, @LowPrice, @HighPrice, @State, @Type, @MinPrice, @MaxPrice, @MarginBuy, @MarginSell, @ExpiryDate,
			@SettlementDate, @ExtensionInfo, @LastTradeId, @LastTradeTime, @LastTradePrice, @LastTradeVolume, @LastTradeOrderDirection,
			@BestBidPrice, @BestBidVolume, @BestBidOrderDirection, @BestAskPrice, @BestAskVolume, @BestAskOrderDirection, @Exchange,
			@OptionType, @Strike, @UnderlyingSecurityId, @Volatility, @TheorPrice)

		insert into HydraSecurityInfo
			([Security], TradeSource, DepthSource, [Source], IsSelected, TradeCount, DepthCount, FinamMarketId, FinamSecurityId, LastUpdateTime)
		values
           (@Id, @TradeSource, @DepthSource, @Source, @IsSelected, @TradeCount, @DepthCount, @FinamMarketId, @FinamSecurityId, @LastUpdateTime)
	end
end try
begin catch
	if @@TRANCOUNT > 0
		rollback transaction
		
	print 'Error Number: ' + str(error_number()) 
	print 'Line Number: ' + str(error_line())
	print error_message()
	
	exec usp_RethrowError
end catch

if @@TRANCOUNT > 0
	commit transaction
	
GO

ALTER TABLE [dbo].[Security] ALTER COLUMN [Strike] DECIMAL (18,7) NOT NULL;
ALTER TABLE [dbo].[Security] ALTER COLUMN [TheorPrice] DECIMAL (18,7) NOT NULL;
ALTER TABLE [dbo].[Security] ALTER COLUMN [Volatility] DECIMAL (18,7) NOT NULL;

ALTER TABLE [dbo].[Security] ALTER COLUMN [BestAskOrderDirection] INT NULL;
ALTER TABLE [dbo].[Security] ALTER COLUMN [BestAskPrice] DECIMAL (18,7) NULL;
ALTER TABLE [dbo].[Security] ALTER COLUMN [BestAskVolume] DECIMAL (18,7) NULL;

ALTER TABLE [dbo].[Security] ALTER COLUMN [BestBidOrderDirection] INT NULL;
ALTER TABLE [dbo].[Security] ALTER COLUMN [BestBidPrice] DECIMAL (18,7) NULL;
ALTER TABLE [dbo].[Security] ALTER COLUMN [BestBidVolume] DECIMAL (18,7) NULL;

ALTER TABLE [dbo].[Security] ALTER COLUMN [LastTradeId] BIGINT NULL;
ALTER TABLE [dbo].[Security] ALTER COLUMN [LastTradePrice] DECIMAL (18,7) NULL;
ALTER TABLE [dbo].[Security] ALTER COLUMN [LastTradeTime] DATETIME2 (7) NULL;
ALTER TABLE [dbo].[Security] ALTER COLUMN [LastTradeVolume] DECIMAL (18,7) NULL;


ALTER TABLE [dbo].[MarketDataSourceSettings] add FilterBySecurities bit NULL;

go

update [dbo].[MarketDataSourceSettings]
set
	[StorageFolder] = N''
where
	[StorageFolder] is null

update [dbo].[MarketDataSourceSettings]
set
	FilterBySecurities = 0
where
	FilterBySecurities is null

go

ALTER TABLE [dbo].[MarketDataSourceSettings] ALTER COLUMN [StorageFolder] [nvarchar](2048) NOT NULL;
ALTER TABLE [dbo].[MarketDataSourceSettings] ALTER COLUMN FilterBySecurities bit NOT NULL;

go

alter proc [dbo].[MarketDataSourceSettings_UpdateBySourceId]
	@SourceId as uniqueidentifier,
	@IsEnabled as bit,
	@WorkingFrom as time(7),
	@WorkingTo as time(7),
	@Interval as time(7),
	@DumpFolder nvarchar(2048),
	@StorageFolder nvarchar(2048),
	@ExtensionInfo nvarchar(max),
	@FilterBySecurities bit
as
if (exists(select * from MarketDataSourceSettings where SourceId = @SourceId))
	update MarketDataSourceSettings
	set
		IsEnabled = @IsEnabled,
		WorkingFrom = @WorkingFrom,
		WorkingTo = @WorkingTo,
		Interval = @Interval,
		DumpFolder = @DumpFolder,
		StorageFolder = @StorageFolder,
		ExtensionInfo = @ExtensionInfo,
		FilterBySecurities = @FilterBySecurities
	where
		SourceId = @SourceId
else
	insert into MarketDataSourceSettings
		(SourceId, IsEnabled, WorkingFrom, WorkingTo, Interval, DumpFolder, StorageFolder, ExtensionInfo, FilterBySecurities)
	values
		(@SourceId, @IsEnabled, @WorkingFrom, @WorkingTo, @Interval, @DumpFolder, @StorageFolder, @ExtensionInfo, @FilterBySecurities)

Tags:


Thanks:


1 2  >
mikhaylovvl

Avatar
Date: 10/4/2011
Reply


Михаил, подскажи пожалуйста в каком именно проекте (название файла) прогнать код?
Спасибо.
Thanks:

Alexander

Avatar
Date: 10/4/2011
Reply


mikhaylovvl Go to
Михаил, подскажи пожалуйста в каком именно проекте (название файла) прогнать код?
Спасибо.


sql
Thanks:

bender

Avatar
Date: 10/12/2011
Reply


Скачал Гидру 4.0.2, при построении выдаёт ошибку:
Quote:
Ошибка 1 выход из команды "call ..\..\..\plugins.bat Plaza Debug

copy StockSharp.Plaza.dll ..\..\..\..\Hydra\bin\Debug\Plugins\StockSharp.Plaza.dll
copy ..\..\..\..\..\References\Interop.P2ClientGateMTA32.dll ..\..\..\..\Hydra\bin\Debug\Plugins\Interop.P2ClientGateMTA32.dll
copy ..\..\..\..\..\References\Interop.P2ClientGateMTA64.dll ..\..\..\..\Hydra\bin\Debug\Plugins\Interop.P2ClientGateMTA64.dll

if Debug == Debug goto :debug

goto :exit

:debug
copy StockSharp.Plaza.pdb ..\..\..\..\Hydra\bin\Debug\Plugins\StockSharp.Plaza.pdb

:exit" с кодом 1. Plaza

А при попытке отладки исключение:
Thanks:

Mikhail Sukhov

Avatar
Date: 10/12/2011
Reply


Для нее нужно выполнить скрипт \Documentation\trading_3.2_4.0.sql
Thanks:

bender

Avatar
Date: 10/12/2011
Reply


Я выполнил. Сейчас старую базу вообще удалил, создал новую скриптом trading.sql, всё тоже самое
Thanks:

Mikhail Sukhov

Avatar
Date: 10/12/2011
Reply


bender Go to
Я выполнил. Сейчас старую базу вообще удалил, создал новую скриптом trading.sql, всё тоже самое


Приношу извинения. Возьмите последнюю версию BusinessEntities (залил пару минут назад). Плюс посмотрите на дифф http://stocksharp.codepl...on%2ftrading_3.2_4.0.sql
Thanks:

Mikhail Sukhov

Avatar
Date: 10/17/2011
Reply


Для перехода на 4.0.3 необходимо выполнить скрипт:

Code
ALTER TABLE [dbo].[Exchange] add ExpiryTime bigint NULL;
ALTER TABLE [dbo].[Exchange] add IsSupportAtomicReRegister bit NULL;

GO

update [dbo].[Exchange]
set
	ExpiryTime = 0,
	IsSupportAtomicReRegister = 0

GO

ALTER TABLE [dbo].[Exchange] ALTER COLUMN ExpiryTime bigint NOT NULL;
ALTER TABLE [dbo].[Exchange] ALTER COLUMN IsSupportAtomicReRegister bit NOT NULL;

GO
ALTER PROCEDURE [dbo].[Exchange_UpdateByName]
	@Name as nvarchar(64),
	@Times as nvarchar(max),
	@SpecialWorkingDays as nvarchar(max),
	@SpecialHolidays as nvarchar(max),
	@ExtensionInfo as nvarchar(max),
	@ExpiryTime bigint,
	@IsSupportAtomicReRegister bit
as
if (exists(select * from Exchange where Name = @Name))
	update Exchange
	set
		Times = @Times,
		SpecialWorkingDays = @SpecialWorkingDays,
		SpecialHolidays = @SpecialHolidays,
		ExtensionInfo = @ExtensionInfo,
		ExpiryTime = @ExpiryTime,
		IsSupportAtomicReRegister = @IsSupportAtomicReRegister
	where
		Name = @Name
else
	insert into Exchange
		(Name, Times, SpecialWorkingDays, SpecialHolidays, ExtensionInfo, ExpiryTime, IsSupportAtomicReRegister)
	values
		(@Name, @Times, @SpecialWorkingDays, @SpecialHolidays, @ExtensionInfo, @ExpiryTime, @IsSupportAtomicReRegister)
Thanks:

DT

Avatar
Date: 10/19/2011
Reply


Последний скрипт выполняется с ошибкой:

Quote:
Msg 4902, Level 16, State 1, Line 1
Cannot find the object "dbo.Exchange" because it does not exist or you do not have permissions.
Msg 208, Level 16, State 1, Line 2
Invalid object name 'dbo.Exchange'.
Msg 4902, Level 16, State 1, Line 2
Cannot find the object "dbo.Exchange" because it does not exist or you do not have permissions.
Msg 208, Level 16, State 6, Procedure Exchange_UpdateByName, Line 22
Invalid object name 'dbo.Exchange_UpdateByName'.
Thanks:

Mikhail Sukhov

Avatar
Date: 10/19/2011
Reply


DT Go to
Последний скрипт выполняется с ошибкой:


Скрипт на базе Trading прогоняется? По умолчанию он пытается выполнится на master базе.
Thanks: DT

DT

Avatar
Date: 10/19/2011
Reply


Да, проблема была в этом. Спасибо
Thanks:
1 2  >

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

loading
clippy