f**********w 发帖数: 93 | 1 I was askes a similar question, I gave the following data structure,
enum OrderType { BUY, SELL};
struct OrderInfo
{
// order information
double price;
OrderType ot;
int shares;
};
struct PriceComparator{
// compare OrderInfo based on price
bool operator() (const OrderInfo& lhs, const OrderInfo& rhs)
{
return lhs.price > rhs.price;
}
};
use hash_map to look up stockname from
orderId;
then use
hash_map |
|
a*******t 发帖数: 891 | 2 fryking's method should work, probably the correct way also.
but usually I just cheat and use
select max(stockName) as StockName, max(price) as MaxPrice
from StockData
where price is between 10 and 20 --your 2nd question
group by StockID
有 |
|
b*****e 发帖数: 474 | 3 if different names have different ids, would this work:
select StockName, max(price)
from StockData
group by StockID, StockName
select D1.*
from StockData as D1, (select StockID, max(price)
from StockData group by StockID) as D2
where D1.StockID = D2.StockID
AND D1.price < ...
有 |
|
w*s 发帖数: 7227 | 4 right now my test is like this,
need to add/update entries
Stock1Entities stock1Entities = new Stock1Entities();
var query = from c in stock1Entities.Level_1
where c.stockName == "spy"
select new
{
ID = c.stockName,
state = c.priceRange
};
foreach (var item in query)
{
Console.WriteL... 阅读全帖 |
|
w*s 发帖数: 7227 | 5 right now my test is like this,
need to add/update entries
Stock1Entities stock1Entities = new Stock1Entities();
var query = from c in stock1Entities.Level_1
where c.stockName == "spy"
select new
{
ID = c.stockName,
state = c.priceRange
};
foreach (var item in query)
{
Console.WriteL... 阅读全帖 |
|
w*s 发帖数: 7227 | 6 同学们,我的程序简化成这样,可以step in看到是在做这些。
todayDate 也是今天,但是mssql里面没有更新,mfiDate还是以前的日子,请问是为什
么?
if (MyGlobals.stock1Entities.TableMfis.Any(x => x.stockName == stock))
{
// update
TableMfi bMfi = MyGlobals.stock1Entities.TableMfis.Single(y => y.
stockName == stock);
// m_date[0] is sth. like "11-04-2013"
System.DateTime todayDate = Convert.ToDateTime(m_date[startDay]);
bMfi.mfiDate = todayDate;
bMfi.mfiValue = m_mfi[startDay];
... 阅读全帖 |
|
A*******y 发帖数: 11148 | 7 写了段SQL语法,数据库是很多股票月度performance
如果希望挑出每只股票价格最高的纪录的话,比如
select max(price)
from StockData
group by StockID
这样一来,如果我想加入其他字段,比如StockName,系统就会说即不在Group by又没有
aggregate。。。请问有什么解决办法吗?
还有,如果我想按照价格挑选所有字段,有什么办法不用手工输入所有字断名吗?
谢谢大家 |
|
H*******g 发帖数: 6997 | 8 if(stock1Entities.Level_1.Any(x=>x.stockName == "spy"))
{
//update
}
else
{
//create new
} |
|
H*******g 发帖数: 6997 | 9 if(stock1Entities.Level_1.Any(x=>x.stockName == "spy"))
{
//update
}
else
{
//create new
} |
|
D*****a 发帖数: 2847 | 10 用ftp软件例如filezilla上 sftp://Y****[email protected]
/wrds/crsp/sasdata/sd 下面有个stocknames的SAS数据
里面就是这种对应的信息 |
|