-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f69ba8
commit 74f78a3
Showing
12 changed files
with
451 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
Order ID,Order Number,Side,Exchange,Symbol,Market,Price,Volume,Disclosed,Value,Fee,Term,Validity,Trigger Type,Trigger Price,Settlement Term,Settlement Date,Settlement Type,Short Sell,Account ID,Account Name,Last Trade ID,Last Trade Ticket,Status,Initiated By,Updated By,Update Type,Update Time,Request ID,Request Type,Request Status | ||
6750,58525243,Buy,BVB,TVBETETF,REGS,24.655000,20,,493.100000,3.270000,Day,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,New,2024-03-05 10:15:40,,, | ||
6750,58525243,Buy,BVB,TVBETETF,REGS,24.745000,20,,494.900000,3.280000,Day,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-03-05 11:32:23,,, | ||
6750,58525243,Buy,BVB,TVBETETF,REGS,24.745000,20,,494.900000,3.280000,Day,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-03-05 11:32:44,12177,Change,Deleted | ||
6750,58525243,Buy,BVB,TVBETETF,REGS,24.745000,20,,0.000000,0.000000,Day,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],7573,24141773,Inactive,JD123456,JD123456,Fil,2024-03-05 12:06:20,,, | ||
9058,58948320,Buy,BVB,TVBETETF,REGS,25.000000,99,,2475.000000,10.610000,Day,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,New,2024-04-11 10:11:27,,, | ||
9058,58948320,Buy,BVB,TVBETETF,REGS,25.000000,99,,2475.000000,10.610000,Day,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,New,2024-04-11 15:43:27,16109,Change,Deleted | ||
9058,58948320,Buy,BVB,TVBETETF,REGS,25.700000,96,,2467.200000,10.580000,Day,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-04-11 15:43:55,,, | ||
9058,58948320,Buy,BVB,TVBETETF,REGS,25.700000,96,,2467.200000,10.580000,Day,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Inactive,JD123456,RIVER,OOT,2024-04-12 00:00:12,,, | ||
9202,58974306,Buy,BVB,TVBETETF,REGS,25.930000,96,,2489.280000,10.660000,Day,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,New,2024-04-12 13:26:12,,, | ||
9202,58974306,Buy,BVB,TVBETETF,REGS,25.930000,96,,0.000000,0.000000,Day,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],10266,24404999,Inactive,JD123456,JD123456,Fil,2024-04-12 14:41:34,,, | ||
9359,58996052,Buy,BVB,R2704A,POFB,100.000000,300,,30000.000000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,New,2024-04-15 12:37:00,,, | ||
9359,58996052,Buy,BVB,R2704A,POFB,100.000000,300,,0.000000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],10738,24454742,Inactive,JD123456,JD123456,Fil,2024-04-18 09:26:50,,, | ||
10938,59236035,Buy,BVB,TVBETETF,REGS,26.160000,95,,2485.200000,10.650000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,New,2024-05-13 10:30:27,,, | ||
10938,59236035,Buy,BVB,TVBETETF,REGS,26.160000,95,,2485.200000,10.650000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,New,2024-05-13 11:18:48,18840,Change,Deleted | ||
10938,59236035,Buy,BVB,TVBETETF,REGS,26.390000,94,,2480.660000,10.630000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-13 11:19:20,,, | ||
10938,59236035,Buy,BVB,TVBETETF,REGS,26.390000,94,,0.000000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],11895,24563391,Inactive,JD123456,JD123456,Fil,2024-05-13 11:43:07,,, | ||
12753,59442013,Buy,BVB,ICBETNETF,REGS,74.570000,267,,19910.190000,61.180000,Day,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,New,2024-05-29 10:10:35,,, | ||
12753,59442013,Buy,BVB,ICBETNETF,REGS,74.550000,267,,19904.850000,61.160000,Day,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-29 10:11:35,,, | ||
12753,59442013,Buy,BVB,ICBETNETF,REGS,74.550000,267,,0.000000,0.000000,Day,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],13906,24704498,Inactive,JD123456,JD123456,Fil,2024-05-29 10:12:07,,, | ||
12779,59442559,Sell,BVB,TVBETETF,REGS,27.750000,210,,5827.500000,0.000000,Day,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,New,2024-05-29 10:16:18,,, | ||
12779,59442559,Sell,BVB,TVBETETF,REGS,27.600000,210,,5796.000000,0.000000,Day,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-29 12:01:13,,, | ||
12779,59442559,Sell,BVB,TVBETETF,REGS,27.700000,210,,5817.000000,0.000000,Day,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-29 12:02:31,,, | ||
12779,59442559,Sell,BVB,TVBETETF,REGS,27.650000,210,,5806.500000,0.000000,Day,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-29 12:03:14,,, | ||
12779,59442559,Sell,BVB,TVBETETF,REGS,27.640000,210,,5804.400000,0.000000,Day,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-29 12:04:07,,, | ||
12779,59442559,Sell,BVB,TVBETETF,REGS,27.640000,210,,5804.400000,0.000000,Day,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Inactive,JD123456,RIVER,OOT,2024-05-30 00:00:12,,, | ||
13268,59479550,Sell,BVB,TVBETETF,REGS,27.800000,210,,5838.000000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,New,2024-05-31 09:45:00,,, | ||
13268,59479550,Sell,BVB,TVBETETF,REGS,27.740000,210,,5825.400000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-31 10:05:49,,, | ||
13268,59479550,Sell,BVB,TVBETETF,REGS,27.500000,210,,5775.000000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-31 10:51:42,,, | ||
13268,59479550,Sell,BVB,TVBETETF,REGS,27.300000,210,,5733.000000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-31 10:52:08,,, | ||
13268,59479550,Sell,BVB,TVBETETF,REGS,27.250000,210,,5722.500000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-31 11:08:23,,, | ||
13268,59479550,Sell,BVB,TVBETETF,REGS,27.230000,210,,5718.300000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-31 11:35:12,,, | ||
13268,59479550,Sell,BVB,TVBETETF,REGS,27.210000,210,,5714.100000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-31 11:39:49,,, | ||
13268,59479550,Sell,BVB,TVBETETF,REGS,27.205000,210,,5713.050000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-31 12:01:14,,, | ||
13268,59479550,Sell,BVB,TVBETETF,REGS,27.200000,210,,5712.000000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-31 12:04:31,,, | ||
13268,59479550,Sell,BVB,TVBETETF,REGS,27.180000,210,,5707.800000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-31 12:34:00,,, | ||
13268,59479550,Sell,BVB,TVBETETF,REGS,27.120000,210,,5695.200000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-31 12:34:50,,, | ||
13268,59479550,Sell,BVB,TVBETETF,REGS,27.100000,210,,5691.000000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-31 12:38:12,,, | ||
13268,59479550,Sell,BVB,TVBETETF,REGS,27.200000,210,,5712.000000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-31 12:40:58,,, | ||
13268,59479550,Sell,BVB,TVBETETF,REGS,27.185000,210,,5708.850000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-31 12:41:15,,, | ||
13268,59479550,Sell,BVB,TVBETETF,REGS,27.185000,200,,5437.000000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],15086,24734177,Active,JD123456,JD123456,Fil,2024-05-31 12:41:49,,, | ||
13268,59479550,Sell,BVB,TVBETETF,REGS,27.185000,145,,3941.825000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],15087,24734207,Active,JD123456,JD123456,Fil,2024-05-31 12:44:12,,, | ||
13268,59479550,Sell,BVB,TVBETETF,REGS,27.190000,145,,3942.550000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,24734207,Active,JD123456,JD123456,Chg,2024-05-31 12:46:59,,, | ||
13268,59479550,Sell,BVB,TVBETETF,REGS,27.190000,137,,3725.030000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],15092,24734255,Active,JD123456,JD123456,Fil,2024-05-31 12:47:24,,, | ||
13268,59479550,Sell,BVB,TVBETETF,REGS,27.190000,64,,1740.160000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],15093,24734266,Active,JD123456,JD123456,Fil,2024-05-31 12:48:32,,, | ||
13268,59479550,Sell,BVB,TVBETETF,REGS,27.190000,64,,0.000000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],15094,24734269,Inactive,JD123456,JD123456,Fil,2024-05-31 12:48:44,,, | ||
13375,59489119,Buy,BVB,ICBETNETF,REGS,73.060000,78,,5698.680000,18.550000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,New,2024-05-31 12:49:37,,, | ||
13375,59489119,Buy,BVB,ICBETNETF,REGS,73.070000,78,,5699.460000,18.550000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-31 12:49:57,,, | ||
13375,59489119,Buy,BVB,ICBETNETF,REGS,73.190000,77,,5635.630000,18.360000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-31 13:02:10,,, | ||
13375,59489119,Buy,BVB,ICBETNETF,REGS,73.200000,77,,5636.400000,18.360000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-31 13:06:03,,, | ||
13375,59489119,Buy,BVB,ICBETNETF,REGS,73.210000,77,,5637.170000,18.360000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Active,JD123456,JD123456,Chg,2024-05-31 13:13:16,,, | ||
13375,59489119,Buy,BVB,ICBETNETF,REGS,73.210000,77,,0.000000,0.000000,Open,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],15122,24734950,Inactive,JD123456,JD123456,Fil,2024-05-31 13:33:56,,, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import { InvestimentalConverter } from "./investimentalConverter"; | ||
import { SecurityService } from "../securityService"; | ||
import { GhostfolioExport } from "../models/ghostfolioExport"; | ||
import YahooFinanceServiceMock from "../testing/yahooFinanceServiceMock"; | ||
|
||
|
||
describe("investimentalConverter", () => { | ||
|
||
beforeEach(() => { | ||
jest.spyOn(console, "log").mockImplementation(jest.fn()); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it("should construct", () => { | ||
|
||
// Act | ||
const sut = new InvestimentalConverter(new SecurityService(new YahooFinanceServiceMock())); | ||
|
||
// Assert | ||
expect(sut).toBeTruthy(); | ||
}); | ||
|
||
it("should process sample CSV file", (done) => { | ||
|
||
// Arange | ||
const sut = new InvestimentalConverter(new SecurityService(new YahooFinanceServiceMock())); | ||
const inputFile = "samples/investimental-export.csv"; | ||
|
||
// Act | ||
sut.readAndProcessFile(inputFile, (actualExport: GhostfolioExport) => { | ||
|
||
// Assert | ||
expect(actualExport).toBeTruthy(); | ||
expect(actualExport.activities.length).toBeGreaterThan(0); | ||
expect(actualExport.activities.length).toBe(6); | ||
|
||
done(); | ||
}, () => { done.fail("Should not have an error!"); }); | ||
}); | ||
|
||
describe("should throw an error if", () => { | ||
it("the input file does not exist", (done) => { | ||
|
||
// Arrange | ||
const sut = new InvestimentalConverter(new SecurityService(new YahooFinanceServiceMock())); | ||
|
||
let tempFileName = "tmp/testinput/investimental-filedoesnotexist.csv"; | ||
|
||
// Act | ||
sut.readAndProcessFile(tempFileName, () => { done.fail("Should not succeed!"); }, (err: Error) => { | ||
|
||
// Assert | ||
expect(err).toBeTruthy(); | ||
|
||
done(); | ||
}); | ||
}); | ||
|
||
it("the input file is empty", (done) => { | ||
|
||
// Arrange | ||
const sut = new InvestimentalConverter(new SecurityService(new YahooFinanceServiceMock())); | ||
|
||
let tempFileContent = "Order ID,Order Number,Side,Exchange,Symbol,Market,Price,Volume,Disclosed,Value,Fee,Term,Validity,Trigger Type,Trigger Price,Settlement Term,Settlement Date,Settlement Type,Short Sell,Account ID,Account Name,Last Trade ID,Last Trade Ticket,Status,Initiated By,Updated By,Update Type,Update Time,Request ID,Request Type,Request Status\n"; | ||
|
||
// Act | ||
sut.processFileContents(tempFileContent, () => { done.fail("Should not succeed!"); }, (err: Error) => { | ||
|
||
// Assert | ||
expect(err).toBeTruthy(); | ||
expect(err.message).toContain("An error ocurred while parsing"); | ||
|
||
done(); | ||
}); | ||
}); | ||
|
||
it("Yahoo Finance throws an error", (done) => { | ||
|
||
// Arrange | ||
let tempFileContent = "Order ID,Order Number,Side,Exchange,Symbol,Market,Price,Volume,Disclosed,Value,Fee,Term,Validity,Trigger Type,Trigger Price,Settlement Term,Settlement Date,Settlement Type,Short Sell,Account ID,Account Name,Last Trade ID,Last Trade Ticket,Status,Initiated By,Updated By,Update Type,Update Time,Request ID,Request Type,Request Status\n"; | ||
tempFileContent += "6750,58525243,Buy,BVB,TVBETETF,REGS,24.745000,20,,494.900000,0,Day,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Inactive,JD123456,JD123456,Fil,2024-03-05 12:06:20,,,"; | ||
|
||
// Mock Yahoo Finance service to throw error. | ||
const yahooFinanceServiceMock = new YahooFinanceServiceMock(); | ||
jest.spyOn(yahooFinanceServiceMock, "search").mockImplementation(() => { throw new Error("Unit test error"); }); | ||
const sut = new InvestimentalConverter(new SecurityService(yahooFinanceServiceMock)); | ||
|
||
// Act | ||
sut.processFileContents(tempFileContent, () => { done.fail("Should not succeed!"); }, (err: Error) => { | ||
|
||
// Assert | ||
expect(err).toBeTruthy(); | ||
expect(err.message).toContain("Unit test error"); | ||
|
||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
it("should log when YahooX Finance returns no symbol", (done) => { | ||
|
||
// Arrange | ||
let tempFileContent = "Order ID,Order Number,Side,Exchange,Symbol,Market,Price,Volume,Disclosed,Value,Fee,Term,Validity,Trigger Type,Trigger Price,Settlement Term,Settlement Date,Settlement Type,Short Sell,Account ID,Account Name,Last Trade ID,Last Trade Ticket,Status,Initiated By,Updated By,Update Type,Update Time,Request ID,Request Type,Request Status\n"; | ||
tempFileContent += "6750,58525243,Buy,BVB,TVBETETF,REGS,24.745000,20,,494.900000,0,Day,,None,,T+2,,Net,No,JD123456RR1,JOHN DOE [RON],0,0,Inactive,JD123456,JD123456,Fil,2024-03-05 12:06:20,,,"; | ||
|
||
// Mock Yahoo Finance service to return no quotes. | ||
const yahooFinanceServiceMock = new YahooFinanceServiceMock(); | ||
jest.spyOn(yahooFinanceServiceMock, "search").mockImplementation(() => { return Promise.resolve({ quotes: [] }) }); | ||
const sut = new InvestimentalConverter(new SecurityService(yahooFinanceServiceMock)); | ||
|
||
// Bit hacky, but it works. | ||
const consoleSpy = jest.spyOn((sut as any).progress, "log"); | ||
|
||
// Act | ||
sut.processFileContents(tempFileContent, () => { | ||
|
||
expect(consoleSpy).toHaveBeenCalledWith("[i] No result found for action buy, symbol TVBETETF, currency RON! Please add this manually..\n"); | ||
|
||
done(); | ||
}, () => done.fail("Should not have an error!")); | ||
}); | ||
}); |
Oops, something went wrong.