i created this script in ruby to calculate mfe mae. however it returns a active record and i cannot query its columns.
if i do a puts["mini"] i get
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)
i did a output of details and it is a of type TickData and the columsn that i am returning are aggregate type. how can i get the values
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"]
Your result is in
details[0]['mini'],details[0]['maxi']anddetails[0]['no']