manager

package
v0.0.0-...-55ba461 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SIDE_MONITOR          = 1
	MAIL_WORKSPACE        = "2"
	DATE_FORMAT           = "20060102__150405"
	LOGSEQ_CLASS          = "Logseq"
	NETWORK_RESTART_DELAY = 5 * time.Second
	UI_INTERACTION_DELAY  = 50 * time.Millisecond
	TRADE_INFO            = `
Trends
HTF - Up
MTF - Up
TTF - Up

Plan: Longs @ TTF DZ

Obstacles:
-

Support:
-`
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountManager

type AccountManager interface {
	GetRecord(ctx context.Context, symbol string) (tax.Account, common.HttpError)
}

func NewAccountManager

func NewAccountManager(repo repository.AccountRepository) AccountManager

type AccountManagerImpl

type AccountManagerImpl struct {
	// contains filtered or unexported fields
}

func (*AccountManagerImpl) GetRecord

func (a *AccountManagerImpl) GetRecord(ctx context.Context, symbol string) (account tax.Account, err common.HttpError)

type AutoManagerImpl

type AutoManagerImpl struct {
	// contains filtered or unexported fields
}

func (*AutoManagerImpl) MonitorInternetConnection

func (a *AutoManagerImpl) MonitorInternetConnection(_ context.Context)

func (*AutoManagerImpl) MonitorSubmap

func (a *AutoManagerImpl) MonitorSubmap(_ context.Context)

func (*AutoManagerImpl) RecordTicker

func (a *AutoManagerImpl) RecordTicker(_ context.Context, ticker, path string) (err error)

Copy existing implementations preserving comments but as methods

func (*AutoManagerImpl) TryOpenTicker

func (a *AutoManagerImpl) TryOpenTicker(_ context.Context, ticker string)

type AutoManagerInterface

type AutoManagerInterface interface {
	RecordTicker(ctx context.Context, ticker, path string) error
	TryOpenTicker(ctx context.Context, ticker string)
	MonitorInternetConnection(ctx context.Context)
	MonitorSubmap(ctx context.Context)
}

func NewAutoManager

func NewAutoManager(wait time.Duration, capturePath string) AutoManagerInterface

type CapitalGainManager

type CapitalGainManager interface {
	ProcessTaxGains(ctx context.Context, gains []tax.Gains) ([]tax.INRGains, common.HttpError)
	GetGainsForYear(ctx context.Context, year int) ([]tax.Gains, common.HttpError)
}

type CapitalGainManagerImpl

type CapitalGainManagerImpl struct {
	// contains filtered or unexported fields
}

func NewCapitalGainManager

func NewCapitalGainManager(exchangeManager ExchangeManager,
	gainsRepository repository.GainsRepository,
	financialYearManager FinancialYearManager[tax.Gains]) *CapitalGainManagerImpl

func (*CapitalGainManagerImpl) GetGainsForYear

func (c *CapitalGainManagerImpl) GetGainsForYear(ctx context.Context, year int) ([]tax.Gains, common.HttpError)

func (*CapitalGainManagerImpl) ProcessTaxGains

func (c *CapitalGainManagerImpl) ProcessTaxGains(ctx context.Context, gains []tax.Gains) ([]tax.INRGains, common.HttpError)

type DividendManager

type DividendManager interface {
	// Retrieves all Dividend records for the specified financial year.
	// The year parameter represents the starting year of the financial year (e.g., 2023 for FY 2023-24).
	GetDividendsForYear(ctx context.Context, year int) ([]tax.Dividend, common.HttpError)

	// Processes a list of Dividend records, adding INR values based on exchange rates.
	ProcessDividends(ctx context.Context, dividends []tax.Dividend) ([]tax.INRDividend, common.HttpError)
}

type DividendManagerImpl

type DividendManagerImpl struct {
	// contains filtered or unexported fields
}

func NewDividendManager

func NewDividendManager(
	exchangeManager ExchangeManager,
	financialYearManager FinancialYearManager[tax.Dividend],
	dividendRepository repository.DividendRepository,
) *DividendManagerImpl

func (*DividendManagerImpl) GetDividendsForYear

func (d *DividendManagerImpl) GetDividendsForYear(ctx context.Context, year int) ([]tax.Dividend, common.HttpError)

GetDividendsForYear implementation added

func (*DividendManagerImpl) ProcessDividends

func (d *DividendManagerImpl) ProcessDividends(ctx context.Context, dividends []tax.Dividend) (inrDividends []tax.INRDividend, err common.HttpError)

type ExcelManager

type ExcelManager interface {
	GenerateTaxSummaryExcel(ctx context.Context, summary tax.Summary) error
}

func NewExcelManager

func NewExcelManager(outputFilePath string) ExcelManager

type ExcelManagerImpl

