From 46e796def212ea0998ce2fba581b88b1a8034559 Mon Sep 17 00:00:00 2001 From: "Raphael C. Almeida" Date: Sat, 20 Jun 2020 22:00:53 -0300 Subject: [PATCH] Moved models outside internal --- pkg/b3/get_history.go | 2 +- pkg/internal/models/asset.go | 35 --------------------------- pkg/internal/parser/history_parser.go | 4 +-- pkg/models/asset.go | 35 +++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 38 deletions(-) delete mode 100644 pkg/internal/models/asset.go create mode 100644 pkg/models/asset.go diff --git a/pkg/b3/get_history.go b/pkg/b3/get_history.go index d97e047..4e4026f 100644 --- a/pkg/b3/get_history.go +++ b/pkg/b3/get_history.go @@ -2,8 +2,8 @@ package b3 import ( "github.com/Bezunca/B3History/pkg/http" - "github.com/Bezunca/B3History/pkg/internal/models" "github.com/Bezunca/B3History/pkg/internal/parser" + "github.com/Bezunca/B3History/pkg/models" "github.com/Bezunca/ZipInMemory/pkg/zip" ) diff --git a/pkg/internal/models/asset.go b/pkg/internal/models/asset.go deleted file mode 100644 index 0060b73..0000000 --- a/pkg/internal/models/asset.go +++ /dev/null @@ -1,35 +0,0 @@ -package models - -import "time" - -type FixedPoint int // Represents the actual value multiplied by 100 - -type AssetInfo struct { - Year int `json:"year" bson:"year"` - TipReg int `json:"-" bson:"-" ` - DataCollectionDate time.Time `json:"data" bson:"data"` - BDICode int `json:"-" bson:"-"` - Ticker string `json:"ticker" bson:"ticker"` - MarketType int `json:"market_type" bson:"market_type"` - CompanyName string `json:"shot_company_name" bson:"shot_company_name"` - SecurityType string `json:"security_type" bson:"security_type"` - FutureMarketExpiration string `json:" future_market_expiration" bson:" future_market_expiration"` // Need to check this against an example that actually has a value - Currency string `json:"currency" bson:"currency"` - PriceOpen FixedPoint `json:"-" bson:"-"` - PriceMax FixedPoint `json:"-" bson:"-"` - PriceMin FixedPoint `json:"-" bson:"-"` - PriceMean FixedPoint `json:"-" bson:"-"` - PriceClose FixedPoint `json:"price_close" bson:"price_close"` - PriceBid FixedPoint `json:"-" bson:"-"` - PriceAsk FixedPoint `json:"-" bson:"-"` - TotalTrades int `json:"-" bson:"-"` - TotalQuantity int `json:"-" bson:"-"` - TotalVolume FixedPoint `json:"total_volume" bson:"total_volume"` - PreExe FixedPoint `json:"execution_price" bson:"execution_price"` // Needs further investigation - IndOpc int `json:"-" bson:"-"` // Needs further investigation - ExpirationDate time.Time `json:"expiration_date" bson:"expiration_date"` - FatCot int `json:"-" bson:"-"` // Needs further investigation - PtoExe int `json:"-" bson:"-"` // Needs further investigation - ISINCode string `json:"-" bson:"-"` - DistributionNumber int `json:"-" bson:"-"` -} diff --git a/pkg/internal/parser/history_parser.go b/pkg/internal/parser/history_parser.go index fdc6757..f1f4f42 100644 --- a/pkg/internal/parser/history_parser.go +++ b/pkg/internal/parser/history_parser.go @@ -5,7 +5,7 @@ import ( "strings" "time" - "github.com/Bezunca/B3History/pkg/internal/models" + "github.com/Bezunca/B3History/pkg/models" ) func parseContentLine(rawLine string, year int) (*models.AssetInfo, error) { @@ -90,7 +90,7 @@ func parseContentLine(rawLine string, year int) (*models.AssetInfo, error) { return nil, err } return &models.AssetInfo{ - Year: year, + Year: year, TipReg: int(tipReg), DataCollectionDate: date, BDICode: int(bdiCode), diff --git a/pkg/models/asset.go b/pkg/models/asset.go new file mode 100644 index 0000000..eba47da --- /dev/null +++ b/pkg/models/asset.go @@ -0,0 +1,35 @@ +package models + +import "time" + +type FixedPoint int // Represents the actual value multiplied by 100 + +type AssetInfo struct { + Year int `json:"year" bson:"year"` + TipReg int `json:"-" bson:"-" ` + DataCollectionDate time.Time `json:"data" bson:"data"` + BDICode int `json:"-" bson:"-"` + Ticker string `json:"ticker" bson:"ticker"` + MarketType int `json:"market_type" bson:"market_type"` + CompanyName string `json:"shot_company_name" bson:"shot_company_name"` + SecurityType string `json:"security_type" bson:"security_type"` + FutureMarketExpiration string `json:" future_market_expiration" bson:" future_market_expiration"` // Need to check this against an example that actually has a value + Currency string `json:"currency" bson:"currency"` + PriceOpen FixedPoint `json:"-" bson:"-"` + PriceMax FixedPoint `json:"-" bson:"-"` + PriceMin FixedPoint `json:"-" bson:"-"` + PriceMean FixedPoint `json:"-" bson:"-"` + PriceClose FixedPoint `json:"price_close" bson:"price_close"` + PriceBid FixedPoint `json:"-" bson:"-"` + PriceAsk FixedPoint `json:"-" bson:"-"` + TotalTrades int `json:"-" bson:"-"` + TotalQuantity int `json:"-" bson:"-"` + TotalVolume FixedPoint `json:"total_volume" bson:"total_volume"` + PreExe FixedPoint `json:"execution_price" bson:"execution_price"` // Needs further investigation + IndOpc int `json:"-" bson:"-"` // Needs further investigation + ExpirationDate time.Time `json:"expiration_date" bson:"expiration_date"` + FatCot int `json:"-" bson:"-"` // Needs further investigation + PtoExe int `json:"-" bson:"-"` // Needs further investigation + ISINCode string `json:"-" bson:"-"` + DistributionNumber int `json:"-" bson:"-"` +}