-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshareLoader.fs
26 lines (19 loc) · 938 Bytes
/
shareLoader.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module DividendExplorer.shareLoader
// Source file located at https://spbexchange.ru/ru/stocks/inostrannye/Instruments.aspx
open System.IO
open System.Text
open FSharp.Data
open DividendExplorer.types
[<Literal>]
let sourceFilePath = "ListingSecurityList.csv"
type Securities = CsvProvider<sourceFilePath, Separators=";", ResolutionFolder=__SOURCE_DIRECTORY__>
let isShare (r: Securities.Row) = r.S_sec_type_name_dop = "Акции"
let toShare(row: Securities.Row) = { symbol = row.S_RTS_code; name = row.E_full_name }
let loadShares() =
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance)
utils.write $"Load source file from {sourceFilePath}"
use reader = new StreamReader(sourceFilePath, Encoding.GetEncoding(1251))
let provider = Securities.Load reader
let result = provider.Rows |> Seq.filter isShare |> Seq.map toShare |> List.ofSeq
utils.write $"Found {Seq.length result} shares"
result