import { Augur } from "augur.js"; import BigNumber from "bignumber.js"; import * as t from "io-ts"; import * as Knex from "knex"; import { Dictionary, NumericDictionary } from "lodash"; import { FrozenFunds } from "../../blockchain/log-processors/profit-loss/frozen-funds"; import { Address } from "../../types"; export declare function getDefaultPLTimeseries(): ProfitLossTimeseries; export declare function getDefaultOVTimeseries(): OutcomeValueTimeseries; export interface Timestamped { timestamp: number; } export interface ProfitLossTimeseries extends Timestamped, FrozenFunds { account: Address; marketId: Address; outcome: number; transactionHash: string; price: BigNumber; position: BigNumber; quantityOpened: BigNumber; numOutcomes: number; profit: BigNumber; realizedCost: BigNumber; minPrice: BigNumber; maxPrice: BigNumber; } export interface OutcomeValueTimeseries extends Timestamped { marketId: Address; outcome: number; value: BigNumber; transactionHash: string; blockNumber: number; logIndex: number; } export interface ProfitLossResult extends Timestamped, // profit and loss as of this timestamp FrozenFunds { marketId: Address; outcome: number; netPosition: BigNumber; averagePrice: BigNumber; unrealizedCost: BigNumber; unrealizedRevenue: BigNumber; unrealized: BigNumber; unrealizedPercent: BigNumber; realizedCost: BigNumber; realized: BigNumber; realizedPercent: BigNumber; totalCost: BigNumber; total: BigNumber; totalPercent: BigNumber; lastTradePrice: BigNumber; lastTradePrice24hAgo: BigNumber; lastTradePrice24hChangePercent: BigNumber; unrealizedRevenue24hAgo: BigNumber; unrealizedRevenue24hChangePercent: BigNumber; } export interface ShortPosition { outcome: number; position: BigNumber; } export declare const GetProfitLossParams: t.IntersectionType<[t.InterfaceType<{ universe: t.StringType; account: t.StringType; startTime: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; endTime: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; periodInterval: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; }, t.TypeOfProps<{ universe: t.StringType; account: t.StringType; startTime: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; endTime: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; periodInterval: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; }>, t.OutputOfProps<{ universe: t.StringType; account: t.StringType; startTime: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; endTime: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; periodInterval: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; }>, t.mixed>, t.InterfaceType<{ marketId: t.UnionType<(t.NullType | t.StringType)[], string | null, string | null, t.mixed>; }, t.TypeOfProps<{ marketId: t.UnionType<(t.NullType | t.StringType)[], string | null, string | null, t.mixed>; }>, t.OutputOfProps<{ marketId: t.UnionType<(t.NullType | t.StringType)[], string | null, string | null, t.mixed>; }>, t.mixed>], t.TypeOfProps<{ universe: t.StringType; account: t.StringType; startTime: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; endTime: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; periodInterval: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; }> & t.TypeOfProps<{ marketId: t.UnionType<(t.NullType | t.StringType)[], string | null, string | null, t.mixed>; }>, t.OutputOfProps<{ universe: t.StringType; account: t.StringType; startTime: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; endTime: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; periodInterval: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; }> & t.OutputOfProps<{ marketId: t.UnionType<(t.NullType | t.StringType)[], string | null, string | null, t.mixed>; }>, t.mixed>; export declare type GetProfitLossParamsType = t.TypeOf; export declare const GetOutcomeProfitLossParams: t.IntersectionType<[t.InterfaceType<{ universe: t.StringType; account: t.StringType; startTime: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; endTime: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; periodInterval: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; }, t.TypeOfProps<{ universe: t.StringType; account: t.StringType; startTime: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; endTime: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; periodInterval: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; }>, t.OutputOfProps<{ universe: t.StringType; account: t.StringType; startTime: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; endTime: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; periodInterval: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; }>, t.mixed>, t.InterfaceType<{ marketId: t.StringType; outcome: t.NumberType; }, t.TypeOfProps<{ marketId: t.StringType; outcome: t.NumberType; }>, t.OutputOfProps<{ marketId: t.StringType; outcome: t.NumberType; }>, t.mixed>], t.TypeOfProps<{ universe: t.StringType; account: t.StringType; startTime: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; endTime: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; periodInterval: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; }> & t.TypeOfProps<{ marketId: t.StringType; outcome: t.NumberType; }>, t.OutputOfProps<{ universe: t.StringType; account: t.StringType; startTime: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; endTime: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; periodInterval: t.UnionType<(t.NullType | t.NumberType)[], number | null, number | null, t.mixed>; }> & t.OutputOfProps<{ marketId: t.StringType; outcome: t.NumberType; }>, t.mixed>; export declare type GetOutcomeProfitLossParamsType = t.TypeOf; export declare const GetProfitLossSummaryParams: t.IntersectionType<[t.InterfaceType<{ universe: t.StringType; account: t.StringType; marketId: t.UnionType<(t.NullType | t.StringType)[], string | null, string | null, t.mixed>; }, t.TypeOfProps<{ universe: t.StringType; account: t.StringType; marketId: t.UnionType<(t.NullType | t.StringType)[], string | null, string | null, t.mixed>; }>, t.OutputOfProps<{ universe: t.StringType; account: t.StringType; marketId: t.UnionType<(t.NullType | t.StringType)[], string | null, string | null, t.mixed>; }>, t.mixed>, t.PartialType<{ endTime: t.NumberType; }, t.TypeOfPartialProps<{ endTime: t.NumberType; }>, t.OutputOfPartialProps<{ endTime: t.NumberType; }>, t.mixed>], t.TypeOfProps<{ universe: t.StringType; account: t.StringType; marketId: t.UnionType<(t.NullType | t.StringType)[], string | null, string | null, t.mixed>; }> & t.TypeOfPartialProps<{ endTime: t.NumberType; }>, t.OutputOfProps<{ universe: t.StringType; account: t.StringType; marketId: t.UnionType<(t.NullType | t.StringType)[], string | null, string | null, t.mixed>; }> & t.OutputOfPartialProps<{ endTime: t.NumberType; }>, t.mixed>; export declare type GetProfitLossSummaryParamsType = t.TypeOf; export declare function bucketRangeByInterval(startTime: number, endTime: number, periodInterval: number | null): Array; export declare function sumProfitLossResults(left: T, right: T): T; export interface AllOutcomesProfitLoss { profit: Dictionary>>; buckets: Array; marketOutcomes: Dictionary; } export declare function getAllOutcomesProfitLoss(db: Knex, params: GetProfitLossParamsType): Promise; export declare function getProfitLoss(db: Knex, augur: Augur, params: GetProfitLossParamsType): Promise>; export declare function getProfitLossSummary(db: Knex, augur: Augur, params: GetProfitLossSummaryParamsType): Promise>;