import { CoinSymbol, Milliseconds } from '../..'; import { Order, PriceFloat, QueuedOrder } from '../market'; /** * Represents how much fiat currency worth each coin should have * during the rebalance, as well as the price to buy/sell for during * the rebalance. Used internally only, not stored. */ export interface PortfolioRebalanceAllocation { pricePerCoin: PriceFloat; cashAmount: number; } export declare type PortfolioRebalanceAllocations = Partial<{ [coin in CoinSymbol]: PortfolioRebalanceAllocation; }>; export interface RebalanceOrders { /** Queued orders that have not yet been placed. */ queued: QueuedOrder[]; /** Orders that have already been placed. */ open: Order[]; } export interface PortfolioRebalanceStatus { /** Is the portfolio currently rebalancing? */ isRebalancing: boolean; /** * Sell orders to perform the rebalance. The rebalancing algorithm * will execute all queued sell orders first. Then, it will wait until * all open sell orders are filled. If a sell order is not filled by * the rebalanceTimeoutAt, the rebalance will fail. */ sellOrders: RebalanceOrders; /** * Buy orders to perform the rebalance. The rebalancing algorithm * will wait until all open sell orders are filled and completed before * executing the queued buy orders. Then, it will wait until all open * buy orders are filled. Once all buy orders are filled, the rebalance * is complete. If a buy order is not filled by the rebalanceTimeoutAt, * the rebalance will fail. */ buyOrders: RebalanceOrders; /** The timestamp for when the rebalance started. */ rebalanceStartedAt?: Milliseconds; /** The timestamp for when the rebalance times out. */ rebalanceTimeoutAt?: Milliseconds; /** If false, the user is alerted of the unsuccessful rebalance. */ success: boolean; }