Skip to content

Commit

Permalink
fix for #7 to support non-All-Accounts for Chuck (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
reedes authored Oct 29, 2021
1 parent 361e75e commit 8452bb5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Sources/Importers/ChuckPositions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ChuckPositions: FINporter {
private let trimFromTicker = CharacterSet(charactersIn: "*")

internal static let headerRE = #"""
"Positions for All-Accounts as of .+"
"Positions for .+? as of .+"
".+"
"Symbol","Description","Quantity","Price","Price Change \$","Price Change %","Market Value","Day Change \$","Day Change %","Cost Basis",.+
Expand Down Expand Up @@ -163,7 +163,7 @@ class ChuckPositions: FINporter {
}

// extract exportedAt from "Positions for All-Accounts as of 09:59 PM ET, 09/26/2021" (with quotes)
let ddRE = #"(?<=\"Positions for All-Accounts as of ).+(?=\")"#
let ddRE = #"(?<= as of ).+(?=\")"#
if let dd = str.range(of: ddRE, options: .regularExpression),
let exportedAt = chuckDateFormatter.date(from: String(str[dd])) {
decodedRow[MSourceMeta.CodingKeys.exportedAt.rawValue] = exportedAt
Expand Down
6 changes: 3 additions & 3 deletions Tests/Importers/ChuckPositionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ final class ChuckPositionsTests: XCTestCase {
let df = ISO8601DateFormatter()

let goodHeader1 = """
"Positions for All-Accounts as of 09:59 PM ET, 09/26/2021"
"Positions for AAA-AAAAAAAAA as of 09:59 PM ET, 09/26/2021"
"Individual XXXX-1234"
"Symbol","Description","Quantity","Price","Price Change $","Price Change %","Market Value","Day Change $","Day Change %","Cost Basis","Gain/Loss $",...
"""

let goodHeader2 = "\"Positions for All-Accounts as of 09:59 PM ET, 09/26/2021\"\r\n\r\n\"Individual XXXX-1234\"\r\n\"Symbol\",\"Description\",\"Quantity\",\"Price\",\"Price Change $\",\"Price Change %\",\"Market Value\",\"Day Change $\",\"Day Change %\",\"Cost Basis\",\"Gain/Loss $\",\"Gain/Loss %\",\"Reinvest Dividends?\",\"Capital Gains?\",\"% Of Account\",\"Dividend Yield\",\"Last Dividend\",\"Ex-Dividend Date\",\"P/E Ratio\",\"52 Week Low\",\"52 Week High\",\"Volume\",\"Intrinsic Value\",\"In The Money\",\"Security Type\",\r\n"
let goodHeader2 = "\"Positions for AAA-AAAAAAAAA as of 09:59 PM ET, 09/26/2021\"\r\n\r\n\"Individual XXXX-1234\"\r\n\"Symbol\",\"Description\",\"Quantity\",\"Price\",\"Price Change $\",\"Price Change %\",\"Market Value\",\"Day Change $\",\"Day Change %\",\"Cost Basis\",\"Gain/Loss $\",\"Gain/Loss %\",\"Reinvest Dividends?\",\"Capital Gains?\",\"% Of Account\",\"Dividend Yield\",\"Last Dividend\",\"Ex-Dividend Date\",\"P/E Ratio\",\"52 Week Low\",\"52 Week High\",\"Volume\",\"Intrinsic Value\",\"In The Money\",\"Security Type\",\r\n"

let goodBody = """
"Positions for All-Accounts as of 09:59 PM ET, 09/26/2021"
"Positions for AAA-AAAAAAAAA as of 09:59 PM ET, 09/26/2021"
"Individual XXXX-1234"
"Symbol","Description","Quantity","Price","Price Change $","Price Change %","Market Value","Day Change $","Day Change %","Cost Basis","Gain/Loss $","Gain/Loss %","Reinvest Dividends?","Capital Gains?","% Of Account","Dividend Yield","Last Dividend","Ex-Dividend Date","P/E Ratio","52 Week Low","52 Week High","Volume","Intrinsic Value","In The Money","Security Type",
Expand Down

0 comments on commit 8452bb5

Please sign in to comment.