stockfolio 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -112,7 +112,14 @@ class StockFolio::Runner < Boson::Runner
112
112
 
113
113
  desc 'Create Portfolio'
114
114
  def create(name)
115
+ p = Portfolio.all(:name => name)
116
+ if p.size > 0
117
+ puts "Portfolio \"#{name}\" already exists"
118
+ exit
119
+ end
120
+
115
121
  Portfolio.create(:name => name, :created_at => DateTime.now)
122
+ puts "Created portfolio \"#{name}\""
116
123
  end
117
124
 
118
125
  desc 'Add to watchlist'
@@ -121,11 +128,11 @@ class StockFolio::Runner < Boson::Runner
121
128
  quote = StockFolio::Web.quote(symbol)
122
129
  if nil != quote
123
130
  quote.each do |q|
124
- WatchList.create(
131
+ item = WatchList.create(
125
132
  :symbol => "#{q["e"]}:#{q["t"]}",
126
133
  :created_at => DateTime.now
127
134
  )
128
- puts "Added #{q["t"]}"
135
+ puts "Added #{item.symbol} to watchlist - current price $#{q['l']}"
129
136
  end
130
137
  end
131
138
  end
@@ -151,13 +158,12 @@ class StockFolio::Runner < Boson::Runner
151
158
  end
152
159
 
153
160
  portfolio = portfolios[0]
154
- puts "Portfolio #{portfolio.id} - #{portfolio.name}"
155
161
 
156
162
  # Validate the symbol
157
163
  quote = StockFolio::Web.quote(options[:symbol])
158
164
  if nil == quote
159
- puts "Symbol #{options[:symbol]} not found"
160
- return
165
+ puts "Symbol \"#{options[:symbol]}\" not found"
166
+ exit
161
167
  end
162
168
 
163
169
  transaction = Transaction.new(
@@ -173,10 +179,10 @@ class StockFolio::Runner < Boson::Runner
173
179
  )
174
180
  transaction.fee = options[:fee] if options[:fee]
175
181
  transaction.executed_at = DateTime.parse(options[:date]) if options[:date]
176
-
177
-
178
182
  transaction.save
179
183
 
184
+ puts "Added #{transaction.order_name} of #{transaction.quantity} #{transaction.symbol} to #{portfolio.name}"
185
+
180
186
  end
181
187
 
182
188
  def print_quotes(quote)
@@ -1,3 +1,3 @@
1
1
  module StockFolio
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stockfolio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: boson
16
- requirement: &2165393860 !ruby/object:Gem::Requirement
16
+ requirement: &2169271960 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2165393860
24
+ version_requirements: *2169271960
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: hirb
27
- requirement: &2165393380 !ruby/object:Gem::Requirement
27
+ requirement: &2169271440 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2165393380
35
+ version_requirements: *2169271440
36
36
  description:
37
37
  email: poitch@gmail.com
38
38
  executables: