查询账户信息

大约 13 分钟

get_managed_accounts 获取管理的账号列表

TradeClient.get_managed_accounts(account=None)

说明

获取本tiger_id关联的资金账号

参数

参数名类型是否必填描述
accountutility::string_tNo账号id,选填,不传则返回所有关联的 account

返回

AccountProfile(tigeropen.trade.domain.profile.AccountProfile)对象构成的列表

属性如下:

参数名类型描述
account综合账号:50129912,环球:U5755619,模拟账号:20191221901212121交易的资金账户,其中综合账号为5到10位数字,模拟账号为17位数字,环球账号以字母U开头
capabilityRegTMargin账户类型(CASH:现金账户, RegTMargin: Reg T 保证金账户, PMGRN: 投资组合保证金)
statusFunded账号状态,大部分场景会返回已入金(Funded)状态。状态包括: Funded(已入金), Open(已开户), Pending(待开户), Rejected(开户被拒绝), Closed(已注销)
accountTypeSTANDARD账户分类, GLOBAL:环球账号;STANDARD:综合账号;PAPER:模拟账号

示例

返回示例

get_assets 获取账户资产信息

value get_asset(string account = "", const value &sub_accounts = value::array(), bool segment = false,
                        bool market_value = false);

说明

获取账户资产信息,返回结构主要适用于环球账户,综合/模拟账号虽然也可使用此接口,但有较多字段为空,请使用 get_prime_assets 查询综合/模拟账户资产

参数

参数名类型是否必填描述
accountutility::string_tNo账户id,如不指定, 则使用 client_config 中的默认 account
sub_accountsvalueNo子账户列表,默认为None
segmentboolNo是否返回按照品种(证券、期货)分类的数据,默认 False,为True时,返回一个dict,C表示期货, S表示股票
market_valueboolNo是否返回按照币种(美元、港币、人民币)分类的数据,默认为 False
secret_keyutility::string_tNo机构交易员密钥,机构用户专有,机构用户必填,需要在client_config中配置

返回

list

list 中的每个元素是一个 PortfolioAccount 对象。如果只有一个account,list 中只有一个元素。 PortfolioAccount(tigeropen.trade.domain.account.PortfolioAccount) 对象的结构如下。

Account、SecuritySegment、CommoditySegment 中的信息请参考对象信息

PortfolioAccount 对象
├── account:账户id
├── summary:当前账户的汇总统计信息。里面的值是一个 Account 对象
├── segments:分品种的账户信息,是一个dict
│   ├── 'S' 表示证券账户,value 是 SecuritySegment 对象
│   └── 'C' 表示期货账户,value 是 CommoditySegment 对象
├── market_value:分币种的账户统计信息,是一个dict
│   ├── 'USD' 表示美元,value 是 MarketValue 对象
│   ├── 'HKD' 表示港币,value 是 MarketValue 对象
└─  └── 'CNH' 表示人民币,value 是 MarketValue 对象

示例

#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;

/**
 * 调用交易接口
 */
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();

    config.private_key = "xxxxxx your private key string xxxxxxxx";
    config.tiger_id = "your tiger id";
    config.account = "your account";



    /**
     * 使用封装后的交易接口 TradeClient
     */
    std::shared_ptr<TradeClient> trade_client = std::make_shared<TradeClient>(config);
    TestTradeClient::test_trade(trade_client);


    return 0;
}

** 返回示例 **

