finexclub 0.3.4 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.4
1
+ 0.4.3
@@ -26,6 +26,10 @@ module Generator
26
26
  def rand_index
27
27
  rand(100)
28
28
  end
29
+
30
+ def rand_array(arr)
31
+ arr[rand(arr.length)]
32
+ end
29
33
  end
30
34
 
31
35
 
@@ -35,8 +39,10 @@ module Generator
35
39
  end
36
40
 
37
41
  def generate(options = {})
42
+ timeframe = options[:timeframe] || raise("--tf option is missing")
38
43
  Finexclub::Chart::SYMBOLS.inject([]) do |data, symbol|
39
44
  data << ["alpha[][symbol]", symbol.upcase]
45
+ data << ["alpha[][timeframe]", timeframe]
40
46
  data << ["alpha[][index]", Generator.rand_index]
41
47
  data << ["alpha[][direction]", rand > 0.5? 1 : 0]
42
48
  end
@@ -50,8 +56,10 @@ module Generator
50
56
 
51
57
  def generate(options = {})
52
58
  symbol = options[:symbol] || raise("--symbol option is missing")
59
+ timeframe = options[:timeframe] || raise("--tf option is missing")
53
60
  data = []
54
61
  data << ["zeta[][symbol]", symbol.upcase]
62
+ data << ["zeta[][timeframe]", timeframe]
55
63
  data << ["zeta[][up_support]", Generator.rand_price]
56
64
  data << ["zeta[][up_resist]", Generator.rand_price]
57
65
  data << ["zeta[][down_support]", Generator.rand_price]
@@ -67,13 +75,20 @@ module Generator
67
75
 
68
76
  def generate(options = {})
69
77
  symbol = options[:symbol] || raise("--symbol option is missing")
78
+ timeframe = options[:timeframe] || raise("--tf option is missing")
70
79
  actions = %w(buy sell hold_sell hold_buy stop)
71
80
  data = []
72
81
  data << ["prognosis[][symbol]", symbol.upcase]
82
+ data << ["prognosis[][timeframe]", timeframe]
73
83
  data << ["prognosis[][action]", actions[rand(actions.size)]]
74
84
  data << ["prognosis[][take_profit]", Generator.rand_price]
75
- data << ["prognosis[][profit]", Generator.rand_index]
76
- data << ["prognosis[][screenshot_filename]", "PROGNOSIS.png"]
85
+ data << ["prognosis[][profit]", rand(100)]
86
+ data << ["prognosis[][stop_loss]", Generator.rand_price]
87
+ data << ["prognosis[][loss]", rand(100)]
88
+ data << ["prognosis[][acceleration]", Generator.rand_array(%w(low high undefined))]
89
+ data << ["prognosis[][tsi]", Generator.rand_index]
90
+ data << ["prognosis[][trend]", rand > 0.4 ? 1 : 0 ]
91
+ data << ["prognosis[][screenshot_filename]", "PROGNOSIS.gif"]
77
92
  end
78
93
  end
79
94
 
@@ -84,16 +99,20 @@ module Generator
84
99
 
85
100
  def generate(options = {})
86
101
  symbol = options[:symbol] || raise("--symbol option is missing")
102
+ timeframe = options[:timeframe] || raise("--tf option is missing")
87
103
  actions = %w(buy sell hold_sell hold_buy stop)
88
104
  data = []
89
105
  data << ["octopus[][symbol]", symbol.upcase]
106
+ data << ["octopus[][timeframe]", timeframe]
90
107
  data << ["octopus[][action]", actions[rand(actions.size)]]
91
108
  data << ["octopus[][take_profit]", Generator.rand_price]
92
109
  data << ["octopus[][profit]", rand(100)]
93
110
  data << ["octopus[][stop_loss]", Generator.rand_price]
94
111
  data << ["octopus[][loss]", rand(100)]
95
112
  data << ["octopus[][index]", Generator.rand_index]
96
- data << ["octopus[][screenshot_filename]", "OCTOPUS.png"]
113
+ data << ["octopus[][tsi]", Generator.rand_index]
114
+ data << ["octopus[][trend]", rand > 0.4 ? 1 : 0 ]
115
+ data << ["octopus[][screenshot_filename]", "OCTOPUS.gif"]
97
116
  end
