import { IPricingProvider } from './pricing-provider.i'
import { ITradeIdeaImage } from './trade-idea-image.i'
import { ITradeIdeaIdeaKind } from './trade-idea-kind.i'
import { IValidPrice } from './valid-price.i'

export interface ITradeIdeaIdeaAdjustment {
	kind: 'increase' | 'decrease'
	percentage: number
}

export interface ITradeIdeaResult {
	isRebalance: false
	summary: ITradeIdeaResultProfit
	calculation: ITradeIdeaResultCalculationStep[]
}

export interface ITradeIdeaResultCalculationStep {
	note: string
	action: 'buy' | 'sell'
	qty: number
	price: number
	trade: number
	positionQty: number
	positionDirection: 'long' | 'short' | 'closed'
	positionValue: number
}

export interface ITradeIdeaResultProfit {
	profit: boolean
	capital: number
	percentage: number
	price: {
		percentage: number
		direction: 'up' | 'down'
		success: boolean
	}
}

export interface ITradeIdeaIdeaAlternativeProviderSymbol {
	provider: string
	symbol: string
}

export interface ITradeIdeaIdea {
	title: string
	kind: ITradeIdeaIdeaKind
	adjustment?: ITradeIdeaIdeaAdjustment
	asset: {
		ticker: string
		description: string
		image?: ITradeIdeaImage
		alternativeProviderSymbols?: ITradeIdeaIdeaAlternativeProviderSymbol[]
	}
	trade?: {
		conviction?: number // This is necessary in case of strategy.ordersType === 'STANDARD'
		allocation?: number // This is necessary in case of strategy.ordersType === 'ALLOCATION'
		direction: 'long' | 'short'
	}
	notes: {
		commentary: string
	}
	priceInfo?: IValidPrice
	chainIdeas?: IChainIdea[]
	result?: ITradeIdeaResult
}

export interface IChainIdea {
	nftId: number
	reference: string
	clientTokenId?: number
	ideaStageKey?: number
	ideaKey?: number
	url: string
	idea: ITradeIdeaIdea
	ideaSha512Hash: string
}