{
    "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 获取综合/模拟账户资产信息

value get_prime_asset(const string& account = "", const string& base_currency = "USD");

说明

获取资产信息,适用于综合/模拟账户

参数

参数名类型是否必填描述
accountutility::string_tNo账户id, 如不指定, 则使用 client_config 中的默认 account

返回

list

list 中的每个元素是一个 PortfolioAccount 对象。如果只有一个account,list 中只有一个元素。 PortfolioAccount 对象的结构如下。

PortfolioAccount、Segment 中的字段详细解释请参考对象信息

PortfolioAccount 对象
├── account:账户id
├── update_timestamp: 更新时间, 毫秒单位的时间戳
├── segments:分品种的账户信息,是以证券类别为 key 的 dict, 值为 Segment 对象
│   ├── 'S' 表示证券账户,value 是 Segment 对象
│   │    ├── currency: 币种, 如 USD, HKD
│   │    ├── capability: 账户类型, 保证金账户: RegTMargin, 现金账户: Cash。
│   │    ├── category': 交易品种分类 C: (Commodities 期货), S: (Securities 股票)
│   │    ├── cash_balance': 现金额。
│   │    ├── cash_available_for_trade': 可用资金,包含现金与融资,可用作交易参考值。
│   │    ├── cash_available_for_withdrawal': 当前账号内可以出金的现金金额
│   │    ├── gross_position_value': 证券总价值
│   │    ├── equity_with_loan': 含贷款价值总权益
│   │    ├── net_liquidation': 总资产;净清算值
│   │    ├── init_margin': 初始保证金
│   │    ├── maintain_margin': 维持保证金
│   │    ├── overnight_margin': 隔夜保证金
│   │    ├── unrealized_pl': 浮动盈亏
│   │    ├── realized_pl': 已实现盈亏
│   │    ├── excess_liquidation': 当前剩余流动性
│   │    ├── overnight_liquidation': 隔夜剩余流动性
│   │    ├── buying_power': 购买力
│   │    ├── leverage': 当前使用的杠杆倍数
│   │    ├── currency_assets:按照交易币种区分的账户资产信息,是以币种为 key 的 dict
│   │    │   ├── 'USD' 表示美元,value 是 CurrencyAsset 对象
│   │    │   │   ├── currency': 当前的货币币种,常用货币包括: USD-美元,HKD-港币,SGD-新加坡币,CNH-人民币
│   │    │   │   ├── cash_balance': 可以交易的现金,加上已锁定部分的现金(如已购买但还未成交的股票,还包括其他一些情形也会有锁定现金情况)
│   │    │   │   ├── cash_available_for_trade': 当前账号内可以交易的现金金额
│   │    │   ├── 'HKD' 表示港币,value 是 CurrencyAsset 对象
│   │    └─  └── 'CNH' 表示人民币,value 是 CurrencyAsset 对象
│   └── 'C' 表示期货账户,value 是 Segment 对象

示例

#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;

/**
 * 调用交易接口
 */
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();

    config.private_key = "xxxxxx your private key string xxxxxxxx";
    config.tiger_id = "your tiger id";
    config.account = "your account";



    /**
     * 使用封装后的交易接口 TradeClient
     */
    std::shared_ptr<TradeClient> trade_client = std::make_shared<TradeClient>(config);
    TestTradeClient::test_trade(trade_client);


    return 0;
}

返回示例

{
    "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 获取持仓数据

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 &currency = "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 = "");

说明

获取账户的持仓信息

参数

参数名类型是否必填描述
accountutility::string_tNo账户id,如不指定, 则使用 client_config 中的默认 account
sec_typeSecurityTypeNo交易品种,包括 STK/OPT/FUT 等, 默认 STK, 可以从 tigerapi/enums.h SecurityTypeopen in new window 下导入
currencyCurrencyNo币种,包括 ALL/USD/HKD/CNH 等, 默认 ALL, 可以从 tigerapi/enums.h Currencyopen in new window 下导入
marketMarketNo市场,包括 ALL/US/HK/CN 等, 默认 ALL, 可以从 tigerapi/enums.h Marketopen in new window 下导入
symbolutility::string_tNo证券代码
expiryutility::string_tNo过期日(适用于期权)。 形式 'yyyyMMdd', 比如 '220121'
strikefloatNo行权价(适用于期权)。如 100.5
put_callutility::string_tNo看涨或看跌(适用于期权)。'PUT' 或 'CALL'
sub_accountlist[str]No子账户列表
secret_keyutility::string_tNo机构交易员密钥,机构用户专有,需要在client_config中配置,个人开发者无需关注

返回

结构如下:

每个元素是一个 Position 对象。Position(tigeropen.trade.domain.position.Position)对象有如下的属性:

参数名类型描述
accountutility::string_t所属账户
contractContract合约对象,tigeropen.trade.domain.contract.Contract
quantityint持仓数量
average_costfloat持仓成本
market_pricefloat最新价格
market_valuefloat市值
realized_pnlfloat已实现盈亏
unrealized_pnlfloat浮动盈亏

示例

#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;

/**
 * 调用交易接口
 */
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();

    config.private_key = "xxxxxx your private key string xxxxxxxx";
    config.tiger_id = "your tiger id";
    config.account = "your account";



    /**
     * 使用封装后的交易接口 TradeClient
     */
    std::shared_ptr<TradeClient> trade_client = std::make_shared<TradeClient>(config);
    TestTradeClient::test_trade(trade_client);


    return 0;
}

返回示例

