0
我在ruby中創建了這個腳本來計算mfe mae。但它返回一個活動記錄,我不能查詢它的列。 如果我做了puts["mini"]
我得到我如何查詢返回的列
D:/TradingTools/torontotrader/app/helpers/rb1A5.tmp:28:in '[]': can't convert String into Integer (TypeError)
from D:/TradingTools/torontotrader/app/helpers/rb1A5.tmp:28
from D:/TradingTools/torontotrader/app/helpers/rb1A5.tmp:24:in `each'
from D:/TradingTools/torontotrader/app/helpers/rb1A5.tmp:24
Complete(1)
我做了細節的輸出,這是一個TickData
型的,我是被返回集合型的columsn的。我怎樣才能得到的值
class TickData < ActiveRecord::Base
set_table_name "tickdata"
end
class Trades < ActiveRecord::Base
set_table_name "trades"
end
class TradesReport < ActiveRecord::Base
set_table_name "tradesreport"
end
sql="select * from tradesreport where entry>=(select min(time) from tickdata) and exitt <=(select max(time) from tickdata)"
tradestocalculate= Trades.find_by_sql(sql)
tradestocalculate.each {|item|
sql="select MIN(LASTPRICE) as mini,MAX(LASTPRICE) as maxi,COUNT(*) as no from tickdata where time >='#{item['entry']}' AND time <= '#{item['exitt']}' and
symbol like '%#{item['symbol_alias'][0,3]}%'"
details= TickData.find_by_sql(sql)
puts details["mini"]
我覺得你這樣做是錯誤的。活動記錄是一個orm不是一個sql庫。爲此你會使用續集 – three 2012-02-25 21:06:28