-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.rake
executable file
·65 lines (45 loc) · 1.12 KB
/
update.rake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require 'net/http'
require 'json'
require 'simple-rss'
require 'open-uri'
require 'net/imap'
require 'update'
require 'update_quote'
require 'core'
namespace :update do
task :quote => :environment do
# create new updater
puts "START updating quotes"
start_time = Time.now
updater = QuoteUpdater.new({})
updater.start
end_time = Time.now
time_delta = end_time - start_time
puts "Updating quotes took #{time_delta} seconds"
puts "END updating quotes"
end
task :symbol => :environment do
include Update
do_symbol
end
task :factor => :environment do
include Core
update_all_factors
end
task :cleanse_old => :environment do
include Util
sql = "DELETE from quotes where market_time < '#{time_to_sql_timestamp(add_days(DateTime.now, -40))}'"
Rails.logger.info sql
Quote.connection.execute(sql)
end
task :cleanse_factors => :environment do
include Util
sql = "TRUNCATE TABLE factors"
Rails.logger.info sql
Factor.connection.execute(sql)
end
task :regen_factors => :environment do
include Update
regen_factors
end
end