[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 获取综合/模拟账户历史资产分析

value get_analytics_asset(utility::string_t account, utility::string_t start_date, utility::string_t end_date, utility::string_t seg_type = U("SEC"), utility::string_t currency = U("USD"), utility::string_t sub_account = U(""));

说明

获取账户的历史资产分析

参数

参数名类型是否必填描述
accountutility::string_tno账户id,如不指定, 则使用 client_config 中的默认 account
start_dateutility::string_tno起始日期, 格式 yyyy-MM-dd, 如 '2022-01-01'。如不传则使用end_date往前30天的日期
end_dateutility::string_tno截止日期, 格式 yyyy-MM-dd, 如 '2022-02-01'。如不传则使用当前日期
seg_typeSegmentTypeno账户划分类型, 可选值有: SegmentType.SEC 代表证券; SegmentType.FUT 代表期货, 可以从 tigerapi/enums.h SegmentTypeopen in new window 下导入
currencyCurrencyno币种,包括 ALL/USD/HKD/CNH 等, 可以从 tigerapi/enums.h Currencyopen in new window 下导入
sub_accountutility::string_tno子账户(仅适用于机构账户), 若传该字段,则返回该子账户的资产
secret_keyutility::string_tno机构交易员密钥,机构用户专有,需要在client_config中配置,个人开发者无需指定

返回

summary 对应值为资产分析汇总, 各字段含义:

参数名类型描述
pnlfloat盈亏金额
pnl_percentagefloat收益率
annualized_returnfloat年化收益率(推算)
over_user_percentagefloat超过用户的百分比 overUserPercentage%

history 对应值为历史资产列表,各字段含义:

参数名类型描述
dateint日期时间戳,单位毫秒
pnlfloat与上一日比的盈亏金额
pnl_percentagefloat与上一日比的收益率
assetfloat总资产金额
cash_balancefloat现金余额
gross_position_valuefloat市值
depositfloat入金金额
withdrawalfloat出金金额

示例

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;
}

返回示例

{"history":[{"asset":48831542.450000003,"cashBalance":48831466.369999997,"date":1688356800000,"deposit":0,"grossPositionValue":76.069999999999993,"pnl":0,"pnlPercentage":0,"withdrawal":0},{"asset":48831533.829999998,"cashBalance":48831460.32,"date":1688443200000,"deposit":0,"grossPositionValue":73.510000000000005,"pnl":-8.6199999999999992,"pnlPercentage":0,"withdrawal":0},{"asset":48831521.659999996,"cashBalance":48831447.100000001,"date":1688529600000,"deposit":0,"grossPositionValue":74.549999999999997,"pnl":-20.789999999999999,"pnlPercentage":0,"withdrawal":0},{"asset":48831519.659999996,"cashBalance":48831446,"date":1688616000000,"deposit":0,"grossPositionValue":73.659999999999997,"pnl":-22.789999999999999,"pnlPercentage":0,"withdrawal":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.469999999999999,"pnl":-13.109999999999999,"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}}

获取最大可交易数量

value get_estimate_tradable_quantity(Order &order, utility::string_t seg_type = U("SEC"));

说明

查询账户下的对某个标的的最大可买卖数量,支持股票、期权,暂不支持期货。

参数

Order

只支持限价单或止损单;暂不支持期货。

返回

字段类型说明
tradable_quantityfloat现金可买卖数量(如action为buy,返回为可买数量,反之为可卖数量)
financing_quantityfloat融资融券可买卖数量(现金账号没有)
position_quantityfloat持仓数量
tradable_position_quantityfloat持仓可交易数量

示例

    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->get_estimate_tradable_quantity(order);
        ucout << U("estimate tradable quantity: ") << res << endl;
    }

返回示例

 {"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"));

说明

获取账户对应segment下的可以转出的资金(综合/模拟账号)

参数

参数类型是否必填描述
from_segmentutility::string_tNo转出segment, FUT或SEC
currencyutility::string_tNo转出币种,USD或HKD

返回

名称类型说明
from_segmentstring转出segment, FUT或SEC
currencystring转出币种,USD或HKD
amountfloat可转资金,单位:元

示例

    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;
    }

返回示例

[{"amount":93104.759999999995,"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"));

说明

对账户不同segment下的资金转账,如证券segment转期货segment (适用于综合或模拟账号)

参数

参数类型是否必填描述
from_segmentutility::string_tYes转出segment, FUT或SEC
to_segmentutility::string_tYes转入segment, FUT或SEC,必须与from_segment不同
currencyutility::string_tYes转出币种,USD或HKD
amountfloatYes转账金额,单位:对应币种的元

返回

名称类型说明
idint转账记录ID
from_segmentutility::string_t转出segment, FUT或SEC
to_segmentutility::string_t转入segment, FUT或SEC
currencyutility::string_t转出币种,USD或HKD
amountfloat转账金额,单位:元
statusutility::string_t状态(NEW/PROC/SUCC/FAIL/CANC)
status_descutility::string_t状态描述(已提交/处理中/已到账/转账失败/已取消)
messageutility::string_t失败信息
settled_atint到账时间戳
updated_atint更新时间戳
created_atint创建时间戳

示例

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;
}

返回示例

{'id': 30322815980011520, 'from_segment': 'SEC', 'to_segment': 'FUT', 'currency': 'USD',
 'amount': 100.0, 'status': 'NEW', 'status_desc': '已提交', 'message': None, 'settled_at': None,
  'updated_at': 1680243926131, 'created_at': 1680243926131}

