42int ofx_proc_security_cb(
struct OfxSecurityData data,
void * security_data)
44 char dest_string[255];
45 std::cout <<
"ofx_proc_security():\n";
46 if (data.unique_id_valid ==
true)
48 std::cout <<
" Unique ID of the security: " << data.unique_id <<
"\n";
50 if (data.unique_id_type_valid ==
true)
52 std::cout <<
" Format of the Unique ID: " << data.unique_id_type <<
"\n";
54 if (data.unique_id2_valid ==
true)
56 std::cout <<
" Unique ID of the underlying security: " << data.unique_id2 <<
"\n";
58 if (data.unique_id2_type_valid ==
true)
60 std::cout <<
" Format of the underlying Unique ID: " << data.unique_id2_type <<
"\n";
62 if (data.security_type_valid ==
true)
64 if (data.security_type == OfxSecurityData::OFX_DEBT_SECURITY)
65 strncpy(dest_string,
"DEBTINFO: Debt security",
sizeof(dest_string));
66 else if (data.security_type == OfxSecurityData::OFX_FUND_SECURITY)
67 strncpy(dest_string,
"MFINFO: Mutual fund security",
sizeof(dest_string));
68 else if (data.security_type == OfxSecurityData::OFX_OPTION_SECURITY)
69 strncpy(dest_string,
"OPTINFO: Option security",
sizeof(dest_string));
70 else if (data.security_type == OfxSecurityData::OFX_STOCK_SECURITY)
71 strncpy(dest_string,
"STOCKINFO: Stock security",
sizeof(dest_string));
72 else if (data.security_type == OfxSecurityData::OFX_OTHER_SECURITY)
73 strncpy(dest_string,
"OTHERINFO: Other type of security",
sizeof(dest_string));
75 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
76 std::cout <<
" Security type: " << dest_string <<
"\n";
78 if (data.secname_valid ==
true)
80 std::cout <<
" Name of the security: " << data.secname <<
"\n";
82 if (data.ticker_valid ==
true)
84 std::cout <<
" Ticker symbol: " << data.ticker <<
"\n";
86 if (data.rating_valid ==
true)
88 std::cout <<
" Rating of the security: " << data.rating <<
"\n";
90 if (data.unitprice_valid ==
true)
92 if (data.security_type_valid ==
true
93 && data.security_type == OfxSecurityData::OFX_DEBT_SECURITY)
94 std::cout <<
" Price (percent of par): " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(4) << data.unitprice <<
"%\n";
96 std::cout <<
" Price of each unit of the security: " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.unitprice <<
"\n";
98 if (data.date_unitprice_valid ==
true)
100 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.date_unitprice)));
101 std::cout <<
" Date as of which the unitprice is valid: " << dest_string <<
"\n";
103 if (data.amounts_are_foreign_currency_valid ==
true)
105 std::cout <<
" Amounts are in foreign currency: " << (data.amounts_are_foreign_currency ?
"Yes" :
"No") <<
"\n";
107 if (data.currency_valid ==
true)
109 std::cout <<
" Currency: " << data.currency <<
"\n";
111 if (data.currency_ratio_valid ==
true)
113 std::cout <<
" Ratio of default currency to currency: " << data.currency_ratio <<
"\n";
115 if (data.memo_valid ==
true)
117 std::cout <<
" Extra security information (memo): " << data.memo <<
"\n";
119 if (data.asset_class_valid ==
true)
121 if (data.asset_class == OfxSecurityData::OFX_ASSET_CLASS_DOMESTICBOND)
122 strncpy(dest_string,
"DOMESTICBOND: Domestic bond",
sizeof(dest_string));
123 else if (data.asset_class == OfxSecurityData::OFX_ASSET_CLASS_INTLBOND)
124 strncpy(dest_string,
"INTLBOND: International bond",
sizeof(dest_string));
125 else if (data.asset_class == OfxSecurityData::OFX_ASSET_CLASS_LARGESTOCK)
126 strncpy(dest_string,
"LARGESTOCK: Large cap stock",
sizeof(dest_string));
127 else if (data.asset_class == OfxSecurityData::OFX_ASSET_CLASS_SMALLSTOCK)
128 strncpy(dest_string,
"SMALLSTOCK: Small cap stock",
sizeof(dest_string));
129 else if (data.asset_class == OfxSecurityData::OFX_ASSET_CLASS_INTLSTOCK)
130 strncpy(dest_string,
"INTLSTOCK: International stock",
sizeof(dest_string));
131 else if (data.asset_class == OfxSecurityData::OFX_ASSET_CLASS_MONEYMRKT)
132 strncpy(dest_string,
"MONEYMRKT: Money market",
sizeof(dest_string));
133 else if (data.asset_class == OfxSecurityData::OFX_ASSET_CLASS_OTHER)
134 strncpy(dest_string,
"OTHER: Other",
sizeof(dest_string));
136 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
137 std::cout <<
" Asset class: " << dest_string <<
"\n";
139 if (data.fiasset_class_valid ==
true)
141 std::cout <<
" FI defined asset class: " << data.fiasset_class <<
"\n";
143 if (data.par_value_valid ==
true)
145 std::cout <<
" Par value: " << data.par_value <<
"\n";
147 if (data.debt_type_valid ==
true)
149 if (data.debt_type == OfxSecurityData::OFX_DEBT_TYPE_COUPON)
150 strncpy(dest_string,
"COUPON: Coupon debt",
sizeof(dest_string));
151 else if (data.debt_type == OfxSecurityData::OFX_DEBT_TYPE_ZERO)
152 strncpy(dest_string,
"ZERO: Zero coupon debt",
sizeof(dest_string));
154 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
155 std::cout <<
" Debt type: " << dest_string <<
"\n";
157 if (data.debt_class_valid ==
true)
159 if (data.debt_class == OfxSecurityData::OFX_DEBTCLASS_TREASURY)
160 strncpy(dest_string,
"TREASURY: Treasury debt",
sizeof(dest_string));
161 else if (data.debt_class == OfxSecurityData::OFX_DEBTCLASS_MUNICIPAL)
162 strncpy(dest_string,
"MUNICIPAL: Municipal debt",
sizeof(dest_string));
163 else if (data.debt_class == OfxSecurityData::OFX_DEBTCLASS_CORPORATE)
164 strncpy(dest_string,
"CORPORATE: Corporate debt",
sizeof(dest_string));
165 else if (data.debt_class == OfxSecurityData::OFX_DEBTCLASS_OTHER)
166 strncpy(dest_string,
"OTHER: Other debt class",
sizeof(dest_string));
168 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
169 std::cout <<
" Debt class: " << dest_string <<
"\n";
171 if (data.coupon_rate_valid ==
true)
173 std::cout <<
" Coupon rate: " << data.coupon_rate <<
"%\n";
175 if (data.date_coupon_valid ==
true)
177 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.date_coupon)));
178 std::cout <<
" Date for the next coupon: " << dest_string <<
"\n";
180 if (data.coupon_freq_valid ==
true)
182 if (data.coupon_freq == OfxSecurityData::OFX_COUPON_FREQ_MONTHLY)
183 strncpy(dest_string,
"MONTHLY: Monthly coupon",
sizeof(dest_string));
184 else if (data.coupon_freq == OfxSecurityData::OFX_COUPON_FREQ_QUARTERLY)
185 strncpy(dest_string,
"QUARTERLY: Quarterly coupon",
sizeof(dest_string));
186 else if (data.coupon_freq == OfxSecurityData::OFX_COUPON_FREQ_SEMIANNUAL)
187 strncpy(dest_string,
"SEMIANNUAL: Semiannual coupon",
sizeof(dest_string));
188 else if (data.coupon_freq == OfxSecurityData::OFX_COUPON_FREQ_ANNUAL)
189 strncpy(dest_string,
"ANNUAL: Annual coupon",
sizeof(dest_string));
190 else if (data.coupon_freq == OfxSecurityData::OFX_COUPON_FREQ_OTHER)
191 strncpy(dest_string,
"OTHER: Other frequency",
sizeof(dest_string));
193 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
194 std::cout <<
" Coupon frequency: " << dest_string <<
"\n";
196 if (data.call_price_valid ==
true)
198 std::cout <<
" Call price (unit price): " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.call_price <<
"\n";
200 if (data.yield_to_call_valid ==
true)
202 std::cout <<
" Yield to next call (rate): " << data.yield_to_call <<
"%\n";
204 if (data.call_date_valid ==
true)
206 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.call_date)));
207 std::cout <<
" Date for the next call: " << dest_string <<
"\n";
209 if (data.call_type_valid ==
true)
211 if (data.call_type == OfxSecurityData::OFX_CALL_TYPE_CALL)
212 strncpy(dest_string,
"CALL: Call",
sizeof(dest_string));
213 else if (data.call_type == OfxSecurityData::OFX_CALL_TYPE_PUT)
214 strncpy(dest_string,
"PUT: Put",
sizeof(dest_string));
215 else if (data.call_type == OfxSecurityData::OFX_CALL_TYPE_PREFUND)
216 strncpy(dest_string,
"PREFUND: Prefund",
sizeof(dest_string));
217 else if (data.call_type == OfxSecurityData::OFX_CALL_TYPE_MATURITY)
218 strncpy(dest_string,
"MATURITY: Maturity",
sizeof(dest_string));
220 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
221 std::cout <<
" Call type: " << dest_string <<
"\n";
223 if (data.yield_to_maturity_valid ==
true)
225 std::cout <<
" Yield to maturity (rate): " << data.yield_to_maturity <<
"%\n";
227 if (data.maturity_date_valid ==
true)
229 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.maturity_date)));
230 std::cout <<
" Maturity date: " << dest_string <<
"\n";
232 if (data.mutual_fund_type_valid ==
true)
234 if (data.mutual_fund_type == OfxSecurityData::OFX_MFTYPE_OPENEND)
235 strncpy(dest_string,
"OPENEND: Open ended",
sizeof(dest_string));
236 else if (data.mutual_fund_type == OfxSecurityData::OFX_MFTYPE_CLOSEEND)
237 strncpy(dest_string,
"CLOSEEND: Closed ended",
sizeof(dest_string));
238 else if (data.mutual_fund_type == OfxSecurityData::OFX_MFTYPE_OTHER)
239 strncpy(dest_string,
"OTHER: Other type",
sizeof(dest_string));
241 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
242 std::cout <<
" Mutual fund type: " << dest_string <<
"\n";
243 if (data.stock_type_valid ==
true)
245 if (data.stock_type == OfxSecurityData::OFX_STOCKTYPE_COMMON)
246 strncpy(dest_string,
"COMMON: Common stock",
sizeof(dest_string));
247 else if (data.stock_type == OfxSecurityData::OFX_STOCKTYPE_PREFERRED)
248 strncpy(dest_string,
"PREFERRED: Preferred stock",
sizeof(dest_string));
249 else if (data.stock_type == OfxSecurityData::OFX_STOCKTYPE_CONVERTIBLE)
250 strncpy(dest_string,
"CONVERTIBLE: Convertable stock",
sizeof(dest_string));
251 else if (data.stock_type == OfxSecurityData::OFX_STOCKTYPE_OTHER)
252 strncpy(dest_string,
"OTHER: Other type",
sizeof(dest_string));
254 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
255 std::cout <<
" Stock type: " << dest_string <<
"\n";
258 if (data.yield_valid ==
true)
260 std::cout <<
" Current yield (rate): " << data.yield <<
"%\n";
262 if (data.yield_asof_date_valid ==
true)
264 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.yield_asof_date)));
265 std::cout <<
" Date for which current yield is valid: " << dest_string <<
"\n";
267 if (data.option_type_valid ==
true)
269 if (data.option_type == OfxSecurityData::OFX_OPTION_TYPE_CALL)
270 strncpy(dest_string,
"CALL: Call option",
sizeof(dest_string));
271 else if (data.option_type == OfxSecurityData::OFX_OPTION_TYPE_PUT)
272 strncpy(dest_string,
"PUT: Put option",
sizeof(dest_string));
274 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
275 std::cout <<
" Option type: " << dest_string <<
"\n";
277 if (data.strike_price_valid ==
true)
279 std::cout <<
" Strike price: " << data.strike_price <<
"\n";
281 if (data.date_expire_valid ==
true)
283 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.date_expire)));
284 std::cout <<
" Expiration date: " << dest_string <<
"\n";
286 if (data.shares_per_cont_valid ==
true)
288 std::cout <<
" Shares per contract: " << data.shares_per_cont <<
"\n";
294int ofx_proc_transaction_cb(
struct OfxTransactionData data,
void * transaction_data)
296 char dest_string[255];
297 std::cout <<
"ofx_proc_transaction():\n";
299 if (data.account_id_valid ==
true)
301 std::cout <<
" Account ID : " << data.account_id <<
"\n";
304 if (data.transactiontype_valid ==
true)
306 if (data.transactiontype == OFX_CREDIT)
307 strncpy(dest_string,
"CREDIT: Generic credit",
sizeof(dest_string));
308 else if (data.transactiontype == OFX_DEBIT)
309 strncpy(dest_string,
"DEBIT: Generic debit",
sizeof(dest_string));
310 else if (data.transactiontype == OFX_INT)
311 strncpy(dest_string,
"INT: Interest earned or paid (Note: Depends on signage of amount)",
sizeof(dest_string));
312 else if (data.transactiontype == OFX_DIV)
313 strncpy(dest_string,
"DIV: Dividend",
sizeof(dest_string));
314 else if (data.transactiontype == OFX_FEE)
315 strncpy(dest_string,
"FEE: FI fee",
sizeof(dest_string));
316 else if (data.transactiontype == OFX_SRVCHG)
317 strncpy(dest_string,
"SRVCHG: Service charge",
sizeof(dest_string));
318 else if (data.transactiontype == OFX_DEP)
319 strncpy(dest_string,
"DEP: Deposit",
sizeof(dest_string));
320 else if (data.transactiontype == OFX_ATM)
321 strncpy(dest_string,
"ATM: ATM debit or credit (Note: Depends on signage of amount)",
sizeof(dest_string));
322 else if (data.transactiontype == OFX_POS)
323 strncpy(dest_string,
"POS: Point of sale debit or credit (Note: Depends on signage of amount)",
sizeof(dest_string));
324 else if (data.transactiontype == OFX_XFER)
325 strncpy(dest_string,
"XFER: Transfer",
sizeof(dest_string));
326 else if (data.transactiontype == OFX_CHECK)
327 strncpy(dest_string,
"CHECK: Check",
sizeof(dest_string));
328 else if (data.transactiontype == OFX_PAYMENT)
329 strncpy(dest_string,
"PAYMENT: Electronic payment",
sizeof(dest_string));
330 else if (data.transactiontype == OFX_CASH)
331 strncpy(dest_string,
"CASH: Cash withdrawal",
sizeof(dest_string));
332 else if (data.transactiontype == OFX_DIRECTDEP)
333 strncpy(dest_string,
"DIRECTDEP: Direct deposit",
sizeof(dest_string));
334 else if (data.transactiontype == OFX_DIRECTDEBIT)
335 strncpy(dest_string,
"DIRECTDEBIT: Merchant initiated debit",
sizeof(dest_string));
336 else if (data.transactiontype == OFX_REPEATPMT)
337 strncpy(dest_string,
"REPEATPMT: Repeating payment/standing order",
sizeof(dest_string));
338 else if (data.transactiontype == OFX_OTHER)
339 strncpy(dest_string,
"OTHER: Other",
sizeof(dest_string));
341 strncpy(dest_string,
"Unknown transaction type",
sizeof(dest_string));
342 std::cout <<
" Transaction type: " << dest_string <<
"\n";
346 if (data.date_initiated_valid ==
true)
348 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.date_initiated)));
349 std::cout <<
" Date initiated: " << dest_string <<
"\n";
351 if (data.date_posted_valid ==
true)
353 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.date_posted)));
354 std::cout <<
" Date posted: " << dest_string <<
"\n";
356 if (data.date_funds_available_valid ==
true)
358 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.date_funds_available)));
359 std::cout <<
" Date funds are available: " << dest_string <<
"\n";
361 if (data.amount_valid ==
true)
363 std::cout <<
" Total money amount: " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.amount <<
"\n";
365 if (data.units_valid ==
true)
367 if (data.invtransactiontype_valid)
369 std::cout <<
" # of units: " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(4) << data.units;
370 strncpy(dest_string,
" (bonds: face value; options: contracts; all others: shares)",
sizeof(dest_string));
371 if (data.security_data_valid ==
true)
373 if (data.security_data_ptr->security_type_valid ==
true)
375 if (data.security_data_ptr->security_type == OfxSecurityData::OFX_DEBT_SECURITY)
376 strncpy(dest_string,
" (face value)",
sizeof(dest_string));
377 else if (data.security_data_ptr->security_type == OfxSecurityData::OFX_FUND_SECURITY ||
378 data.security_data_ptr->security_type == OfxSecurityData::OFX_STOCK_SECURITY ||
379 data.security_data_ptr->security_type == OfxSecurityData::OFX_OTHER_SECURITY)
380 strncpy(dest_string,
" (shares)",
sizeof(dest_string));
381 else if (data.security_data_ptr->security_type == OfxSecurityData::OFX_OPTION_SECURITY)
382 strncpy(dest_string,
" (contracts)",
sizeof(dest_string));
385 std::cout << dest_string;
388 std::cout <<
" # of units: " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.units;
391 if (data.oldunits_valid ==
true)
393 if (data.invtransactiontype_valid)
394 std::cout <<
" # of units before split: " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(4) << data.oldunits <<
"\n";
396 std::cout <<
" # of units before split: " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.oldunits <<
"\n";
398 if (data.newunits_valid ==
true)
400 std::cout <<
" # of units after split: " << std::setprecision(4) << data.newunits <<
"\n";
402 if (data.unitprice_valid ==
true)
404 if (data.invtransactiontype_valid)
406 std::cout <<
" Unit price: " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(4) << data.unitprice;
407 strncpy(dest_string,
" (bonds: % of par; options: premium per share of underlying; all others: price per share)\n",
sizeof(dest_string));
408 if (data.security_data_valid ==
true)
410 if (data.security_data_ptr->security_type_valid ==
true)
412 if (data.security_data_ptr->security_type == OfxSecurityData::OFX_DEBT_SECURITY)
414 strncpy(dest_string,
"% (% of par)\n",
sizeof(dest_string));
416 else if (data.security_data_ptr->security_type == OfxSecurityData::OFX_FUND_SECURITY ||
417 data.security_data_ptr->security_type == OfxSecurityData::OFX_STOCK_SECURITY ||
418 data.security_data_ptr->security_type == OfxSecurityData::OFX_OTHER_SECURITY)
419 strncpy(dest_string,
" (price per share)\n",
sizeof(dest_string));
420 else if (data.security_data_ptr->security_type == OfxSecurityData::OFX_OPTION_SECURITY)
421 strncpy(dest_string,
" (premium per share of underlying)\n",
sizeof(dest_string));
424 std::cout << dest_string;
427 std::cout <<
" Unit price: " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.unitprice <<
"\n";
429 if (data.fees_valid ==
true)
431 std::cout <<
" Fees: " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.fees <<
"\n";
433 if (data.commission_valid ==
true)
435 std::cout <<
" Commission: " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.commission <<
"\n";
437 if (data.amounts_are_foreign_currency_valid ==
true)
439 std::cout <<
" Amounts are in foreign currency: " << (data.amounts_are_foreign_currency ?
"Yes" :
"No") <<
"\n";
441 if (data.currency_valid ==
true)
443 std::cout <<
" Currency: " << data.currency <<
"\n";
445 if (data.currency_ratio_valid ==
true)
447 std::cout <<
" Ratio of default currency to currency: " << data.currency_ratio <<
"\n";
449 if (data.fi_id_valid ==
true)
451 std::cout <<
" Financial institution's ID for this transaction: " << data.fi_id <<
"\n";
453 if (data.fi_id_corrected_valid ==
true)
455 std::cout <<
" Financial institution ID replaced or corrected by this transaction: " << data.fi_id_corrected <<
"\n";
457 if (data.fi_id_correction_action_valid ==
true)
459 std::cout <<
" Action to take on the corrected transaction: ";
460 if (data.fi_id_correction_action == DELETE)
461 std::cout <<
"DELETE\n";
462 else if (data.fi_id_correction_action == REPLACE)
463 std::cout <<
"REPLACE\n";
465 std::cout <<
"ofx_proc_transaction(): This should not happen!\n";
467 if (data.invtransactiontype_valid ==
true)
469 std::cout <<
" Investment transaction type: ";
470 if (data.invtransactiontype == OFX_BUYDEBT)
471 strncpy(dest_string,
"BUYDEBT (Buy debt security)",
sizeof(dest_string));
472 else if (data.invtransactiontype == OFX_BUYMF)
473 strncpy(dest_string,
"BUYMF (Buy mutual fund)",
sizeof(dest_string));
474 else if (data.invtransactiontype == OFX_BUYOPT)
475 strncpy(dest_string,
"BUYOPT (Buy option)",
sizeof(dest_string));
476 else if (data.invtransactiontype == OFX_BUYOTHER)
477 strncpy(dest_string,
"BUYOTHER (Buy other security type)",
sizeof(dest_string));
478 else if (data.invtransactiontype == OFX_BUYSTOCK)
479 strncpy(dest_string,
"BUYSTOCK (Buy stock)",
sizeof(dest_string));
480 else if (data.invtransactiontype == OFX_CLOSUREOPT)
481 strncpy(dest_string,
"CLOSUREOPT (Close a position for an option)",
sizeof(dest_string));
482 else if (data.invtransactiontype == OFX_INCOME)
483 strncpy(dest_string,
"INCOME (Investment income is realized as cash into the investment account)",
sizeof(dest_string));
484 else if (data.invtransactiontype == OFX_INVEXPENSE)
485 strncpy(dest_string,
"INVEXPENSE (Misc investment expense that is associated with a specific security)",
sizeof(dest_string));
486 else if (data.invtransactiontype == OFX_JRNLFUND)
487 strncpy(dest_string,
"JRNLFUND (Journaling cash holdings between subaccounts within the same investment account)",
sizeof(dest_string));
488 else if (data.invtransactiontype == OFX_MARGININTEREST)
489 strncpy(dest_string,
"MARGININTEREST (Margin interest expense)",
sizeof(dest_string));
490 else if (data.invtransactiontype == OFX_REINVEST)
491 strncpy(dest_string,
"REINVEST (Reinvestment of income)",
sizeof(dest_string));
492 else if (data.invtransactiontype == OFX_RETOFCAP)
493 strncpy(dest_string,
"RETOFCAP (Return of capital)",
sizeof(dest_string));
494 else if (data.invtransactiontype == OFX_SELLDEBT)
495 strncpy(dest_string,
"SELLDEBT (Sell debt security. Used when debt is sold, called, or reached maturity)",
sizeof(dest_string));
496 else if (data.invtransactiontype == OFX_SELLMF)
497 strncpy(dest_string,
"SELLMF (Sell mutual fund)",
sizeof(dest_string));
498 else if (data.invtransactiontype == OFX_SELLOPT)
499 strncpy(dest_string,
"SELLOPT (Sell option)",
sizeof(dest_string));
500 else if (data.invtransactiontype == OFX_SELLOTHER)
501 strncpy(dest_string,
"SELLOTHER (Sell other type of security)",
sizeof(dest_string));
502 else if (data.invtransactiontype == OFX_SELLSTOCK)
503 strncpy(dest_string,
"SELLSTOCK (Sell stock)",
sizeof(dest_string));
504 else if (data.invtransactiontype == OFX_SPLIT)
505 strncpy(dest_string,
"SPLIT (Stock or mutial fund split)",
sizeof(dest_string));
506 else if (data.invtransactiontype == OFX_TRANSFER)
507 strncpy(dest_string,
"TRANSFER (Transfer holdings in and out of the investment account)",
sizeof(dest_string));
508 else if (data.invtransactiontype == OFX_INVBANKTRAN)
509 strncpy(dest_string,
"INVBANKTRAN (Transfer cash in and out of the investment account)",
sizeof(dest_string));
511 strncpy(dest_string,
"ERROR, this investment transaction type is unknown. This is a bug in ofxdump",
sizeof(dest_string));
513 std::cout << dest_string <<
"\n";
515 if (data.unique_id_valid ==
true)
517 std::cout <<
" Unique ID of the security being traded: " << data.unique_id <<
"\n";
519 if (data.unique_id_type_valid ==
true)
521 std::cout <<
" Format of the Unique ID: " << data.unique_id_type <<
"\n";
523 if (data.server_transaction_id_valid ==
true)
525 std::cout <<
" Server's transaction ID (confirmation number): " << data.server_transaction_id <<
"\n";
527 if (data.check_number_valid ==
true)
529 std::cout <<
" Check number: " << data.check_number <<
"\n";
531 if (data.reference_number_valid ==
true)
533 std::cout <<
" Reference number: " << data.reference_number <<
"\n";
535 if (data.standard_industrial_code_valid ==
true)
537 std::cout <<
" Standard Industrial Code: " << data.standard_industrial_code <<
"\n";
539 if (data.payee_id_valid ==
true)
541 std::cout <<
" Payee_id: " << data.payee_id <<
"\n";
543 if (data.name_valid ==
true)
545 std::cout <<
" Name of payee or transaction description: " << data.name <<
"\n";
547 if (data.memo_valid ==
true)
549 std::cout <<
" Extra transaction information (memo): " << data.memo <<
"\n";
551 if (data.accrued_interest_valid ==
true)
553 std::cout <<
" Accrued Interest: " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.accrued_interest <<
"\n";
555 if (data.avg_cost_basis_valid ==
true)
557 std::cout <<
" Average cost basis: " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.avg_cost_basis <<
"\n";
559 if (data.buy_type_valid ==
true)
561 if (data.buy_type == OfxTransactionData::OFX_BUY_TYPE_BUY)
562 strncpy(dest_string,
"BUY: Buy",
sizeof(dest_string));
563 else if (data.buy_type == OfxTransactionData::OFX_BUY_TYPE_BUYTOCOVER)
564 strncpy(dest_string,
"BUYTOCOVER: Buy to cover",
sizeof(dest_string));
565 else if (data.buy_type == OfxTransactionData::OFX_BUY_TYPE_BUYTOOPEN)
566 strncpy(dest_string,
"BUYTOOPEN: Buy to open",
sizeof(dest_string));
567 else if (data.buy_type == OfxTransactionData::OFX_BUY_TYPE_BUYTOCLOSE)
568 strncpy(dest_string,
"BUYTOCLOSE: Buy to close",
sizeof(dest_string));
570 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
571 std::cout <<
" Buy type: " << dest_string <<
"\n";
573 if (data.denominator_valid ==
true)
575 std::cout <<
" Stock split ratio denominator: " << data.denominator <<
"\n";
577 if (data.date_payroll_valid ==
true)
579 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.date_payroll)));
580 std::cout <<
" Date 401(k) funds were deducted from payroll: " << dest_string <<
"\n";
582 if (data.date_purchase_valid ==
true)
584 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.date_purchase)));
585 std::cout <<
" Original purchase date of the security: " << dest_string <<
"\n";
587 if (data.gain_valid ==
true)
589 std::cout <<
" Average cost basis: " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.gain <<
"\n";
591 if (data.cash_for_fractional_valid ==
true)
593 std::cout <<
" Average cost basis: " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.cash_for_fractional <<
"\n";
595 if (data.income_type_valid ==
true)
597 if (data.income_type == OfxTransactionData::OFX_CGLONG)
598 strncpy(dest_string,
"CGLONG: Long term capital gains",
sizeof(dest_string));
599 else if (data.income_type == OfxTransactionData::OFX_CGSHORT)
600 strncpy(dest_string,
"CGSHORT: Short term capital gains",
sizeof(dest_string));
601 else if (data.income_type == OfxTransactionData::OFX_DIVIDEND)
602 strncpy(dest_string,
"DIVIDEND",
sizeof(dest_string));
603 else if (data.income_type == OfxTransactionData::OFX_INTEREST)
604 strncpy(dest_string,
"INTEREST",
sizeof(dest_string));
605 else if (data.income_type == OfxTransactionData::OFX_MISC)
606 strncpy(dest_string,
"MISC: Miscellaneous",
sizeof(dest_string));
608 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
609 std::cout <<
" Income type: " << dest_string <<
"\n";
611 if (data.inv_401k_source_valid ==
true)
613 if (data.inv_401k_source == OfxTransactionData::OFX_401K_SOURCE_PRETAX)
614 strncpy(dest_string,
"PRETAX",
sizeof(dest_string));
615 else if (data.inv_401k_source == OfxTransactionData::OFX_401K_SOURCE_AFTERTAX)
616 strncpy(dest_string,
"AFTERTAX",
sizeof(dest_string));
617 else if (data.inv_401k_source == OfxTransactionData::OFX_401K_SOURCE_MATCH)
618 strncpy(dest_string,
"MATCH",
sizeof(dest_string));
619 else if (data.inv_401k_source == OfxTransactionData::OFX_401K_SOURCE_PROFITSHARING)
620 strncpy(dest_string,
"PROFITSHARING",
sizeof(dest_string));
621 else if (data.inv_401k_source == OfxTransactionData::OFX_401K_SOURCE_ROLLOVER)
622 strncpy(dest_string,
"ROLLOVER",
sizeof(dest_string));
623 else if (data.inv_401k_source == OfxTransactionData::OFX_401K_SOURCE_OTHERVEST)
624 strncpy(dest_string,
"OTHERVEST",
sizeof(dest_string));
625 else if (data.inv_401k_source == OfxTransactionData::OFX_401K_SOURCE_OTHERNONVEST)
626 strncpy(dest_string,
"OTHERNONVEST",
sizeof(dest_string));
628 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
629 std::cout <<
" Source of 401(k) money: " << dest_string <<
"\n";
631 if (data.load_valid ==
true)
633 std::cout <<
" Load (amount): " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.load <<
"\n";
635 if (data.loan_id_valid ==
true)
637 std::cout <<
" 401(k) loan id: " << data.loan_id <<
"\n";
639 if (data.loan_interest_valid ==
true)
641 std::cout <<
" 401(k) loan interest (amount): " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.loan_interest <<
"\n";
643 if (data.loan_principal_valid ==
true)
645 std::cout <<
" 401(k) loan principle (amount): " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.loan_principal <<
"\n";
647 if (data.markdown_valid ==
true)
649 std::cout <<
" Markdown (unitprice): " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.markdown <<
"\n";
651 if (data.markup_valid ==
true)
653 std::cout <<
" Markup (unitprice): " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.markup <<
"\n";
655 if (data.numerator_valid ==
true)
657 std::cout <<
" Stock split ratio numerator: " << data.numerator <<
"\n";
659 if (data.opt_action_valid ==
true)
661 if (data.opt_action == OfxTransactionData::OFX_OPTACTION_EXERCISE)
662 strncpy(dest_string,
"EXERCISE",
sizeof(dest_string));
663 else if (data.opt_action == OfxTransactionData::OFX_OPTACTION_ASSIGN)
664 strncpy(dest_string,
"ASSIGN",
sizeof(dest_string));
665 else if (data.opt_action == OfxTransactionData::OFX_OPTACTION_EXPIRE)
666 strncpy(dest_string,
"EXPIRE",
sizeof(dest_string));
668 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
669 std::cout <<
" Option action: " << dest_string <<
"\n";
671 if (data.penalty_valid ==
true)
673 std::cout <<
" Penalty withheld (amount): " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.penalty <<
"\n";
675 if (data.pos_type_valid ==
true)
677 if (data.pos_type == OfxTransactionData::OFX_POSTYPE_LONG)
678 strncpy(dest_string,
"LONG",
sizeof(dest_string));
679 else if (data.pos_type == OfxTransactionData::OFX_POSTYPE_SHORT)
680 strncpy(dest_string,
"SHORT",
sizeof(dest_string));
682 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
683 std::cout <<
" Position Type: " << dest_string <<
"\n";
685 if (data.prior_year_contrib_valid ==
true)
687 std::cout <<
" Prior year 401(k) contribution: " << (data.prior_year_contrib ?
"Yes" :
"No") <<
"\n";
689 if (data.related_fi_tid_valid ==
true)
691 std::cout <<
" Related transaction TID: " << data.related_fi_tid <<
"\n";
693 if (data.related_type_valid ==
true)
695 if (data.related_type == OfxTransactionData::OFX_RELTYPE_SPREAD)
696 strncpy(dest_string,
"SPREAD",
sizeof(dest_string));
697 else if (data.related_type == OfxTransactionData::OFX_RELTYPE_STRADDLE)
698 strncpy(dest_string,
"STRADDLE",
sizeof(dest_string));
699 else if (data.related_type == OfxTransactionData::OFX_RELTYPE_NONE)
700 strncpy(dest_string,
"NONE",
sizeof(dest_string));
701 else if (data.related_type == OfxTransactionData::OFX_RELTYPE_OTHER)
702 strncpy(dest_string,
"OTHER",
sizeof(dest_string));
704 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
705 std::cout <<
" Related Option Type: " << dest_string <<
"\n";
707 if (data.option_secured_valid ==
true)
709 if (data.option_secured == OfxTransactionData::OFX_SECURED_NAKED)
710 strncpy(dest_string,
"NAKED",
sizeof(dest_string));
711 else if (data.option_secured == OfxTransactionData::OFX_SECURED_COVERED)
712 strncpy(dest_string,
"COVERED: Cash covered",
sizeof(dest_string));
714 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
715 std::cout <<
" How is the option secured: " << dest_string <<
"\n";
717 if (data.sell_reason_valid ==
true)
719 if (data.sell_reason == OfxTransactionData::OFX_SELLREASON_CALL)
720 strncpy(dest_string,
"CALL: the debt was called",
sizeof(dest_string));
721 else if (data.sell_reason == OfxTransactionData::OFX_SELLREASON_SELL)
722 strncpy(dest_string,
"SELL: the debt was sold",
sizeof(dest_string));
723 else if (data.sell_reason == OfxTransactionData::OFX_SELLREASON_MATURITY)
724 strncpy(dest_string,
"MATURITY: the debt reached maturity",
sizeof(dest_string));
726 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
727 std::cout <<
" Reason for the debt sell: " << dest_string <<
"\n";
729 if (data.sell_type_valid ==
true)
731 if (data.sell_type == OfxTransactionData::OFX_SELL_TYPE_SELL)
732 strncpy(dest_string,
"SELL: Sell",
sizeof(dest_string));
733 else if (data.sell_type == OfxTransactionData::OFX_SELL_TYPE_SELLSHORT)
734 strncpy(dest_string,
"SELLSHORT: Sell short",
sizeof(dest_string));
735 else if (data.sell_type == OfxTransactionData::OFX_SELL_TYPE_SELLTOOPEN)
736 strncpy(dest_string,
"SELLTOOPEN: Sell to open",
sizeof(dest_string));
737 else if (data.sell_type == OfxTransactionData::OFX_SELL_TYPE_SELLTOCLOSE)
738 strncpy(dest_string,
"SELLTOCLOSE: Sell to close",
sizeof(dest_string));
740 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
741 std::cout <<
" Sell type: " << dest_string <<
"\n";
743 if (data.shares_per_cont_valid ==
true)
745 std::cout <<
" Shares per option contract: " << data.shares_per_cont <<
"\n";
747 if (data.state_withholding_valid ==
true)
749 std::cout <<
" State taxes withheld: " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.state_withholding <<
"\n";
751 if (data.subacct_from_valid ==
true)
753 if (data.subacct_from == OfxTransactionData::OFX_SUBACCT_CASH)
754 strncpy(dest_string,
"CASH",
sizeof(dest_string));
755 else if (data.subacct_from == OfxTransactionData::OFX_SUBACCT_MARGIN)
756 strncpy(dest_string,
"MARGIN",
sizeof(dest_string));
757 else if (data.subacct_from == OfxTransactionData::OFX_SUBACCT_SHORT)
758 strncpy(dest_string,
"SHORT",
sizeof(dest_string));
759 else if (data.subacct_from == OfxTransactionData::OFX_SUBACCT_OTHER)
760 strncpy(dest_string,
"OTHER",
sizeof(dest_string));
762 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
763 std::cout <<
" From sub account type: " << dest_string <<
"\n";
765 if (data.subacct_funding_valid ==
true)
767 if (data.subacct_funding == OfxTransactionData::OFX_SUBACCT_CASH)
768 strncpy(dest_string,
"CASH",
sizeof(dest_string));
769 else if (data.subacct_funding == OfxTransactionData::OFX_SUBACCT_MARGIN)
770 strncpy(dest_string,
"MARGIN",
sizeof(dest_string));
771 else if (data.subacct_funding == OfxTransactionData::OFX_SUBACCT_SHORT)
772 strncpy(dest_string,
"SHORT",
sizeof(dest_string));
773 else if (data.subacct_funding == OfxTransactionData::OFX_SUBACCT_OTHER)
774 strncpy(dest_string,
"OTHER",
sizeof(dest_string));
776 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
777 std::cout <<
" Funding sub account type: " << dest_string <<
"\n";
779 if (data.subacct_security_valid ==
true)
781 if (data.subacct_security == OfxTransactionData::OFX_SUBACCT_CASH)
782 strncpy(dest_string,
"CASH",
sizeof(dest_string));
783 else if (data.subacct_security == OfxTransactionData::OFX_SUBACCT_MARGIN)
784 strncpy(dest_string,
"MARGIN",
sizeof(dest_string));
785 else if (data.subacct_security == OfxTransactionData::OFX_SUBACCT_SHORT)
786 strncpy(dest_string,
"SHORT",
sizeof(dest_string));
787 else if (data.subacct_security == OfxTransactionData::OFX_SUBACCT_OTHER)
788 strncpy(dest_string,
"OTHER",
sizeof(dest_string));
790 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
791 std::cout <<
" Security sub account type: " << dest_string <<
"\n";
793 if (data.subacct_to_valid ==
true)
795 if (data.subacct_to == OfxTransactionData::OFX_SUBACCT_CASH)
796 strncpy(dest_string,
"CASH",
sizeof(dest_string));
797 else if (data.subacct_to == OfxTransactionData::OFX_SUBACCT_MARGIN)
798 strncpy(dest_string,
"MARGIN",
sizeof(dest_string));
799 else if (data.subacct_to == OfxTransactionData::OFX_SUBACCT_SHORT)
800 strncpy(dest_string,
"SHORT",
sizeof(dest_string));
801 else if (data.subacct_to == OfxTransactionData::OFX_SUBACCT_OTHER)
802 strncpy(dest_string,
"OTHER",
sizeof(dest_string));
804 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
805 std::cout <<
" To sub account type: " << dest_string <<
"\n";
807 if (data.taxes_valid ==
true)
809 std::cout <<
" Tax on the trade (amount): " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.taxes <<
"\n";
811 if (data.tax_exempt_valid ==
true)
813 std::cout <<
" Tax exempt: " << (data.tax_exempt ?
"Yes" :
"No") <<
"\n";
815 if (data.transfer_action_valid ==
true)
817 if (data.transfer_action == OfxTransactionData::OFX_TFERACTION_IN)
818 strncpy(dest_string,
"IN",
sizeof(dest_string));
819 else if (data.transfer_action == OfxTransactionData::OFX_TFERACTION_OUT)
820 strncpy(dest_string,
"OUT",
sizeof(dest_string));
822 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
823 std::cout <<
" Action for the transfer: " << dest_string <<
"\n";
825 if (data.unit_type_valid ==
true)
827 if (data.unit_type == OfxTransactionData::OFX_UNITTYPE_SHARES)
828 strncpy(dest_string,
"SHARES",
sizeof(dest_string));
829 else if (data.unit_type == OfxTransactionData::OFX_UNITTYPE_CURRENCY)
830 strncpy(dest_string,
"CURRENCY",
sizeof(dest_string));
832 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
833 std::cout <<
" Type of the Units value: " << dest_string <<
"\n";
835 if (data.withholding_valid ==
true)
837 std::cout <<
" Federal tax withheld (amount): " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.withholding <<
"\n";
839 if (data.security_data_valid ==
true)
841 ofx_proc_security_cb(*(data.security_data_ptr), NULL );
847int ofx_proc_position_cb(
struct OfxPositionData data,
void * position_data)
849 char dest_string[255];
850 std::cout <<
"ofx_proc_position():\n";
851 if (data.account_id_valid ==
true)
853 std::cout <<
" Account ID: " << data.account_id <<
"\n";
855 if (data.unique_id_valid ==
true)
857 std::cout <<
" Unique ID of the security: " << data.unique_id <<
"\n";
859 if (data.unique_id_type_valid ==
true)
861 std::cout <<
" Format of the Unique ID: " << data.unique_id_type <<
"\n";
863 if (data.heldinaccount_type_valid ==
true)
865 if (data.heldinaccount_type == OfxPositionData::OFX_HELDINACCT_CASH)
866 strncpy(dest_string,
"CASH: Cash subaccount",
sizeof(dest_string));
867 else if (data.heldinaccount_type == OfxPositionData::OFX_HELDINACCT_MARGIN)
868 strncpy(dest_string,
"MARGIN: Margin subaccount",
sizeof(dest_string));
869 else if (data.heldinaccount_type == OfxPositionData::OFX_HELDINACCT_SHORT)
870 strncpy(dest_string,
"SHORT: Short subaccount",
sizeof(dest_string));
871 else if (data.heldinaccount_type == OfxPositionData::OFX_HELDINACCT_OTHER)
872 strncpy(dest_string,
"OTHER: Other subaccount",
sizeof(dest_string));
874 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
875 std::cout <<
" Held in account type: " << dest_string <<
"\n";
877 if (data.position_type_valid ==
true)
879 if (data.position_type == OfxPositionData::OFX_POSITION_SHORT)
880 strncpy(dest_string,
"SHORT: Short (writer for options, short for all others)",
sizeof(dest_string));
881 else if (data.position_type == OfxPositionData::OFX_POSITION_LONG)
882 strncpy(dest_string,
"LONG: Long (holder for options, long for all others)",
sizeof(dest_string));
884 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
885 std::cout <<
" Position type: " << dest_string <<
"\n";
887 if (data.units_valid ==
true)
889 std::cout <<
" Units: " << std::setprecision(4) << data.units;
890 strncpy(dest_string,
" (bonds: face value; options: contracts; all others: shares)\n",
sizeof(dest_string));
891 if (data.security_data_valid ==
true)
893 if (data.security_data_ptr->security_type_valid ==
true)
895 if (data.security_data_ptr->security_type == OfxSecurityData::OFX_DEBT_SECURITY)
896 strncpy(dest_string,
" (face value)\n",
sizeof(dest_string));
897 else if (data.security_data_ptr->security_type == OfxSecurityData::OFX_FUND_SECURITY ||
898 data.security_data_ptr->security_type == OfxSecurityData::OFX_STOCK_SECURITY ||
899 data.security_data_ptr->security_type == OfxSecurityData::OFX_OTHER_SECURITY)
900 strncpy(dest_string,
" (shares)\n",
sizeof(dest_string));
901 else if (data.security_data_ptr->security_type == OfxSecurityData::OFX_OPTION_SECURITY)
902 strncpy(dest_string,
" (contracts)\n",
sizeof(dest_string));
905 std::cout << dest_string;
907 if (data.unit_price_valid ==
true)
909 if (data.security_data_valid ==
true)
911 std::cout <<
" Unit price: " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(4) << data.unit_price;
912 strncpy(dest_string,
" (bonds: % of par; options: premium per share of underlying; all others: price per share)\n",
sizeof(dest_string));
913 if (data.security_data_ptr->security_type_valid ==
true)
915 if (data.security_data_ptr->security_type == OfxSecurityData::OFX_DEBT_SECURITY)
916 strncpy(dest_string,
"% (% of par)\n",
sizeof(dest_string));
917 else if (data.security_data_ptr->security_type == OfxSecurityData::OFX_FUND_SECURITY ||
918 data.security_data_ptr->security_type == OfxSecurityData::OFX_STOCK_SECURITY ||
919 data.security_data_ptr->security_type == OfxSecurityData::OFX_OTHER_SECURITY)
920 strncpy(dest_string,
" (price per share)\n",
sizeof(dest_string));
921 else if (data.security_data_ptr->security_type == OfxSecurityData::OFX_OPTION_SECURITY)
922 strncpy(dest_string,
" (premium per share of underlying)\n",
sizeof(dest_string));
924 std::cout << dest_string;
927 std::cout <<
" Unit price: " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.unit_price <<
"\n";
929 if (data.market_value_valid ==
true)
931 std::cout <<
" Market Value: " << data.market_value <<
"\n";
933 if (data.amounts_are_foreign_currency_valid ==
true)
935 std::cout <<
" Amounts are in foreign currency: " << (data.amounts_are_foreign_currency ?
"Yes" :
"No") <<
"\n";
937 if (data.currency_valid ==
true)
939 std::cout <<
" Currency: " << data.currency <<
"\n";
941 if (data.currency_ratio_valid ==
true)
943 std::cout <<
" Ratio of default currency to currency: " << data.currency_ratio <<
"\n";
945 if (data.date_unit_price_valid ==
true)
947 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.date_unit_price)));
948 std::cout <<
" Date of unit price: " << dest_string <<
"\n";
950 if (data.memo_valid ==
true)
952 std::cout <<
" Extra position information (memo): " << data.memo <<
"\n";
954 if (data.inv_401k_source_valid ==
true)
956 if (data.inv_401k_source == OfxPositionData::OFX_401K_POSN_SOURCE_PRETAX)
957 strncpy(dest_string,
"PRETAX",
sizeof(dest_string));
958 else if (data.inv_401k_source == OfxPositionData::OFX_401K_POSN_SOURCE_AFTERTAX)
959 strncpy(dest_string,
"AFTERTAX",
sizeof(dest_string));
960 else if (data.inv_401k_source == OfxPositionData::OFX_401K_POSN_SOURCE_MATCH)
961 strncpy(dest_string,
"MATCH",
sizeof(dest_string));
962 else if (data.inv_401k_source == OfxPositionData::OFX_401K_POSN_SOURCE_PROFITSHARING)
963 strncpy(dest_string,
"PROFITSHARING",
sizeof(dest_string));
964 else if (data.inv_401k_source == OfxPositionData::OFX_401K_POSN_SOURCE_ROLLOVER)
965 strncpy(dest_string,
"ROLLOVER",
sizeof(dest_string));
966 else if (data.inv_401k_source == OfxPositionData::OFX_401K_POSN_SOURCE_OTHERVEST)
967 strncpy(dest_string,
"OTHERVEST",
sizeof(dest_string));
968 else if (data.inv_401k_source == OfxPositionData::OFX_401K_POSN_SOURCE_OTHERNONVEST)
969 strncpy(dest_string,
"OTHERNONVEST",
sizeof(dest_string));
971 strncpy(dest_string,
"ERROR: unrecognized",
sizeof(dest_string));
972 std::cout <<
" Source of 401(k) money: " << dest_string <<
"\n";
974 if (data.security_data_valid ==
true)
976 ofx_proc_security_cb(*(data.security_data_ptr), NULL );
982int ofx_proc_statement_cb(
struct OfxStatementData data,
void * statement_data)
984 char dest_string[255];
985 std::cout <<
"ofx_proc_statement():\n";
986 if (data.currency_valid ==
true)
988 std::cout <<
" Default Currency: " << data.currency <<
"\n";
990 if (data.account_id_valid ==
true)
992 std::cout <<
" Account ID: " << data.account_id <<
"\n";
994 if (data.date_asof_valid ==
true)
996 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.date_asof)));
997 std::cout <<
" Statement as-of date: " << dest_string <<
"\n";
999 if (data.date_start_valid ==
true)
1001 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.date_start)));
1002 std::cout <<
" Start date of this statement: " << dest_string <<
"\n";
1004 if (data.date_end_valid ==
true)
1006 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.date_end)));
1007 std::cout <<
" End date of this statement: " << dest_string <<
"\n";
1009 if (data.ledger_balance_valid ==
true)
1011 std::cout <<
" Ledger balance: " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.ledger_balance <<
"\n";
1013 if (data.ledger_balance_date_valid ==
true)
1015 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.ledger_balance_date)));
1016 std::cout <<
" Ledger balance date: " << dest_string <<
"\n";
1018 if (data.available_balance_valid ==
true)
1020 std::cout <<
" Available balance: " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.available_balance <<
"\n";
1022 if (data.available_balance_date_valid ==
true)
1024 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.available_balance_date)));
1025 std::cout <<
" Available balance date: " << dest_string <<
"\n";
1027 if (data.margin_balance_valid ==
true)
1029 std::cout <<
" Margin balance: " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.margin_balance <<
"\n";
1031 if (data.short_balance_valid ==
true)
1033 std::cout <<
" Short balance: " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.short_balance <<
"\n";
1035 if (data.buying_power_valid ==
true)
1037 std::cout <<
" Buying power: " << std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::showpoint) << std::setprecision(2) << data.buying_power <<
"\n";
1039 if (data.marketing_info_valid ==
true)
1041 std::cout <<
" Marketing information: " << data.marketing_info <<
"\n";
1047int ofx_proc_account_cb(
struct OfxAccountData data,
void * account_data)
1049 std::cout <<
"ofx_proc_account():\n";
1050 if (data.account_id_valid ==
true)
1052 std::cout <<
" Account ID: " << data.account_id <<
"\n";
1053 std::cout <<
" Account name: " << data.account_name <<
"\n";
1055 if (data.account_type_valid ==
true)
1057 std::cout <<
" Account type: ";
1058 switch (data.account_type)
1060 case OfxAccountData::OFX_CHECKING :
1061 std::cout <<
"CHECKING\n";
1063 case OfxAccountData::OFX_SAVINGS :
1064 std::cout <<
"SAVINGS\n";
1066 case OfxAccountData::OFX_MONEYMRKT :
1067 std::cout <<
"MONEYMRKT\n";
1069 case OfxAccountData::OFX_CREDITLINE :
1070 std::cout <<
"CREDITLINE\n";
1072 case OfxAccountData::OFX_CMA :
1073 std::cout <<
"CMA\n";
1075 case OfxAccountData::OFX_CREDITCARD :
1076 std::cout <<
"CREDITCARD\n";
1078 case OfxAccountData::OFX_INVESTMENT :
1079 std::cout <<
"INVESTMENT\n";
1082 std::cout <<
"ofx_proc_account() WRITEME: This is an unknown account type!";
1085 if (data.currency_valid ==
true)
1087 std::cout <<
" Default Currency: " << data.currency <<
"\n";
1090 if (data.bank_id_valid)
1091 std::cout <<
" Bank ID: " << data.bank_id << std::endl;;
1093 if (data.branch_id_valid)
1094 std::cout <<
" Branch ID: " << data.branch_id << std::endl;
1096 if (data.account_number_valid)
1097 std::cout <<
" Account #: " << data.account_number << std::endl;
1105int ofx_proc_status_cb(
struct OfxStatusData data,
void * status_data)
1107 std::cout <<
"ofx_proc_status():\n";
1108 if (data.ofx_element_name_valid ==
true)
1110 std::cout <<
" Ofx entity this status is relevant to: " << data.ofx_element_name <<
" \n";
1112 if (data.severity_valid ==
true)
1114 std::cout <<
" Severity: ";
1115 switch (data.severity)
1117 case OfxStatusData::INFO :
1118 std::cout <<
"INFO\n";
1120 case OfxStatusData::WARN :
1121 std::cout <<
"WARN\n";
1123 case OfxStatusData::ERROR :
1124 std::cout <<
"ERROR\n";
1127 std::cout <<
"WRITEME: Unknown status severity!\n";
1130 if (data.code_valid ==
true)
1132 std::cout <<
" Code: " << data.code <<
", name: " << data.name <<
"\n Description: " << data.description <<
"\n";
1134 if (data.server_message_valid ==
true)
1136 std::cout <<
" Server Message: " << data.server_message <<
"\n";
1149 if (cmdline_parser (argc, argv, &args_info) != 0)
1165 bool skiphelp =
false;
1170 std::cout <<
"The supported file formats for the 'input-file-format' argument are:" << std::endl;
1171 for (
int i = 0; LibofxImportFormatList[i].format != LAST; i++)
1173 std::cout <<
" " << LibofxImportFormatList[i].description << std::endl;
1177 LibofxContextPtr libofx_context = libofx_get_new_context();
1185 ofx_set_statement_cb(libofx_context, ofx_proc_statement_cb, 0);
1186 ofx_set_account_cb(libofx_context, ofx_proc_account_cb, 0);
1187 ofx_set_transaction_cb(libofx_context, ofx_proc_transaction_cb, 0);
1188 ofx_set_security_cb(libofx_context, ofx_proc_security_cb, 0);
1189 ofx_set_status_cb(libofx_context, ofx_proc_status_cb, 0);
1190 ofx_set_position_cb(libofx_context, ofx_proc_position_cb, 0);
1192 enum LibofxFileFormat file_format = libofx_get_file_format_from_str(LibofxImportFormatList, args_info.
import_format_arg);
1196 std::cout <<
"Sorry, currently, only the first file is processed as the library can't deal with more right now. The following files were ignored:" << std::endl;
1197 for (
unsigned i = 1 ; i < args_info.
inputs_num ; ++i )
1199 std::cout <<
"file: " << args_info.
inputs[i] << std::endl ;
1202 rc = libofx_proc_file(libofx_context, args_info.
inputs[0], file_format);
1210 libofx_free_context(libofx_context);
1211 cmdline_parser_free(&args_info);
LIBOFX_API int ofx_STATUS_msg
LIBOFX_API int ofx_DEBUG_msg
LIBOFX_API int ofx_INFO_msg
LIBOFX_API int ofx_WARNING_msg
LIBOFX_API int ofx_PARSER_msg
LIBOFX_API int ofx_ERROR_msg
void cmdline_parser_print_help(void)
The header file for the command line option parser generated by GNU Gengetopt version 2....
int main(int argc, char *argv[])
Where the command line options are stored.
int msg_status_flag
Output status messages (default=on).
unsigned int list_import_formats_given
Whether list-import-formats was given.
unsigned inputs_num
unnamed options number
int msg_parser_flag
Output file parsing messages (default=off).
int msg_debug_flag
Output messages meant for debugging (default=off).
char ** inputs
unnamed options (options without names)
int msg_info_flag
Output informational messages about the progress of the library (default=on).
int msg_warning_flag
Output warning messages about abnormal conditions and unknown constructs (default=on).
int msg_error_flag
Output error messages (default=on).
char * import_format_arg
Force the file format of the file(s) specified (default='AUTODETECT').