ofxparser 1.0.0 → 1.0.2a
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/lib/ofx.rb +6 -3
- data/lib/ofxparser.rb +35 -4
- metadata +6 -6
data/History.txt
CHANGED
data/lib/ofx.rb
CHANGED
@@ -93,7 +93,7 @@ module OfxParser
|
|
93
93
|
end
|
94
94
|
|
95
95
|
class InvestmentAccount < Account
|
96
|
-
attr_accessor :broker_id, :positions, :margin_balance, :short_balance, :cash_balance
|
96
|
+
attr_accessor :broker_id, :positions, :margin_balance, :short_balance, :cash_balance, :availcash, :balances
|
97
97
|
|
98
98
|
# include MonetarySupport
|
99
99
|
# monetary_vars :margin_balance, :short_balance, :cash_balance
|
@@ -101,7 +101,7 @@ module OfxParser
|
|
101
101
|
|
102
102
|
|
103
103
|
class Statement
|
104
|
-
attr_accessor :currency, :transactions, :start_date, :end_date, :stock_positions, :opt_positions
|
104
|
+
attr_accessor :currency, :transactions, :start_date, :end_date, :stock_positions, :opt_positions, :stock_transactions
|
105
105
|
end
|
106
106
|
|
107
107
|
class Transaction
|
@@ -153,10 +153,13 @@ module OfxParser
|
|
153
153
|
attr_accessor :uniqueid, :uniqueid_type, :heldinacct, :type, :units, :unitprice, :pricedate, :memo
|
154
154
|
end
|
155
155
|
|
156
|
-
|
156
|
+
class Opt_Position
|
157
157
|
attr_accessor :uniqueid, :uniqueid_type, :heldinacct, :type, :units, :unitprice, :pricedate, :memo, :mktval
|
158
158
|
end
|
159
159
|
|
160
|
+
class Stock_Transaction
|
161
|
+
attr_accessor :transid, :tradedate, :settledate, :uniqueid, :uniqueid_type, :units, :unitprice, :commission, :total, :subacctsec, ,:subacctfund,:type
|
162
|
+
end
|
160
163
|
|
161
164
|
# Status of a sign on
|
162
165
|
class Status
|
data/lib/ofxparser.rb
CHANGED
@@ -7,7 +7,7 @@ require 'date'
|
|
7
7
|
end
|
8
8
|
|
9
9
|
module OfxParser
|
10
|
-
VERSION = '1.0.
|
10
|
+
VERSION = '1.0.2a'
|
11
11
|
|
12
12
|
class OfxParser
|
13
13
|
|
@@ -181,11 +181,19 @@ module OfxParser
|
|
181
181
|
def self.build_investment(doc)
|
182
182
|
acct = InvestmentAccount.new
|
183
183
|
acct.broker_id=(doc/"INVSTMTRS/INVACCTFROM/BROKERID").inner_text
|
184
|
-
acct.
|
185
|
-
|
184
|
+
acct.availcash = (doc/"INVSTMTRS/INVBAL/AVAILCASH").inner_text
|
185
|
+
acct.margin_balance = (doc/"INVSTMTRS/INVBAL/MARGINBALANCE").inner_text
|
186
|
+
acct.short_balance = (doc/"INVSTMTRS/INVBAL/SHORTBALANCE").inner_text
|
187
|
+
|
186
188
|
statement = Statement.new
|
187
189
|
acct.statement=statement
|
188
|
-
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
#-----------------------------------------------------------------------
|
194
|
+
# Ideally we wouldn't need 2 separate classes for different types of positions/transactions.
|
195
|
+
# Need to find some way to parse informaton based on "POS****" or "BUY****"
|
196
|
+
|
189
197
|
statement.stock_positions = (doc/"INVSTMTRS/INVPOSLIST/POSSTOCK").collect do |p|
|
190
198
|
build_stock_position(p)
|
191
199
|
end
|
@@ -193,9 +201,32 @@ module OfxParser
|
|
193
201
|
statement.opt_positions = (doc/"INVSTMTRS/INVPOSLIST/POSOPT").collect do |p|
|
194
202
|
build_opt_position(p)
|
195
203
|
end
|
204
|
+
|
205
|
+
statement.stock_transactions = (doc/"INVSTMTRS/INVTRANLIST/BUYSTOCK").collect do |t|
|
206
|
+
build_stock_transactions(t)
|
207
|
+
end
|
196
208
|
|
209
|
+
|
197
210
|
acct
|
198
211
|
end
|
212
|
+
|
213
|
+
def self.build_stock_transactions(t)
|
214
|
+
stock_transaction = Stock_Transaction.new
|
215
|
+
stock_transaction.transid = (t/"INVBUY/INVTRAN/FITID").inner_text
|
216
|
+
stock_transaction.tradedate = parse_datetime((t/"INVBUY/INVTRAN/DTTRADE").inner_text)
|
217
|
+
stock_transaction.settledate = parse_datetime((t/"INVBUY/INVTRAN/DTSETTLE").inner_text)
|
218
|
+
stock_transaction.uniqueid = (t/"INVBUY/SECID/UNIQUEID").inner_text
|
219
|
+
stock_transaction.uniqueid_type = (t/"INVBUY/SECID/UNIQUEIDTYPE").inner_text
|
220
|
+
stock_transaction.units = (t/"INVBUY/UNITS").inner_text
|
221
|
+
stock_transaction.unitprice = (t/"INVBUY/UNITPRICE").inner_text
|
222
|
+
stock_transaction.commission = (t/"INVBUY/UNITPRICE").inner_text
|
223
|
+
stock_transaction.total = (t/"INVBUY/TOTAL").inner_text
|
224
|
+
stock_transaction.subacctsec = (t/"INVBUY/SUBACCTSEC").inner_text
|
225
|
+
stock_transaction.subacctfund = (t/"INVBUY/SUBACCTFUND").inner_text
|
226
|
+
stock_transaction.type = (t/"BUYTYPE").inner_text
|
227
|
+
stock_transaction
|
228
|
+
end
|
229
|
+
|
199
230
|
|
200
231
|
def self.build_stock_position(p)
|
201
232
|
stock_position = Stock_Position.new
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ofxparser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.2a
|
5
|
+
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Pavit Masson (forked from Andrew A. Smith)
|
@@ -14,7 +14,7 @@ default_executable:
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hpricot
|
17
|
-
requirement: &
|
17
|
+
requirement: &9644532 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0.6'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *9644532
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: hoe
|
28
|
-
requirement: &
|
28
|
+
requirement: &9644244 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: 1.5.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *9644244
|
37
37
|
description: ! '== DESCRIPTION: My fork of aasmith''s ofx-parser v1.0.2 and attempt
|
38
38
|
at building the investment acct methods. OfxParser is a ruby library to parse a
|
39
39
|
realistic subset of the lengthy OFX 1.x specification. == FEATURES/PROBLEMS: *
|