get_segment_fund_history 账号内部资金转账历史记录查询

value get_segment_fund_history(int limit = 0);

说明

查询账号segment间的历史转账记录。按时间倒序排列。 (适用于综合/模拟账户)

参数

参数类型是否必填描述
limitintNo返回最近转账记录数。默认为100,最大500

返回

名称类型说明
idint转账记录ID
from_segmentutility::string_t转出segment, FUT或SEC
to_segmentutility::string_t转入segment, FUT或SEC
currencyutility::string_t转出币种,USD或HKD
amountfloat转账金额,单位:元
statusutility::string_t状态(NEW/PROC/SUCC/FAIL/CANC)
status_descutility::string_t状态描述(已提交/处理中/已到账/转账失败/已取消)
messageutility::string_t失败信息
settled_atint到账时间戳
updated_atint更新时间戳
created_atint创建时间戳

示例

static void test_get_segment_fund_history(const std::shared_ptr<TradeClient>& trade_client) {
    value res = trade_client->get_segment_fund_history();
    ucout << U("segment fund history: ") << res << endl;
}

返回示例

[{"amount":10,"createdAt":1689250798000,"currency":"USD","fromSegment":"SEC","id":31503365023203328,"settledAt":1689250802000,"status":"SUCC","statusDesc":"SUCCESS","toSegment":"FUT","updatedAt":1689250798000},{"amount":100,"createdAt":1680243926000,"currency":"USD","fromSegment":"SEC","id":30322815980011520,"settledAt":1680243927000,"status":"SUCC","statusDesc":"SUCCESS","toSegment":"FUT","updatedAt":1680243926000},{"amount":100,"createdAt":1679988683000,"currency":"USD","fromSegment":"SEC","id":30289360747233280,"settledAt":1679988683000,"status":"SUCC","statusDesc":"SUCCESS","toSegment":"FUT","updatedAt":1679988683000},{"amount":100,"createdAt":1679975418000,"currency":"USD","fromSegment":"SEC","id":30287622073483264,"settledAt":1679975418000,"status":"SUCC","statusDesc":"SUCCESS","toSegment":"FUT","updatedAt":1679975418000},{"amount":100,"createdAt":1679975237000,"currency":"USD","fromSegment":"SEC","id":30287598378156032,"settledAt":1679975238000,"status":"SUCC","statusDesc":"SUCCESS","toSegment":"FUT","updatedAt":1679975237000},{"amount":100,"createdAt":1679974286000,"currency":"USD","fromSegment":"SEC","id":30287473755029504,"settledAt":1679974287000,"status":"SUCC","statusDesc":"SUCCESS","toSegment":"FUT","updatedAt":1679974286000},{"amount":100,"createdAt":1679920128000,"currency":"USD","fromSegment":"SEC","id":30280375134060544,"settledAt":1679920129000,"status":"SUCC","statusDesc":"SUCCESS","toSegment":"FUT","updatedAt":1679920128000},{"amount":100,"createdAt":1679906158000,"currency":"USD","fromSegment":"SEC","id":30278544007888896,"settledAt":1679906158000,"status":"SUCC","statusDesc":"SUCCESS","toSegment":"FUT","updatedAt":1679906158000},{"amount":100,"createdAt":1679905746000,"currency":"USD","fromSegment":"SEC","id":30278490091552768,"settledAt":1679905747000,"status":"SUCC","statusDesc":"SUCCESS","toSegment":"FUT","updatedAt":1679905746000},{"amount":1000000,"createdAt":1572925615000,"currency":"USD","fromSegment":"SEC","id":16256390316032000,"settledAt":1573024157000,"status":"SUCC","statusDesc":"SUCCESS","toSegment":"FUT","updatedAt":1572925615000},{"amount":100000,"createdAt":1572925578000,"currency":"USD","fromSegment":"SEC","id":16256385456537600,"settledAt":1572925581000,"status":"SUCC","statusDesc":"SUCCESS","toSegment":"FUT","updatedAt":1572925578000},{"amount":100000,"createdAt":1572925520000,"currency":"USD","fromSegment":"SEC","id":16256377863667712,"settledAt":1572925525000,"status":"SUCC","statusDesc":"SUCCESS","toSegment":"FUT","updatedAt":1572925520000},{"amount":100000,"createdAt":1567573235000,"currency":"USD","fromSegment":"SEC","id":15554843128627200,"settledAt":1567573240000,"status":"SUCC","statusDesc":"SUCCESS","toSegment":"FUT","updatedAt":1567573235000},{"amount":10000,"createdAt":1556011922000,"currency":"USD","fromSegment":"SEC","id":14039478715026432,"settledAt":1556011922000,"status":"SUCC","statusDesc":"SUCCESS","toSegment":"FUT","updatedAt":1556011922000}]

上次编辑于: