В последней версии Гидры были изменения в SQL. Нужно прогнать следующий скрипт, чтобы новая Гидра смогла работать со старой БД:
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)
Comments (12)
Login or Create account, Log in or register to leave a comment
Михаил, подскажи пожалуйста в каком именно проекте (название файла) прогнать код? Спасибо.
sql
Скачал Гидру 4.0.2, при построении выдаёт ошибку:
Гидра 00:23:03.5468750 System.Windows.Markup.XamlParseException: Не удается создать экземпляр "MainWindow", определенный в сборке "Hydra, Version=4.0.2.0, Culture=neutral, PublicKeyToken=null". Адресат вызова создал исключение. Ошибка в файле разметки "Hydra;component/MainWindow.xaml", строка 1, позиция 9. ---> System.Reflection.TargetInvocationException: Адресат вызова создал исключение. ---> System.InvalidCastException: Не удалось преобразовать значение параметра из TimeSpan в Int64. ---> System.InvalidCastException: Объект должен реализовывать интерфейс IConvertible. в System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) в System.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType) --- Конец трассировки внутреннего стека исключений --- в System.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType) в System.Data.SqlClient.SqlParameter.GetCoercedValue() в System.Data.SqlClient.SqlParameter.Validate(Int32 index, Boolean isCommandProc) в System.Data.SqlClient.SqlCommand.SetUpRPCParameters(_SqlRPC rpc, Int32 startCount, Boolean inSchema, SqlParameterCollection parameters) в System.Data.SqlClient.SqlCommand.BuildRPC(Boolean inSchema, SqlParameterCollection parameters, _SqlRPC& rpc) в System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) в System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) в System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) в System.Data.SqlClient.SqlCommand.ExecuteNonQuery() в Ecng.Data.DatabaseCommand.<ExecuteNonQuery>b__5(DbCommand cmd) в Ecng.Data.DatabaseCommand.<>c__DisplayClass3
1.<Execute>b__0(DbConnection connection) в Ecng.Data.Database.GetConnection(Action1 action) в Ecng.Data.DatabaseCommand.Execute[TResult](IEnumerable1 input, Func2 handler) в Ecng.Data.DatabaseCommand.ExecuteNonQuery(SerializationItemCollection input) в Ecng.Data.Database.Execute(DatabaseCommand command, SerializationItemCollection source, Boolean needRetVal) в Ecng.Data.Database.Update(DatabaseCommand command, SerializationItemCollection source, Boolean needRetVal) в Ecng.Data.Database.<>c__DisplayClassf1.<Update>b__e() в Ecng.Data.Database.Update[TEntity](TEntity entity, FieldCollection keyFields, FieldCollection valueFields) в Ecng.Data.Database.Update[TEntity](TEntity entity, FieldCollection valueFields) в Ecng.Data.Database.Update[TEntity](TEntity entity) в Ecng.Serialization.RelationManyList1.OnUpdate(TEntity entity) в Ecng.Data.HierarchicalPageLoadList1.OnUpdate(TEntity entity) в Ecng.Serialization.RelationManyList1.Update(TEntity entity) в StockSharp.Algo.Storages.BaseStorageEntityList`1.Save(T entity) в StockSharp.Hydra.MainWindow..ctor() в C:\Documents and Settings\Yura\Мои документы\Загрузки\StockSharp_4.0.2_Sources\Hydra\Hydra\MainWindow.xaml.cs:строка 56 --- Конец трассировки внутреннего стека исключений --- в System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) в System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) в System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) в System.Activator.CreateInstance(Type type, Boolean nonPublic) в System.Windows.Markup.BamlRecordReader.CreateInstanceFromType(Type type, Int16 typeId, Boolean throwOnFail) --- Конец трассировки внутреннего стека исключений --- в System.Windows.Markup.XamlParseException.ThrowException(String message, Exception innerException, Int32 lineNumber, Int32 linePosition, Uri baseUri, XamlObjectIds currentXamlObjectIds, XamlObjectIds contextXamlObjectIds, Type objectType) в System.Windows.Markup.XamlParseException.ThrowException(ParserContext parserContext, Int32 lineNumber, Int32 linePosition, String message, Exception innerException) в System.Windows.Markup.BamlRecordReader.ThrowExceptionWithLine(String message, Exception innerException) в System.Windows.Markup.BamlRecordReader.CreateInstanceFromType(Type type, Int16 typeId, Boolean throwOnFail) в System.Windows.Markup.BamlRecordReader.GetElementAndFlags(BamlElementStartRecord bamlElementStartRecord, Object& element, ReaderFlags& flags, Type& delayCreatedType, Int16& delayCreatedTypeId) в System.Windows.Markup.BamlRecordReader.BaseReadElementStartRecord(BamlElementStartRecord bamlElementRecord) в System.Windows.Markup.BamlRecordReader.ReadElementStartRecord(BamlElementStartRecord bamlElementRecord) в System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord) в System.Windows.Markup.BamlRecordReader.Read(Boolean singleRecord) в System.Windows.Markup.TreeBuilderBamlTranslator.ParseFragment() в System.Windows.Markup.TreeBuilder.Parse() в System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream) в System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc) в System.Windows.Application.LoadComponent(Uri resourceLocator, Boolean bSkipJournaledProperties) в System.Windows.Application.DoStartup() в System.Windows.Application.<.ctor>b__0(Object unused) в System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter) в System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)Для нее нужно выполнить скрипт \Documentation\trading_3.2_4.0.sql
Я выполнил. Сейчас старую базу вообще удалил, создал новую скриптом trading.sql, всё тоже самое
Приношу извинения. Возьмите последнюю версию BusinessEntities (залил пару минут назад). Плюс посмотрите на дифф http://stocksharp.codeplex.com/SourceControl/changeset/changes/10430#Documentation%2ftrading_3.2_4.0.sql
Для перехода на 4.0.3 необходимо выполнить скрипт:
Для перехода на 4.0.4 нужно обновить БД. Подробности, в диффе на trading_3.2_4.0.sql
Последний скрипт выполняется с ошибкой:
Скрипт на базе Trading прогоняется? По умолчанию он пытается выполнится на master базе.
Да, проблема была в этом. Спасибо
Чтоб не контролировать какая база в данный момент активна, первой строкой можно вставлять - use Trading.