Class TradeAccount

A trade account instance. The instance is connected to a specific equity token, and will only have access to LPs with that same underlying token.

Implements

  • ITradeAccount

Constructors

  • Parameters

    • id: number
    • realizedEquity: BigNumber
    • positions: Position[]
    • openOrders: {
          accountId: number;
          accountUser: string;
          createdTimestampUnixMillis: number;
          expiryTimestampUnixMillis: number;
          id: string;
          kind: {
              kind: "market";
          } | {
              args: {
                  limitPrice: BigNumber;
              };
              kind: "limit";
          } | {
              args: {
                  stopLoss?: null | {
                      kind: "position";
                  } | {
                      id: string;
                      kind: "order";
                  };
                  triggerPrice: BigNumber;
              };
              kind: "stopMarket";
          } | {
              args: {
                  limitPrice: BigNumber;
                  triggerPrice: BigNumber;
              };
              kind: "stopLimit";
          } | {
              args: {
                  takeProfit?: null | {
                      kind: "position";
                  } | {
                      id: string;
                      kind: "order";
                  };
                  triggerPrice: BigNumber;
              };
              kind: "limitTrigger";
          } | {
              kind: string;
          };
          lpId: string;
          nonce: string;
          pair: Pair;
          signature: string;
          size: {
              amount: BigNumber;
              unit: "lpc" | "lot";
          };
          status: {
              content: {
                  status: "placed";
              } | {
                  content: {
                      timestampUnixMillis: number;
                      triggerPrice: BigNumber;
                  };
                  status: "triggered";
              };
              status: "open";
          } | {
              content: {
                  price: BigNumber;
                  settlementStatus: {
                      status: "queued";
                  } | {
                      status: "beforeTx";
                  } | {
                      status: "indexing";
                  } | {
                      content: {
                          txHash: string;
                      };
                      status: "settled";
                  };
                  timestampUnixMillis: number;
              };
              status: "filled";
          } | {
              content: {
                  reason: string;
                  timestampUnixMillis: number;
                  userCancellation?: null | {
                      address: string;
                      nonce: string;
                      signature: {
                          r: string;
                          s: string;
                          v: number;
                      };
                  };
              };
              status: "cancelled";
          };
      }[]
    • protocol: TradeProtocol
    • adapter: TradeAdapter
    • reader: TradeReader
    • equityTokenAddress: string

    Returns TradeAccount

Properties

adapter: TradeAdapter
equityTokenAddress: string
id: number
isProcessingSubscriptionRequest: boolean = false
onUpdate?: (() => void)

Type declaration

    • (): void
    • Returns void

openOrders: {
    accountId: number;
    accountUser: string;
    createdTimestampUnixMillis: number;
    expiryTimestampUnixMillis: number;
    id: string;
    kind: {
        kind: "market";
    } | {
        args: {
            limitPrice: BigNumber;
        };
        kind: "limit";
    } | {
        args: {
            stopLoss?: null | {
                kind: "position";
            } | {
                id: string;
                kind: "order";
            };
            triggerPrice: BigNumber;
        };
        kind: "stopMarket";
    } | {
        args: {
            limitPrice: BigNumber;
            triggerPrice: BigNumber;
        };
        kind: "stopLimit";
    } | {
        args: {
            takeProfit?: null | {
                kind: "position";
            } | {
                id: string;
                kind: "order";
            };
            triggerPrice: BigNumber;
        };
        kind: "limitTrigger";
    } | {
        kind: string;
    };
    lpId: string;
    nonce: string;
    pair: Pair;
    signature: string;
    size: {
        amount: BigNumber;
        unit: "lpc" | "lot";
    };
    status: {
        content: {
            status: "placed";
        } | {
            content: {
                timestampUnixMillis: number;
                triggerPrice: BigNumber;
            };
            status: "triggered";
        };
        status: "open";
    } | {
        content: {
            price: BigNumber;
            settlementStatus: {
                status: "queued";
            } | {
                status: "beforeTx";
            } | {
                status: "indexing";
            } | {
                content: {
                    txHash: string;
                };
                status: "settled";
            };
            timestampUnixMillis: number;
        };
        status: "filled";
    } | {
        content: {
            reason: string;
            timestampUnixMillis: number;
            userCancellation?: null | {
                address: string;
                nonce: string;
                signature: {
                    r: string;
                    s: string;
                    v: number;
                };
            };
        };
        status: "cancelled";
    };
}[]

Type declaration

  • accountId: number
  • accountUser: string
  • createdTimestampUnixMillis: number
  • expiryTimestampUnixMillis: number
  • id: string
  • kind: {
        kind: "market";
    } | {
        args: {
            limitPrice: BigNumber;
        };
        kind: "limit";
    } | {
        args: {
            stopLoss?: null | {
                kind: "position";
            } | {
                id: string;
                kind: "order";
            };
            triggerPrice: BigNumber;
        };
        kind: "stopMarket";
    } | {
        args: {
            limitPrice: BigNumber;
            triggerPrice: BigNumber;
        };
        kind: "stopLimit";
    } | {
        args: {
            takeProfit?: null | {
                kind: "position";
            } | {
                id: string;
                kind: "order";
            };
            triggerPrice: BigNumber;
        };
        kind: "limitTrigger";
    } | {
        kind: string;
    }
  • lpId: string
  • nonce: string
  • pair: Pair
  • signature: string
  • size: {
        amount: BigNumber;
        unit: "lpc" | "lot";
    }
    • amount: BigNumber
    • unit: "lpc" | "lot"
  • status: {
        content: {
            status: "placed";
        } | {
            content: {
                timestampUnixMillis: number;
                triggerPrice: BigNumber;
            };
            status: "triggered";
        };
        status: "open";
    } | {
        content: {
            price: BigNumber;
            settlementStatus: {
                status: "queued";
            } | {
                status: "beforeTx";
            } | {
                status: "indexing";
            } | {
                content: {
                    txHash: string;
                };
                status: "settled";
            };
            timestampUnixMillis: number;
        };
        status: "filled";
    } | {
        content: {
            reason: string;
            timestampUnixMillis: number;
            userCancellation?: null | {
                address: string;
                nonce: string;
                signature: {
                    r: string;
                    s: string;
                    v: number;
                };
            };
        };
        status: "cancelled";
    }
orderPublicationListener: undefined | OrderPublicationListener
positions: Position[]
protocol: TradeProtocol
reader: TradeReader
realizedEquity: BigNumber
subsriptionId: null | string = null