type ExcelManagerImpl struct {
	// contains filtered or unexported fields
}

func (*ExcelManagerImpl) GenerateTaxSummaryExcel

func (e *ExcelManagerImpl) GenerateTaxSummaryExcel(ctx context.Context, summary tax.Summary) error

type ExchangeManager

type ExchangeManager interface {
	Exchange(ctx context.Context, exchangeables []tax.Exchangeable) common.HttpError

	// ExchangeGains applies exchange rates to INRGains items.
	// For each gain, it uses the SBI TT Buy Rate from the last day of the month
	// immediately preceding the month of that gain's SellDate.
	// If an exact rate for that date is not found, it relies on the underlying
	// SBI rate provider to furnish a rate for the closest available date.
	ExchangeGains(ctx context.Context, gains []tax.INRGains) common.HttpError
}

func NewExchangeManager

func NewExchangeManager(sbiManager SBIManager) ExchangeManager

type ExchangeManagerImpl

type ExchangeManagerImpl struct {
	// contains filtered or unexported fields
}

func (*ExchangeManagerImpl) Exchange

func (e *ExchangeManagerImpl) Exchange(ctx context.Context, exchangeables []tax.Exchangeable) common.HttpError

func (*ExchangeManagerImpl) ExchangeGains

func (e *ExchangeManagerImpl) ExchangeGains(ctx context.Context, gains []tax.INRGains) common.HttpError

type FinancialYearManager

type FinancialYearManager[T tax.CSVRecord] interface {
	FilterIndia(ctx context.Context, records []T, year int) ([]T, common.HttpError)
	FilterUS(ctx context.Context, records []T, year int) ([]T, common.HttpError)
}

func NewFinancialYearManager

func NewFinancialYearManager[T tax.CSVRecord]() FinancialYearManager[T]

type FinancialYearManagerImpl

type FinancialYearManagerImpl[T tax.CSVRecord] struct{}

func (*FinancialYearManagerImpl[T]) FilterIndia

func (f *FinancialYearManagerImpl[T]) FilterIndia(_ context.Context, records []T, year int) ([]T, common.HttpError)

func (*FinancialYearManagerImpl[T]) FilterUS

func (f *FinancialYearManagerImpl[T]) FilterUS(_ context.Context, records []T, year int) ([]T, common.HttpError)

type InterestManager

type InterestManager interface {
	// Retrieves all Interest records for the specified financial year.
	// The year parameter represents the starting year of the financial year (e.g., 2023 for FY 2023-24).
	GetInterestForYear(ctx context.Context, year int) ([]tax.Interest, common.HttpError)

	// Processes a list of Interest records, adding INR values based on exchange rates.
	ProcessInterest(ctx context.Context, interest []tax.Interest) ([]tax.INRInterest, common.HttpError)
}

Interface definition updated

type InterestManagerImpl

type InterestManagerImpl struct {
	// contains filtered or unexported fields
}

Implementation struct updated with new dependencies

func NewInterestManager

func NewInterestManager(
	exchangeManager ExchangeManager,
	financialYearManager FinancialYearManager[tax.Interest],
	interestRepository repository.InterestRepository,
) *InterestManagerImpl

Constructor updated to accept new dependencies

func (*InterestManagerImpl) GetInterestForYear

func (i *InterestManagerImpl) GetInterestForYear(ctx context.Context, year int) ([]tax.Interest, common.HttpError)

GetInterestForYear implementation added

func (*InterestManagerImpl) ProcessInterest

func (i *InterestManagerImpl) ProcessInterest(ctx context.Context, interests []tax.Interest) (inrInterests []tax.INRInterest, err common.HttpError)

ProcessInterest implementation (Ensure it uses injected exchangeManager)

type SBIManager

type SBIManager interface {
	DownloadRates(ctx context.Context) common.HttpError
	// TODO: Get Last TT Buy Rate for month.
	GetTTBuyRate(ctx context.Context, date time.Time) (float64, common.HttpError)
}

type SBIManagerImpl

type SBIManagerImpl struct {
	// contains filtered or unexported fields
}

func NewSBIManager

func NewSBIManager(client clients.SBIClient, filePath string, exchangeRepo repository.ExchangeRepository) *SBIManagerImpl

func (*SBIManagerImpl) DownloadRates

func (s *SBIManagerImpl) DownloadRates(ctx context.Context) (err common.HttpError)

func (*SBIManagerImpl) GetTTBuyRate

func (s *SBIManagerImpl) GetTTBuyRate(ctx context.Context, requestedDate time.Time) (rate float64, err common.HttpError)

type TaxManager

type TaxManager interface {
	GetTaxSummary(ctx context.Context, year int) (tax.Summary, common.HttpError)
	SaveTaxSummaryToExcel(ctx context.Context, summary tax.Summary) error
}

func NewTaxManager

func NewTaxManager(
	capitalGainManager CapitalGainManager,
	dividendManager DividendManager,
	interestManager InterestManager,
	taxValuationManager TaxValuationManager,
	excelManager ExcelManager,
) TaxManager

type TaxManagerImpl

type TaxManagerImpl struct {
	// contains filtered or unexported fields
}

func (*TaxManagerImpl) GetTaxSummary

func (t *TaxManagerImpl) GetTaxSummary(ctx context.Context, year int) (summary tax.Summary, err common.HttpError)

func (*TaxManagerImpl) SaveTaxSummaryToExcel

func (t *TaxManagerImpl) SaveTaxSummaryToExcel(ctx context.Context, summary tax.Summary) error

type TaxValuationManager

type TaxValuationManager interface {
	// Processes a list of Valuation records, adding INR values based on exchange rates.
	ProcessValuations(ctx context.Context, valuations []tax.Valuation) ([]tax.INRValuation, common.HttpError)

	// GetYearlyValuationsUSD calculates the base USD Valuation (First, Peak, YearEnd)
	// for all relevant tickers based on trade history up to the end of the specified calendar year.
	GetYearlyValuationsUSD(ctx context.Context, year int) ([]tax.Valuation, common.HttpError)
}

TaxValuationManager handles currency exchange rate processing

func NewTaxValuationManager

func NewTaxValuationManager(exchangeManager ExchangeManager, valuationManager ValuationManager) TaxValuationManager

NewTaxValuationManager creates a new instance of TaxValuationManager

type TaxValuationManagerImpl

type TaxValuationManagerImpl struct {
	// contains filtered or unexported fields
}

Implementation struct updated with ValuationManager

func (*TaxValuationManagerImpl) GetYearlyValuationsUSD

func (v *TaxValuationManagerImpl) GetYearlyValuationsUSD(ctx context.Context, year int) ([]tax.Valuation, common.HttpError)

GetYearlyValuationsUSD passes the call through to the underlying ValuationManager.

func (*TaxValuationManagerImpl) ProcessValuations

func (v *TaxValuationManagerImpl) ProcessValuations(ctx context.Context, valuations []tax.Valuation) (inrValuations []tax.INRValuation, err common.HttpError)

type TickerManager

type TickerManager interface {
	DownloadTicker(ctx context.Context, ticker string) (err common.HttpError)
	FindPeakPrice(ctx context.Context, ticker string, year int) (tax.PeakPrice, common.HttpError)
	GetPrice(ctx context.Context, ticker string, date time.Time) (float64, common.HttpError)
}

type TickerManagerImpl

type TickerManagerImpl struct {
	// contains filtered or unexported fields
}

func NewTickerManager

func NewTickerManager(client clients.AlphaClient, downloads string) *TickerManagerImpl

func (*TickerManagerImpl) DownloadTicker

func (t *TickerManagerImpl) DownloadTicker(ctx context.Context, ticker string) (err common.HttpError)

func (*TickerManagerImpl) FindPeakPrice

func (t *TickerManagerImpl) FindPeakPrice(_ context.Context, ticker string, year int) (peakPrice tax.PeakPrice, err common.HttpError)

func (*TickerManagerImpl) GetPrice

func (t *TickerManagerImpl) GetPrice(ctx context.Context, ticker string, date time.Time) (float64, common.HttpError)

type ValuationManager

type ValuationManager interface {
	AnalyzeValuation(ctx context.Context, tickerSymbol string, trades []tax.Trade, year int) (tax.Valuation, common.HttpError)
	// GetYearlyValuationsUSD calculates the base USD Valuation (First, Peak, YearEnd)
	// for all relevant tickers based on trade history up to the end of the specified calendar year.
	GetYearlyValuationsUSD(ctx context.Context, year int) ([]tax.Valuation, common.HttpError)
}

func NewValuationManager

func NewValuationManager(
	tickerManager TickerManager,
	accountManager AccountManager,
	tradeRepository repository.TradeRepository,
	fyManager FinancialYearManager[tax.Trade],
) ValuationManager

type ValuationManagerImpl

type ValuationManagerImpl struct {
	// contains filtered or unexported fields
}

func (*ValuationManagerImpl) AnalyzeValuation

func (v *ValuationManagerImpl) AnalyzeValuation(ctx context.Context, tickerSymbol string, trades []tax.Trade, year int) (tax.Valuation, common.HttpError)

AnalyzeValuation calculates valuation based on trades and opening position for a given ticker.

func (*ValuationManagerImpl) GetYearlyValuationsUSD

func (v *ValuationManagerImpl) GetYearlyValuationsUSD(ctx context.Context, year int) (valuations []tax.Valuation, err common.HttpError)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL