Get Account Information
get_managed_accounts Get Managed Accounts
TradeClient.get_managed_accounts(account=None)
Description
Fetch a list of managed accounts of the current user, along with account information.
Arguments
Arguments | Type | Description |
---|---|---|
account | utility::string_t | Account id. Optional,Default value is to return all managed accounts |
Response
list
, each element is a AccountProfile
(tigeropen.trade.domain.profile.AccountProfile)object
Attributes:
Attribute | Type | Description |
---|---|---|
account | utility::string_t | Account |
capability | utility::string_t | Account Types (CASH: cash account, RegTMargin: Reg T Margin Account, PMGRN: Portfolio Margin) |
status | utility::string_t | Account Status(New, Funded, Open, Pending, Abandoned, Rejected, Closed, Unknown) |
accountType | utility::string_t | Account Type, including: GLOBAL,STANDARD,PAPER |
Example
Response Example
get_assets Get Account Summary
value get_asset(string account = "", const value &sub_accounts = value::array(), bool segment = false,
bool market_value = false);
Description
Get account summary,this method is only recommended for Global Account. You can also get the account summary of your standard, or paper trading account using this method. However, because different account types have different account structures, Please use get_prime_assets to get assets for prime and paper acount.
Arguments
Arguments | Typse | Required | Description |
---|---|---|---|
account | utility::string_t | Account id | |
sub_accounts | list<str...> | A list of sub-accounts, default value is None | |
segment | bool | Whether to return data grouped by segments (securities, futures). Default value is False. When set to True, a dict will be returned, where 'C' means futures, 'S' means stocks | |
market_value | bool | Whether to return data grouped by currency (USD, HKD, RMB). Default is False | |
secret_key | utility::string_t | Institutional trader key. Only applicable to institutional users. Configured in client_config |
Response
list
Each element of this list is a PortfolioAccount Object。If the user only has one account,there will be only one element in the list returned.
PortfolioAccount(tigeropen.trade.domain.account.PortfolioAccount) has the following structure。
Please refer to Object for data fields in Account、SecuritySegment、CommoditySegment
PortfolioAccount Object
├── account: account id
├── summary: Summary statistics of the current account. The value inside is an Account object
├── segments: account information grouped by segments. A dictionary
│ ├── 'S' stands for securities account, value is SecuritySegment object
│ └── 'C' stands for futures account, value is CommoditySegment object
├── market_value: Account statistics by currency, a dict
│ ├── 'USD' stands for US dollar, value is a MarketValue object
│ ├── 'HKD' stands for Hong Kong dollar, value is a MarketValue object
└─ └── 'CNH' stands for RMB, value is a MarketValue object
Example
#include "tigerapi/trade_client.h"
#include "tigerapi/contract_util.h"
#include "tigerapi/order_util.h"
using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;
/**
* Calling TradeClient
*/
class TestTradeClient {
public:
static void test_get_asset(const std::shared_ptr<TradeClient>& trade_client) {
value res = trade_client->get_asset();
cout << "asset: " << res << endl;
}
static void test_trade(const std::shared_ptr<TradeClient>& trade_client) {
TestTradeClient::test_get_asset(trade_client);
}
};
int main(int argc, char *args[]) {
cout << "Tiger Api main" << endl;
/************************** set config **********************/
ClientConfig config = ClientConfig(true);
config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
"xxxxxx private key xxxxxxxx"
"-----END RSA PRIVATE KEY-----";
config.tiger_id = "Tiger ID";
config.account = "Account ID";
/**
* Use TradeClient
*/
std::shared_ptr<TradeClient> trade_client = std::make_shared<TradeClient>(config);
TestTradeClient::test_trade(trade_client);
return 0;
}
** Response Example **
{
"accountId": "402901",
"segments": [
{
"buyingPower": 397095.39000000001,
"capability": "RegTMargin",
"cashAvailableForTrade": 99273.850000000006,
"cashAvailableForWithdrawal": 99273.850000000006,
"cashBalance": 120286.77,
"category": "S",
"currency": "USD",
"currencyAssets": [
{
"cashAvailableForTrade": 108322.47,
"cashBalance": 108930.53999999999,
"currency": "USD",
"grossPositionValue": -1036.23,
"optionMarketValue": 0,
"realizedPL": 0,
"stockMarketValue": -1036.23,
"unrealizedPL": 2146.5599999999999
},
{
"cashAvailableForTrade": 19065.91,
"cashBalance": 88674.960000000006,
"currency": "HKD",
"grossPositionValue": 90026.5,
"optionMarketValue": 0,
"realizedPL": 0,
"stockMarketValue": 90026.5,
"unrealizedPL": -47976.830000000002
},
{
"cashAvailableForTrade": 0,
"cashBalance": 0,
"currency": "CNH"
},
{
"cashAvailableForTrade": 0,
"cashBalance": 0,
"currency": "SGD"
}
],
"equityWithLoan": 130779.86,
"excessLiquidation": 99238.059999999998,
"grossPositionValue": 10493.09,
"initMargin": 28891.459999999999,
"leverage": 0.65000000000000002,
"lockedFunds": 2614.5500000000002,
"maintainMargin": 31541.799999999999,
"netLiquidation": 132130.32000000001,
"overnightLiquidation": 95774.460000000006,
"overnightMargin": 35005.389999999999,
"realizedPL": 0,
"totalTodayPL": -327.79000000000002,
"unrealizedPL": -3997.6300000000001,
"unrealizedPLByCostOfCarry": 22008.740000000002
},
{
"buyingPower": 0,
"capability": "RegTMargin",
"cashAvailableForTrade": 1098805.6799999999,
"cashAvailableForWithdrawal": 1098805.6799999999,
"cashBalance": 1100567.8899999999,
"category": "C",
"currency": "USD",
"currencyAssets": [
{
"cashAvailableForTrade": 1100567.8899999999,
"cashBalance": 1100567.8899999999,
"currency": "USD",
"futuresMarketValue": 1012929,
"grossPositionValue": 1012929,
"realizedPL": 0,
"unrealizedPL": 933321.01000000001
},
{
"cashAvailableForTrade": 0,
"cashBalance": 0,
"currency": "HKD"
},
{
"cashAvailableForTrade": 0,
"cashBalance": 0,
"currency": "CNH"
}
],
"equityWithLoan": 1098985.6799999999,
"excessLiquidation": 1098985.6799999999,
"grossPositionValue": 1012929,
"initMargin": 1980.0699999999999,
"leverage": 0,
"lockedFunds": 0,
"maintainMargin": 1800.0699999999999,
"netLiquidation": 1100785.75,
"overnightLiquidation": 1098985.6799999999,
"overnightMargin": 1800.0699999999999,
"realizedPL": 0,
"totalTodayPL": 0,
"unrealizedPL": 933321.01000000001,
"unrealizedPLByCostOfCarry": 1000598.6
}
],
"updateTimestamp": 1673343992573
}
get_prime_assets Account Summary for Prime Account
value get_prime_asset(const string& account = "", const string& base_currency = "USD");
Description
Get account summary, including asset information and open positions, for your Prime and Paper accounts
Arguments
Argument | Type | Description |
---|---|---|
account | str | account id, if not specified, the request will use default account id configured in client_config |
Example
Response
list
A list where each element is a PortfolioAccount object. If there is only one account, the method will return a one-element list.
The structure of the PortfolioAccount object is as follows.
For a detailed list of data fields contained in PortfolioAccount and Segment, please refer to Object Information
PortfolioAccount object
├── account: account id
├── update_timestamp: update time, timestamp in milliseconds
├── segments: account information by segments, a dict with the security category as the key, and the value as a Segment object
│ ├── 'S' means securities account, value is Segment object
│ │ ├── currency: currency, such as USD, HKD
│ │ ├── capability: Account Type, Margin: RegTMargin, Cash: Cash
│ │ ├── category': Securities Classification C: (Commodities Futures), S: (Securities Stocks)
│ │ ├── cash_balance': cash that can be traded, plus some cash that has been locked (such as stocks that have been purchased but not yet traded, and some other situations will also have locked cash)
│ │ ├── cash_available_for_trade': The amount of cash and margin that can be traded in the current account
│ │ ├── cash_available_for_withdrawal': The amount of cash that can be withdrawn in the current account
│ │ ├── gross_position_value': total security value: long stock value + short stock value + long option value + short option value. The above items are calculated as absolute values
│ │ ├── equity_with_loan': Equity with loan value (including loan value assets). Securities Segment: Cash value + stock value, Futures Segment: Cash value - maintenance margin
│ │ ├── net_liquidation': net liquidation value
│ │ ├── init_margin': initial margin requirement
│ │ ├── maintain_margin': maintenance margin requirement
│ │ ├── overnight_margin': overnight margin requirement
│ │ ├── unrealized_pl': floating profit and loss
│ │ ├── realized_pl': realized profit and loss
│ │ ├── excess_liquidation': Excess liquidity, used to represent intraday risk value. Calculation method for securities segment: equity_with_loan - maintenance_margin_requirement. Calculation method for futures segment: net_liquidation - maintenance_margin_requirement
│ │ ├── overnight_liquidation': Overnight risk control value, when it is less than 0, account positions will be forced to liquidate, and you need to pay attention to risks
│ │ ├── buying_power': buying power. Estimate how many dollars you can buy in stock assets. The margin account has a maximum of four times the purchasing power of the funds (funds that are not occupited) during the day. Overnight purchasing power Up to two times.
│ │ ├── leverage': The currently leverage, if it is less than 1, it means that the leverage is not used, and if it is greater than 1, it means the leverage multiple used
│ │ ├── currency_assets: Account asset information differentiated by transaction currency, a dict with currency as key
│ │ │ ├── 'USD' means US dollar, value is CurrencyAsset object
│ │ │ │ ├── currency': current currency, commonly used currencies include: USD-US dollar, HKD-Hong Kong dollar, SGD-Singapore dollar, CNH-RMB
│ │ │ │ ├── cash_balance': cash that can be traded, plus some cash that has been locked (such as stocks that have been purchased but not yet traded, and some other situations will also have locked cash)
│ │ │ │ ├── cash_available_for_trade': The amount of cash that can be traded in the current account
│ │ │ │ ├── gross_position_value': gross value
│ │ │ │ ├── stock_market_value': The market value of the stock, when the category is C (futures type), there will be no stock market value
│ │ │ │ ├── futures_market_value': the market value of futures, when the category is S (stock type), there will be no futures market value
│ │ │ │ ├── option_market_value': the market value of the option
│ │ │ │ ├── unrealized_pl': floating profit and loss within the account
│ │ │ │ ├── realized_pl': realized profit and loss in the account
│ │ │ ├── 'HKD' means Hong Kong dollar, value is CurrencyAsset object
│ │ └─ └── 'CNH' means RMB, value is CurrencyAsset object
│ └── 'C' means futures account, value is Segment object
Example
#include "tigerapi/trade_client.h"
#include "tigerapi/contract_util.h"
#include "tigerapi/order_util.h"
using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;
/**
* Calling TradeClient
*/
class TestTradeClient {
public:
static void test_get_prime_asset(const std::shared_ptr<TradeClient>& trade_client) {
value res = trade_client->get_prime_asset();
cout << "asset: " << res << endl;
}
static void test_trade(const std::shared_ptr<TradeClient>& trade_client) {
TestTradeClient::test_get_prime_asset(trade_client);
}
};
int main(int argc, char *args[]) {
cout << "Tiger Api main" << endl;
/************************** set config **********************/
ClientConfig config = ClientConfig(true);
config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
"xxxxxx private key xxxxxxxx"
"-----END RSA PRIVATE KEY-----";
config.tiger_id = "Tiger ID";
config.account = "Account ID";
/**
* Use TradeClient
*/
std::shared_ptr<TradeClient> trade_client = std::make_shared<TradeClient>(config);
TestTradeClient::test_trade(trade_client);
return 0;
}
Response
{
"accountId": "402901",
"segments": [
{
"buyingPower": 396935.09999999998,
"capability": "RegTMargin",
"cashAvailableForTrade": 99233.770000000004,
"cashAvailableForWithdrawal": 99233.770000000004,
"cashBalance": 120286.21000000001,
"category": "S",
"currency": "USD",
"currencyAssets": [
{
"cashAvailableForTrade": 108322.42999999999,
"cashBalance": 108930.53999999999,
"currency": "USD",
"grossPositionValue": -1095.0699999999999,
"optionMarketValue": 0,
"realizedPL": 0,
"stockMarketValue": -1095.0699999999999,
"unrealizedPL": 2087.7199999999998
},
{
"cashAvailableForTrade": 19065.91,
"cashBalance": 88674.960000000006,
"currency": "HKD",
"grossPositionValue": 90026.5,
"optionMarketValue": 0,
"realizedPL": 0,
"stockMarketValue": 90026.5,
"unrealizedPL": -47976.830000000002
},
{
"cashAvailableForTrade": 0,
"cashBalance": 0,
"currency": "CNH"
},
{
"cashAvailableForTrade": 0,
"cashBalance": 0,
"currency": "SGD"
}
],
"equityWithLoan": 130719.88,
"excessLiquidation": 99203.070000000007,
"grossPositionValue": 10433.68,
"initMargin": 28871.639999999999,
"leverage": 0.65000000000000002,
"lockedFunds": 2614.4699999999998,
"maintainMargin": 31516.82,
"netLiquidation": 132070.35000000001,
"overnightLiquidation": 95744.270000000004,
"overnightMargin": 34975.610000000001,
"realizedPL": 0,
"totalTodayPL": -386.61000000000001,
"unrealizedPL": -4056.1599999999999,
"unrealizedPLByCostOfCarry": 21949.290000000001
},
{
"buyingPower": 0,
"capability": "RegTMargin",
"cashAvailableForTrade": 1098805.6799999999,
"cashAvailableForWithdrawal": 1098805.6799999999,
"cashBalance": 1100567.8899999999,
"category": "C",
"currency": "USD",
"currencyAssets": [
{
"cashAvailableForTrade": 1100567.8899999999,
"cashBalance": 1100567.8899999999,
"currency": "USD",
"futuresMarketValue": 1012929,
"grossPositionValue": 1012929,
"realizedPL": 0,
"unrealizedPL": 933321.01000000001
},
{
"cashAvailableForTrade": 0,
"cashBalance": 0,
"currency": "HKD"
},
{
"cashAvailableForTrade": 0,
"cashBalance": 0,
"currency": "CNH"
}
],
"equityWithLoan": 1098985.6799999999,
"excessLiquidation": 1098985.6799999999,
"grossPositionValue": 1012929,
"initMargin": 1980.0699999999999,
"leverage": 0,
"lockedFunds": 0,
"maintainMargin": 1800.0699999999999,
"netLiquidation": 1100785.75,
"overnightLiquidation": 1098985.6799999999,
"overnightMargin": 1800.0699999999999,
"realizedPL": 0,
"totalTodayPL": 0,
"unrealizedPL": 933321.01000000001,
"unrealizedPLByCostOfCarry": 1000598.6
}
],
"updateTimestamp": 1673352596442
}
get_positions Get Positions
value get_positions(string account = "", SecType sec_type = SecType::ALL, Currency currency = Currency::ALL,
Market market = Market::ALL,
string symbol = "", const value &sub_accounts = value::array(), long expiry = -1,
double strike = 0, Right right = Right::ALL);
value get_positions(const string &account, const string &sec_type = "", const string ¤cy = "ALL",
const string &market = "ALL",
const string &symbol = "", const value &sub_accounts = value::array(), long expiry = -1,
double strike = 0, const string &right = "");
vector<Position> get_position_list(string account = "", string sec_type = "", string currency = "ALL",
string market = "ALL",
string symbol = "", const value &sub_accounts = value::array(), long expiry = -1,
double strike = 0, string right = "");
Description
Get the position information of the account
Arguments
Argument | Type | Required | Description |
---|---|---|---|
account | str | no | account id, if not specified, default account id configured in client_config will be used |
sec_type | SecurityType | no | SecurityType enumeration, including STK/OPT/FUT, etc., default value is STK. This parameter can be imported from tigeropen.common.consts |
currency | Currency | no | Currency enumeration, including ALL/USD/HKD/CNH, etc., default ALL, can be imported from tigeropen.common.consts |
market | Market | no | Market enumeration, including ALL/US/HK/CN, etc., default ALL, can be imported from tigeropen.common.consts |
symbol | str | no | Ticker symbol |
expiry | str | no | Options expiration date, format: 'yyyyMMdd', example: '220121' |
strike | float | no | Options strike price, example: 100.5 |
put_call | str | no | 'PUT' / 'CALL' for options |
sub_account | list[str] | no | Sub account list |
secret_key | str | no | Institutional trader key. Only applicable to institutional users. It needs to be configured in client_config. Ignore if you are a individual developer |
Response
list
The structure is as follows:
Each element is a Position object. The Position(tigeropen.trade.domain.position.Position) object has the following properties:
Argument | Type | Description |
---|---|---|
account | utility::string_t | Account id |
contract | Contract | Contract object, tigeropen.trade.domain.contract.Contract |
quantity | int | Position quantity |
average_cost | float | Holding cost |
market_price | float | Latest price |
market_value | float | Market value |
realized_pnl | float | Realized profit and loss |
unrealized_pnl | float | Unrealized profit and loss |
Example
#include "tigerapi/trade_client.h"
#include "tigerapi/contract_util.h"
#include "tigerapi/order_util.h"
using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;
/**
* Calling TradeClient
*/
class TestTradeClient {
public:
static void test_get_positions(const std::shared_ptr<TradeClient>& trade_client) {
value res = trade_client->get_positions();
cout << "position: " << res << endl;
}
static void test_trade(const std::shared_ptr<TradeClient>& trade_client) {
TestTradeClient::test_get_positions(trade_client);
}
};
int main(int argc, char *args[]) {
cout << "Tiger Api main" << endl;
/************************** set config **********************/
ClientConfig config = ClientConfig(true);
config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
"xxxxxx private key xxxxxxxx"
"-----END RSA PRIVATE KEY-----";
config.tiger_id = "Tiger ID";
config.account = "Account ID";
/**
* Use TradeClient
*/
std::shared_ptr<TradeClient> trade_client = std::make_shared<TradeClient>(config);
TestTradeClient::test_trade(trade_client);
return 0;
}
Response
[contract: BABA/STK/USD, quantity: 1, average_cost: 178.99, market_price: 176.77,
contract: BIDU/STK/USD, quantity: 3, average_cost: 265.4633, market_price: 153.45,
contract: SPY/STK/USD, quantity: 7, average_cost: 284.9243, market_price: 284.97]
get_analytics_asset Get Analytics Asset
TradeClient.get_analytics_asset(account=None, start_date=None, end_date=None, seg_type=None, sub_account=None)
Description
Get historical asset analysis of the account
Arguments
Argument | Type | Required | Description |
---|---|---|---|
account | utility::string_t | no | Account id,if not specified, use client_config's default account |
start_date | utility::string_t | no | start date, format yyyy-MM-dd, like '2022-01-01' |
end_date | utility::string_t | no | end date, format yyyy-MM-dd, like '2022-02-01', if not passed, use current date |
seg_type | SegmentType | no | Account segment. Available: SegmentType.SEC for Securities; SegmentType.FUT for Commodities, can be imported from tigeropen.common.consts.SegmentType |
currency | Currency | no | currency,include ALL/USD/HKD/CNH, can be imported from tigeropen.common.consts.Currency |
sub_account | utility::string_t | no | Sub-account (for institutional accounts only), if this field is passed, the assets of the sub-account will be returned |
secret_key | utility::string_t | no | Institutional trader key. Only applicable to institutional users. It needs to be configured in client_config. Ignore if you are a individual developer |
Return
summary: The corresponding value is the asset analysis summary.
Argument | Type | Description |
---|---|---|
pnl | float | Profit and Loss Amount |
pnl_percentage | float | Profit and Loss Amount rate |
annualized_return | float | Annualized rate of return (imputed) |
over_user_percentage | float | Percentage of users exceeded |
history: History assets
Argument | Type | Description |
---|---|---|
date | int | Date timestamp in milliseconds |
pnl | float | Amount of profit or loss compared to the previous day |
pnl_percentage | float | Yield compared to the previous day |
asset | float | Total assets amount |
cash_balance | float | Cash balance |
gross_position_value | float | position market value |
deposit | float | deposit amount |
withdrawal | float | withdrawal amount |
Examples | float | market_value
static void test_get_analytics_asset(const std::shared_ptr<TradeClient>& trade_client) {
value res = trade_client->get_analytics_asset(trade_client->client_config.account, U("2023-11-01"),
U("2023-12-31"));
ucout << U("analytics asset: ") << res << endl;
}
Return example
{"history":[{"asset":48831542.450000003, "cashBalance":48831466.36999999997, "date":1688356800000, "deposit":0, "grossPositionValue". 76.0699999999999999993, "pnl":0, "pnlPercentage":0, "withdrawal":0},{"asset":48831533.82999999998, "cashBalance":48831460.32, "date". 1688443200000, "deposit":0, "grossPositionValue":73.510000000000005, "pnl":-8.619999999999999992, "pnlPercentage":0, "withdrawal":0},{" asset":48831521.65999999996, "cashBalance":48831447.100000001, "date":1688529600000, "deposit":0, "grossPositionValue". 74.5499999999999999997, "pnl":-20.7899999999999999999, "pnlPercentage":0, "withdrawal":0},{"asset":48831519.65999999996, "cashBalance":48831446,. 0},{"asset":48831525.450000003, "cashBalance":48831454.530000001, "date":1688702400000, "deposit":0, "grossPositionValue". 70.920000000000002, "pnl":-17, "pnlPercentage":0, "withdrawal":0},{"asset":48831529.340000004, "cashBalance":48831455.859999999, "date" :1688961600000, "deposit":0, "grossPositionValue":73.46999999999999999, "pnl":-13.1099999999999999999, "pnlPercentage":0, "withdrawal":0},{" asset":48831533.560000002, "cashBalance":48831453.020000003, "date":1689048000000, "deposit":0, "grossPositionValue". 80.540000000000006, "pnl":-8.8900000000000006, "pnlPercentage":0, "withdrawal":0}], "summary":{"annualizedReturn":0," overUserPercentage":0, "pnl":-8.8900000000000006, "pnlPercentage":0}}
get_estimate_tradable_quantity
value get_estimate_tradable_quantity(Order &order, utility::string_t seg_type = U("SEC"));
**Description
Queries the maximum tradable quantity of an underlying under an account, supports stocks and options, does not support futures for the time being.
Parameters
Only limit or stop orders are supported; futures are not supported for the time being.
Returns
Fields | Type | Description |
---|---|---|
tradable_quantity | float | cash_tradable_quantity (if action is buy, return as tradable quantity, vice versa) |
financing_quantity | float | Tradingable_quantity |
trading_position_quantity | float | position_quantity |
tradable_position_quantity | float | Position Tradable Quantity |
example
static void test_get_estimate_tradable_quantity(const std::shared_ptr<TradeClient>& trade_client) {
Contract contract = ContractUtil::stock_contract(U("AAPL"), U("USD"));
Order order = OrderUtil::limit_order(contract, U("BUY"), 1, 100.0); value res = trade_client-contract(U("AAPL"), U("USD")); value
value res = trade_client->get_estimate_tradable_quantity(order);
ucout << U("estimate tradable quantity: ") << res << endl;
}
Return example
{"financingQuantity":3391, "positionQuantity":178, "tradablePositionQuantity":178, "tradableQuantity":673}
get_segment_fund_available
value get_segment_fund_available(utility::string_t from_segment, utility::string_t currency = U("USD"));
Description
Get the funds available for transfer under the corresponding segment of the account (consolidated/demo account).
Parameters
Parameters | Type | Required or not | Description |
---|---|---|---|
from_segment | utility::string_t | No | Transfer out segment, FUT or SEC |
currency | utility::string_t | No | Transfer out currency, USD or HKD |
Returns
Name | Type | Description |
---|---|---|
from_segment | string | Transfer out segment, FUT or SEC |
currency | string | Transfer out currency, USD or HKD |
amount | float | Transferable funds, in dollars |
Examples
static void test_get_segment_fund_available(const std::shared_ptr<TradeClient>& trade_client) {
value res = trade_client->get_segment_fund_available(U("SEC"));
ucout << U("segment fund available: ") << res << endl;
}
Return example
[{"amount":93104.7599999999999995, "currency": "USD", "fromSegment": "SEC"}]
transfer_segment_fund
value transfer_segment_fund(utility::string_t from_segment, utility::string_t to_segment, double amount, utility::string_t currency = U(" USD"));
Description
Transfer of funds under different segments of an account, e.g. securities segment to futures segment (for consolidated or demo accounts).
Parameters
Parameters | Type | Required or not | Description |
---|---|---|---|
from_segment | utility::string_t | Yes | transfer out segment, FUT or SEC |
to_segment | utility::string_t | Yes | transfer to segment, FUT or SEC, must be different from from_segment |
currency | utility::string_t | Yes | Transfer to segment, USD or HKD |
amount | float | Yes | Transfer amount in $ of corresponding currency |
Returns
name | type | description |
---|---|---|
id | int | Transfer Record ID |
from_segment | utility::string_t | transfer_segment, FUT or SEC |
to_segment | utility::string_t | Transfer in to segment, FUT or SEC |
currency | utility::string_t | transfer_out_currency, USD or HKD |
amount | float | Transfer amount in dollars |
status | utility::string_t | Status (NEW/PROC/SUCC/FAIL/CANC) |
status_desc | utility::string_t | status_description (submitted/processing/accounted/failed/canceled) |
message | utility::string_t | Failed message |
settled_at | int | Arrival timestamp |
updated_at | int | update_timestamp |
created_at | int | Creation timestamp |
Example
static void test_transfer_segment_fund(const std::shared_ptr<TradeClient>& trade_client) {
value res = trade_client->transfer_segment_fund(U("SEC"), U("FUT"), 10.0);
ucout << U("transfer segment fund: ") << res << endl;
}
Return example
{'id': 30322815980011520, 'from_segment': 'SEC', 'to_segment': 'FUT', 'currency': 'USD'.
'updated_at': 1680243926131, 'created_at': 1680243926131}