98
117
  end
99
118
  end
@@ -122,7 +141,10 @@ class FakeUpdater
122
141
  end
123
142
  end
124
143
 
125
- STRATEGIES = %w(trends finexclub)
144
+ STRATEGIES = %w(trends finexclub octopus prognosis)
145
+ FINEXCLUB_TIMEFRAMES = %w(h1 h4 d1)
146
+ TRENDSONFOREX_SYMBOLS = Finexclub::Chart::SYMBOLS
147
+ FINEXCLUB_SYMBOLS = %w(eurusd gbpusd eurgbp audusd usdjpy usdcad)
126
148
 
127
149
  options = {}
128
150
  options[:host] = 'localhost'
@@ -142,6 +164,10 @@ opts = OptionParser.new do |opts|
142
164
  options[:symbol] = s
143
165
  end
144
166
 
167
+ opts.on("-t", "--tf TIMEFRAME", "Timeframe (h1, h4, d1)") do |t|
168
+ options[:timeframe] = t
169
+ end
170
+
145
171
  opts.on_tail("-h", "Help") do |s|
146
172
  puts opts
147
173
  exit
@@ -162,18 +188,28 @@ unless options[:generator].nil?
162
188
  exit
163
189
  end
164
190
 
191
+ f = FakeUpdater.new(options[:host], options[:port])
192
+
165
193
  case options[:strategy]
166
194
  when 'trends'
167
- f = FakeUpdater.new(options[:host], options[:port])
168
- f.send(Generator::Alpha.new)
195
+ f.send(Generator::Alpha.new, :timeframe => 'h1')
169
196
  Finexclub::Chart::SYMBOLS.each do |symbol|
170
- f.send(Generator::Zeta.new, :symbol => symbol)
197
+ f.send(Generator::Zeta.new, :symbol => symbol, :timeframe => 'h1')
171
198
  end
172
199
  when 'finexclub'
173
- f = FakeUpdater.new(options[:host], options[:port])
174
- Finexclub::Chart::SYMBOLS.each do |symbol|
175
- f.send(Generator::Octopus.new, :symbol => symbol)
176
- f.send(Generator::Prognosis.new, :symbol => symbol)
200
+ FINEXCLUB_TIMEFRAMES.each do |tf|
201
+ FINEXCLUB_SYMBOLS.each do |symbol|
202
+ f.send(Generator::Octopus.new, :symbol => symbol, :timeframe => tf)
203
+ f.send(Generator::Prognosis.new, :symbol => symbol, :timeframe => tf)
204
+ end
205
+ end
206
+ when 'octopus'
207
+ FINEXCLUB_SYMBOLS.each do |symbol|
208
+ f.send(Generator::Octopus.new, :symbol => symbol, :timeframe => 'h1')
209
+ end
210
+ when 'prognosis'
211
+ FINEXCLUB_SYMBOLS.each do |symbol|
212
+ f.send(Generator::Prognosis.new, :symbol => symbol, :timeframe => 'h1')
177
213
  end
178
214
  else
179
215
  puts opts
data/finexclub.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{finexclub}
8
- s.version = "0.3.4"
8
+ s.version = "0.4.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alex Levin"]
12
- s.date = %q{2010-12-03}
12
+ s.date = %q{2010-12-20}
13
13
  s.default_executable = %q{finexclub_updater}