Methods

  • Returns the available equity for the account.

    Returns BigNumber

  • Returns BigNumber

    The total value of all positions in the liquidity token currency (currently USD).

  • Returns {
        accountId: number;
        accountUser: string;
        createdTimestampUnixMillis: number;
        expiryTimestampUnixMillis: number;
        id: string;
        kind: {
            kind: "market";
        } | {
            args: {
                limitPrice: BigNumber;
            };
            kind: "limit";
        } | {
            args: {
                stopLoss?: null | {
                    kind: "position";
                } | {
                    id: string;
                    kind: "order";
                };
                triggerPrice: BigNumber;
            };
            kind: "stopMarket";
        } | {
            args: {
                limitPrice: BigNumber;
                triggerPrice: BigNumber;
            };
            kind: "stopLimit";
        } | {
            args: {
                takeProfit?: null | {
                    kind: "position";
                } | {
                    id: string;
                    kind: "order";
                };
                triggerPrice: BigNumber;
            };
            kind: "limitTrigger";
        } | {
            kind: string;
        };
        lpId: string;
        nonce: string;
        pair: Pair;
        signature: string;
        size: {
            amount: BigNumber;
            unit: "lpc" | "lot";
        };
        status: {
            content: {
                status: "placed";
            } | {
                content: {
                    timestampUnixMillis: number;
                    triggerPrice: BigNumber;
                };
                status: "triggered";
            };
            status: "open";
        } | {
            content: {
                price: BigNumber;
                settlementStatus: {
                    status: "queued";
                } | {
                    status: "beforeTx";
                } | {
                    status: "indexing";
                } | {
                    content: {
                        txHash: string;
                    };
                    status: "settled";
                };
                timestampUnixMillis: number;
            };
            status: "filled";
        } | {
            content: {
                reason: string;
                timestampUnixMillis: number;
                userCancellation?: null | {
                    address: string;
                    nonce: string;
                    signature: {
                        r: string;
                        s: string;
                        v: number;
                    };
                };
            };
            status: "cancelled";
        };
    }[]

  • Parameters

    Returns Promise<{
        accountId: number;
        accountUser: string;
        createdTimestampUnixMillis: number;
        expiryTimestampUnixMillis: number;
        id: string;
        kind: {
            kind: "market";
        } | {
            args: {
                limitPrice: BigNumber;
            };
            kind: "limit";
        } | {
            args: {
                stopLoss?: null | {
                    kind: "position";
                } | {
                    id: string;
                    kind: "order";
                };
                triggerPrice: BigNumber;
            };
            kind: "stopMarket";
        } | {
            args: {
                limitPrice: BigNumber;
                triggerPrice: BigNumber;
            };
            kind: "stopLimit";
        } | {
            args: {
                takeProfit?: null | {
                    kind: "position";
                } | {
                    id: string;
                    kind: "order";
                };
                triggerPrice: BigNumber;
            };
            kind: "limitTrigger";
        } | {
            kind: string;
        };
        lpId: string;
        nonce: string;
        pair: Pair;
        signature: string;
        size: {
            amount: BigNumber;
            unit: "lpc" | "lot";
        };
        status: {
            content: {
                status: "placed";
            } | {
                content: {
                    timestampUnixMillis: number;
                    triggerPrice: BigNumber;
                };
                status: "triggered";
            };
            status: "open";
        } | {
            content: {
                price: BigNumber;
                settlementStatus: {
                    status: "queued";
                } | {
                    status: "beforeTx";
                } | {
                    status: "indexing";
                } | {
                    content: {
                        txHash: string;
                    };
                    status: "settled";
                };
                timestampUnixMillis: number;
            };
            status: "filled";
        } | {
            content: {
                reason: string;
                timestampUnixMillis: number;
                userCancellation?: null | {
                    address: string;
                    nonce: string;
                    signature: {
                        r: string;
                        s: string;
                        v: number;
                    };
                };
            };
            status: "cancelled";
        };
    }[]>

  • Returns the unrealised equity for the account.

    Returns BigNumber

  • Parameters

    Returns Promise<{
        accountId: number;
        accountUser: string;
        createdTimestampUnixMillis: number;
        expiryTimestampUnixMillis: number;
        id: string;
        kind: {
            kind: "market";
        } | {
            args: {
                limitPrice: BigNumber;
            };
            kind: "limit";
        } | {
            args: {
                stopLoss?: null | {
                    kind: "position";
                } | {
                    id: string;
                    kind: "order";
                };
                triggerPrice: BigNumber;
            };
            kind: "stopMarket";
        } | {
            args: {
                limitPrice: BigNumber;
                triggerPrice: BigNumber;
            };
            kind: "stopLimit";
        } | {
            args: {
                takeProfit?: null | {
                    kind: "position";
                } | {
                    id: string;
                    kind: "order";
                };
                triggerPrice: BigNumber;
            };
            kind: "limitTrigger";
        } | {
            kind: string;
        };
        lpId: string;
        nonce: string;
        pair: Pair;
        signature: string;
        size: {
            amount: BigNumber;
            unit: "lpc" | "lot";
        };
        status: {
            content: {
                status: "placed";
            } | {
                content: {
                    timestampUnixMillis: number;
                    triggerPrice: BigNumber;
                };
                status: "triggered";
            };
            status: "open";
        } | {
            content: {
                price: BigNumber;
                settlementStatus: {
                    status: "queued";
                } | {
                    status: "beforeTx";
                } | {
                    status: "indexing";
                } | {
                    content: {
                        txHash: string;
                    };
                    status: "settled";
                };
                timestampUnixMillis: number;
            };
            status: "filled";
        } | {
            content: {
                reason: string;
                timestampUnixMillis: number;
                userCancellation?: null | {
                    address: string;
                    nonce: string;
                    signature: {
                        r: string;
                        s: string;
                        v: number;
                    };
                };
            };
            status: "cancelled";
        };
    }>

  • Parameters

    Returns Promise<{
        accountId: number;
        accountUser: string;
        createdTimestampUnixMillis: number;
        expiryTimestampUnixMillis: number;
        id: string;
        kind: {
            kind: "market";
        } | {
            args: {
                limitPrice: BigNumber;
            };
            kind: "limit";
        } | {
            args: {
                stopLoss?: null | {
                    kind: "position";
                } | {
                    id: string;
                    kind: "order";
                };
                triggerPrice: BigNumber;
            };
            kind: "stopMarket";
        } | {
            args: {
                limitPrice: BigNumber;
                triggerPrice: BigNumber;
            };
            kind: "stopLimit";
        } | {
            args: {
                takeProfit?: null | {
                    kind: "position";
                } | {
                    id: string;
                    kind: "order";
                };
                triggerPrice: BigNumber;
            };
            kind: "limitTrigger";
        } | {
            kind: string;
        };
        lpId: string;
        nonce: string;
        pair: Pair;
        signature: string;
        size: {
            amount: BigNumber;
            unit: "lpc" | "lot";
        };
        status: {
            content: {
                status: "placed";
            } | {
                content: {
                    timestampUnixMillis: number;
                    triggerPrice: BigNumber;
                };
                status: "triggered";
            };
            status: "open";
        } | {
            content: {
                price: BigNumber;
                settlementStatus: {
                    status: "queued";
                } | {
                    status: "beforeTx";
                } | {
                    status: "indexing";
                } | {
                    content: {
                        txHash: string;
                    };
                    status: "settled";
                };
                timestampUnixMillis: number;
            };
            status: "filled";
        } | {
            content: {
                reason: string;
                timestampUnixMillis: number;
                userCancellation?: null | {
                    address: string;
                    nonce: string;
                    signature: {
                        r: string;
                        s: string;
                        v: number;
                    };
                };
            };
            status: "cancelled";
        };
    }[]>