Viewing 15 posts - 31 through 45 (of 73 total)
GSquared (12/3/2010)
select *
from dbo.MyTable
where @Parameter = 'A'
or ParentTradeID is not null and @Parameter = 'O'
or ParentTradeID is null and @Parameter = 'R';
Wouldn't that do it?
Of course, thanks. My brain...
December 3, 2010 at 6:36 am
Sachin Nandanwar (12/3/2010)
Cant you just use IF blocks ?
Yes, I could use IF blocks... 😉
December 3, 2010 at 6:35 am
Here's some more sample data
DELETE [accountperformance]
INSERT INTO [accountperformance] ([tradeId],[pctAccountRisked],[profit],[tradeDateTime])VALUES(1,3.00,110.000000,'Jan 19 2010 11:00:00:000AM')
INSERT INTO [accountperformance] ([tradeId],[pctAccountRisked],[profit],[tradeDateTime])VALUES(2,1.80,104.000000,'Jan 28 2010 3:00:00:000PM')
INSERT INTO [accountperformance] ([tradeId],[pctAccountRisked],[profit],[tradeDateTime])VALUES(3,3.00,463.000000,'Feb 3 2010 7:00:00:000PM')
INSERT INTO [accountperformance] ([tradeId],[pctAccountRisked],[profit],[tradeDateTime])VALUES(4,0.94,-50.000000,'Feb...
November 22, 2010 at 8:00 am
Thanks it doesn't give me the correct results for dates that are the same. Is there a tweak needed to do that?
November 22, 2010 at 6:16 am
WayneS (11/2/2010)
What you supplied has a purchase (IE) with price of 1.359400.
First sale (MX) of 1.364100.
Second sale (XXX) of 1.359700
so:
(1.359700 - 1.359400) + (1.364100 - 1.359400) = +0.005000
Perhaps I have...
November 3, 2010 at 1:37 am
Sorry, here you go 😀
INSERT INTO [orders] ([orderId],[tradeId],[units],[side],[price],[spread],[strategyId],[signalTypeId],[brokerId],[orderTypeId],[orderDateTime])VALUES(12,4,2,'S',1.359400,1.00,3,'IE',1,'SM','Feb 15 2010 7:00:00:000AM')
INSERT INTO [orders] ([orderId],[tradeId],[units],[side],[price],[spread],[strategyId],[signalTypeId],[brokerId],[orderTypeId],[orderDateTime])VALUES(14,4,1,'B',1.364100,1.00,3,'MX',1,'BM','Feb 16 2010 7:00:00:000AM')
INSERT INTO [orders] ([orderId],[tradeId],[units],[side],[price],[spread],[strategyId],[signalTypeId],[brokerId],[orderTypeId],[orderDateTime])VALUES(13,4,1,'B',1.359700,1.00,3,'XXX',1,'BM','Feb 16 2010 7:00:00:000PM')
November 2, 2010 at 9:43 am
Profit should be the sale price - purchase price. Have a look at tradeId 4.
Buy 1 unit at 1.3641
Buy 1 unit at 1.3597
Sell 2 units at 1.3594
The profit should be...
November 2, 2010 at 9:10 am
Chris Morris-439714 (11/2/2010)
I think your profit expression is incorrect:profit = sum(p.Price - s.Price)
it should be selling price minus purchase price.
Chris that is not the case because all the other values...
November 2, 2010 at 7:29 am
Hi Guys,
I've just added some more sample data and realised that the values of the profit column are wrong. here's some extra sample data to show the wrong values:
INSERT INTO...
November 2, 2010 at 7:01 am
Well Chris that was pretty impressive without an instance of SQL Server to test on. Works great, and thanks very much! 😎
October 27, 2010 at 6:40 am
🙂 I hope your manflu is being kind to you. I now get:
Msg 207, Level 16, State 1, Line 18
Invalid column name 'rn'.
October 27, 2010 at 6:23 am
Thanks I did that and I now get:
Msg 207, Level 16, State 1, Line 5
Invalid column name 'accountPerformance'.
:unsure:
October 27, 2010 at 6:02 am
Hi Chris, thanks for you reply. It doesn't seem to work, I get this error:
Msg 137, Level 15, State 2, Line 18
Must declare the scalar variable "@nannyRisk".
October 27, 2010 at 4:50 am
Yes the max memory SQL Server can take will be limited to the value you have specified, in your case 4 GB. Bear in mind though that the cache will...
October 27, 2010 at 4:49 am
Viewing 15 posts - 31 through 45 (of 73 total)