14
14
  s.description = %q{Finexclub gem stores and retrieves Forex signals and screenshots. It is the heart of the http://trendsonforex.com and http://finexclub.net}
15
15
  s.email = %q{clubfinex@gmail.com}
@@ -6,6 +6,7 @@ module Finexclub
6
6
 
7
7
  field :updated, :timestamp
8
8
  field :symbol, :symbol
9
+ field :timeframe, :string
9
10
  field :date, :string
10
11
 
11
12
  attr_reader :core
@@ -36,6 +36,7 @@ module Finexclub
36
36
  signal = Signal.build(core, signal_type, params.merge(:updated => Time.now))
37
37
  c = {
38
38
  :symbol => signal.symbol,
39
+ :timeframe => signal.timeframe,
39
40
  :date => signal.updated_at.strftime("%Y-%m-%d")
40
41
  }
41
42
  collection.update(c, {"$push" => {signal_type => signal.to_doc}, "$set" => {:updated => signal.updated}}, :upsert => true)
@@ -3,6 +3,7 @@ module Finexclub
3
3
 
4
4
  class Alpha < Signal
5
5
  field :symbol, :symbol
6
+ field :timeframe, :string
6
7
  field :updated, :timestamp
7
8
  field :index, :integer
8
9
  field :direction, :integer
@@ -3,6 +3,7 @@ module Finexclub
3
3
 
4
4
  class Octopus < Signal
5
5
  field :symbol, :symbol
6
+ field :timeframe, :string
6
7
  field :updated, :timestamp
7
8
  field :action, :trade_action
8
9
  field :take_profit, :float
@@ -10,9 +11,11 @@ module Finexclub
10
11
  field :stop_loss, :float
11
12
  field :loss, :integer
12
13
  field :index, :integer
14
+ field :tsi, :integer
15
+ field :trend, :integer # 1 - uptrend, 0 - downtrend
13
16
  field :screenshot, :image
14
17
 
15
- doc_fields :updated, :action, :take_profit, :profit, :stop_loss, :loss, :index, :screenshot
18
+ doc_fields :updated, :action, :take_profit, :profit, :stop_loss, :loss, :index, :tsi, :trend, :screenshot
16
19
  end
17
20
 
18
21
  end
@@ -3,14 +3,19 @@ module Finexclub
3
3
 
4
4
  class Prognosis < Signal
5
5
  field :symbol, :symbol
6
+ field :timeframe, :string
6
7
  field :updated, :timestamp
7
8
  field :action, :trade_action
8
- field :acceleration, :string
9
+ field :acceleration, :string # high, low, undefined
9
10
  field :take_profit, :float
10
11
  field :profit, :integer
12
+ field :stop_loss, :float
13
+ field :loss, :integer
14
+ field :tsi, :integer
15
+ field :trend, :integer # 1 - uptrend, 0 - downtrend
11
16
  field :screenshot, :image
12
17
 
13
- doc_fields :updated, :action, :acceleration, :take_profit, :profit, :screenshot
18
+ doc_fields :updated, :action, :acceleration, :take_profit, :profit, :stop_loss, :loss, :tsi, :trend, :screenshot
14
19
  end
15
20
 
16
21
  end
@@ -3,6 +3,7 @@ module Finexclub
3
3
 
4
4
  class Zeta < Signal
5
5
  field :symbol, :symbol
6
+ field :timeframe, :string
6
7
  field :updated, :timestamp
7
8
 
8
9
  field :up_support, :float
@@ -3,13 +3,32 @@ require File.dirname(__FILE__) + '/../spec_helper'
3
3
  describe 'Finexclub::Signals::Alpha' do
4
4
  before do
5
5
  @core = mock_core
6
- @signal = Finexclub::Signals::Alpha.new(@core)
6
+ @alpha = Finexclub::Signals::Alpha.new(@core)
7
7
  end
8
8
 
9
- it 'should provide attribute accessors' do
10
- @signal.build("direction" => 1, "index" => 100)
11
- @signal.direction.should == 1
12
- @signal.index.should == 100
9
+ it 'should have meta' do
10
+ Finexclub::Signals::Alpha.meta.should == {
11
+ :symbol => :symbol,
12
+ :timeframe => :string,
13
+ :updated => :timestamp,
14
+ :index => :integer,
15
+ :direction => :integer
16
+ }
17
+ end
18
+
19
+ it 'should export valid doc' do
20
+ @alpha.build(
21
+ "symbol" => 'eurusd',
22
+ "timeframe" => 'h1',
23
+ "updated" => 123,
24
+ "index" => 80,
25
+ "direction" => 1)
26
+
27
+ @alpha.to_doc.should == {
28
+ :updated => 123,
29
+ :index => 80,
30
+ :direction => 1
31
+ }
13
32
  end
14
33
 
15
34
  {
@@ -18,8 +37,8 @@ describe 'Finexclub::Signals::Alpha' do
18
37
  0 => :bearish
19
38
  }.each do |direction, trend|
20
39
  it "should return #{trend} trend when direction is #{direction}" do
21
- @signal.direction = direction
22
- @signal.trend.should == trend
40
+ @alpha.direction = direction
41
+ @alpha.trend.should == trend
23
42
  end
24
43
  end
25
44
 
@@ -31,17 +50,13 @@ describe 'Finexclub::Signals::Alpha' do
31
50
  :unstable => 0..60
32
51
  }.each do |stability, range|
33
52
  it "should return #{stability} stability when index within #{range}" do
34
- @signal.index = range.first
35
- @signal.stability.should == stability
53
+ @alpha.index = range.first
54
+ @alpha.stability.should == stability
36
55
 
37
- @signal.index = range.last
38
- @signal.stability.should == stability
56
+ @alpha.index = range.last
57
+ @alpha.stability.should == stability
39
58
  end
40
59
  end
41
60
 
42
- it 'should export valid doc' do
43
- @signal.build("direction" => 1, "index" => 100, "updated" => 123)
44
- @signal.to_doc.should == {:updated => 123, :index => 100, :direction => 1}
45
- end
46
61
  end
47
62
 
@@ -15,6 +15,7 @@ describe 'Finexclub::Chart' do
15
15
  chart_doc = {
16
16
  :symbol => 'eurusd',
17
17
  :date => '2010-09-08',
18
+ :timeframe => 'h1',
18
19
  :updated => @ts,
19
20
  :alpha => [ @a1, @a2 ],
20
21
  :zeta => [ @z1, @z2 ]
@@ -24,6 +25,7 @@ describe 'Finexclub::Chart' do
24
25
 
25
26
  it 'should have attribute accessors' do
26
27
  @chart.symbol.should == 'eurusd'
28
+ @chart.timeframe.should == 'h1'
27
29
  @chart.date.should == '2010-09-08'
28
30
  @chart.updated.should == @ts
29
31
  end
@@ -60,6 +60,7 @@ describe 'Finexclub::Manager' do
60
60
  before do
61
61
  class Omega < Finexclub::Signal
62
62
  field :symbol, :symbol
63
+ field :timeframe, :string
63
64
  field :updated, :timestamp
64
65
  field :foo, :string
65
66
 
@@ -75,6 +76,7 @@ describe 'Finexclub::Manager' do
75
76
  @manager.collection.should.receive(:update).with(
76
77
  {
77
78
  :date => '2010-10-04',
79
+ :timeframe => 'h1',
78
80
  :symbol => 'eurusd'
79
81
  },
80
82
  {
@@ -85,7 +87,7 @@ describe 'Finexclub::Manager' do
85
87
  )
86
88
 
87
89
  Timecop.travel(Time.at(ts))
88
- @manager.add_signal(:omega, {"foo" => "bar", "symbol" => "EURUSD"})
90
+ @manager.add_signal(:omega, {"foo" => "bar", "timeframe" => 'h1', "symbol" => "EURUSD"})
89
91
  end
90
92
  end
91
93
 
@@ -10,19 +10,36 @@ describe 'Finexclub::Signals::Octopus' do
10
10
  Finexclub::Signals::Octopus.meta.should == {
11
11
  :updated => :timestamp,
12
12
  :symbol => :symbol,
13
+ :timeframe => :string,
13
14
  :action => :trade_action,
14
15
  :take_profit => :float,
15
16
  :profit => :integer,
16
17
  :stop_loss => :float,
17
18
  :loss => :integer,
18
19
  :index => :integer,
20
+ :tsi => :integer,
21
+ :trend => :integer,
19
22
  :screenshot => :image
20
23
  }
21
24
  end
22
25
 
23
26
  it 'should export valid doc' do
24
27
  @core.images.stub!(:store).and_return('image_uid')
25
- @signal.build("updated" => 123, "action" => "sell", "take_profit" => 1.5, "profit" => 10, "stop_loss" => 1.7, "loss"=>10, "index" => 50, "screenshot_filename"=>"whatever.png")
28
+ @signal.build(
29
+ "symbol" => 'eurusd',
30
+ "timeframe" => 'h1',
31
+ "updated" => 123,
32
+ "action" => "sell",
33
+ "take_profit" => 1.5,
34
+ "profit" => 10,
35
+ "stop_loss" => 1.7,
36
+ "loss"=>10,
37
+ "index" => 50,
38
+ "tsi" => 80,
39
+ "trend" => 1,
40
+ "screenshot_filename"=>"whatever.png"
41
+ )
42
+
26
43
  @signal.to_doc.should == {
27
44
  :updated => 123,
28
45
  :action => "sell",
@@ -31,6 +48,8 @@ describe 'Finexclub::Signals::Octopus' do
31
48
  :stop_loss => 1.7,
32
49
  :loss => 10,
33
50
  :index => 50,
51
+ :tsi => 80,
52
+ :trend => 1,
34
53
  :screenshot => "image_uid"
35
54
  }
36
55
  end
@@ -10,10 +10,15 @@ describe 'Finexclub::Signals::Prognosis' do
10
10
  Finexclub::Signals::Prognosis.meta.should == {
11
11
  :updated => :timestamp,
12
12
  :symbol => :symbol,
13
+ :timeframe => :string,
13
14
  :action => :trade_action,
14
15
  :acceleration => :string,
15
16
  :take_profit => :float,
16
17
  :profit => :integer,
18
+ :stop_loss => :float,
19
+ :loss => :integer,
20
+ :tsi => :integer,
21
+ :trend => :integer,
17
22
  :screenshot => :image
18
23
  }
19
24
  end
@@ -21,11 +26,16 @@ describe 'Finexclub::Signals::Prognosis' do
21
26
  it 'should export valid doc' do
22
27
  @core.images.stub!(:store).and_return('image_uid')
23
28
  @prognosis.build(
29
+ "symbol" => 'eurusd',
30
+ "timeframe" => 'h1',
24
31
  "updated" => 123,
25
- "action" =>
26
- "sell",
32
+ "action" => "sell",
27
33
  "take_profit" => 1.5,
28
34
  "profit" => 10,
35
+ "stop_loss" => 1.7,
36
+ "loss"=> 10,
37
+ "tsi" => 80,
38
+ "trend" => 1,
29
39
  "acceleration" => "undefined",
30
40
  "screenshot_filename"=>"whatever.png")
31
41
 
@@ -34,9 +44,14 @@ describe 'Finexclub::Signals::Prognosis' do
34
44
  :action => "sell",
35
45
  :take_profit => 1.5,
36
46
  :profit => 10,
47
+ :stop_loss => 1.7,
48
+ :loss => 10,
49
+ :tsi => 80,
50
+ :trend => 1,
37
51
  :acceleration => "undefined",
38
52
  :screenshot => "image_uid"
39
53
  }
40
54
  end
55
+
41
56
  end
42
57
 
@@ -10,6 +10,7 @@ describe 'Finexclub::Signals::Zeta' do
10
10
  Finexclub::Signals::Zeta.meta.should == {
11
11
  :updated => :timestamp,
12
12
  :symbol => :symbol,
13
+ :timeframe => :string,
13
14
  :up_support => :float,
14
15
  :up_resist => :float,
15
16
  :down_support => :float,
@@ -38,7 +39,16 @@ describe 'Finexclub::Signals::Zeta' do
38
39
 
39
40
  it 'should export valid doc' do
40
41
  @core.images.stub!(:store).and_return('image_uid')
41
- @zeta.build("up_support" => "1.1", "up_resist" => "1.2", "down_support" => "2.1", "down_resist" => "2.2", "updated" => 123, "screenshot_filename" => "egg.png")
42
+ @zeta.build(
43
+ "symbol" => 'eurusd',
44
+ "timeframe" => 'h1',
45
+ "updated" => 123,
46
+ "up_support" => "1.1",
47
+ "up_resist" => "1.2",
48
+ "down_support" => "2.1",
49
+ "down_resist" => "2.2",
50
+ "screenshot_filename" => "egg.png"
51
+ )
42
52
  @zeta.to_doc.should == {
43
53
  :updated => 123,
44
54
  :up_support => 1.1,
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 3
8
7
  - 4
9
- version: 0.3.4
8
+ - 3
9
+ version: 0.4.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Alex Levin
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-03 00:00:00 +07:00
17
+ date: 2010-12-20 00:00:00 +07:00
18
18
  default_executable: finexclub_updater
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency