下载
登录/ 注册
主页
论坛
视频
热股
可转债
下载
下载

可帮助实现正规券商交易接口

21-12-23 21:55 209次浏览
含光
+关注
博主要求身份验证
登录用户ID:
可帮助交易风险能力测评为激进型的用户或高净值用户(300w以上现金资产或年收入50w以上)实现正规券商交易接口(非破解、非模拟鼠标键盘、非文件单),性能同tradex,可支持c/c++/c#/java/python编程语言

C语言例子

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include "trade_strategy.h"

/**
* @param argv[capitalAccount strtegyPassword strategyConfigPath orderStockCode orderStockPrice]
*/

#ifdef _WINDOWS_
#include <windows.h>
struct timezone {
int tz_minuteswest; /*格林威治时间往西方的时差*/
int tz_dsttime; /*DST 时间的修正方式*/
};
#ifndef _WINSOCKAPI_
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
};
#endif
int gettimeofday(struct timeval* tvp, struct timezone *tz) {
SYSTEMTIME wtm;
GetLocalTime(&wtm);
tvp->tv_usec = wtm.wMilliseconds * 1000;
return 0;
}
#else
#include <sys/time.h>
#endif

int main(int argc, char* argv[])
{
if (argc < 3) {
printf("usage : capitalAccount strtegyPassword [strategyConfigPath orderStockCode orderStockPrice]");
return ERROR_INVALID_CALL;
}
printf("登录策略\n");
char hash[HASH_ERR_BUFFER_SIZE];
char error[HASH_ERR_BUFFER_SIZE];
int nClientID = login(argv[1], argc > 3 ? argv[3] : "C:/TradeStrategy/MyStrategy.cfg", argv[2], hash, error);
if (nClientID < 0) {
printf("%s\n%d:%s", hash, nClientID, error);
return nClientID;
}
printf("登录成功\n");

int type;
printf("\n请指定账号类型,可选值\n0 :股票\n1 :信用\n2 :沪港通\n3 :深港通\n4 :期权\n5 :期货\n");
scanf_s("%d", &type);

char str[QUERY_BUFFER_SIZE];
char result[QUERY_BUFFER_SIZE];
int size = QUERY_BUFFER_SIZE;
const char* categories[] = {"资金", "持仓", "委托", "成交"};
for (int i = 0; i < 4; i++) {
printf("\n查询");
printf(categories);
printf("\n");
size = sizeof(str);
query(nClientID, i, type, str, &size);
size = sizeof(result);
printf(queryResult2StockTabTag(i, type, str, result, &size));
printf("\n");
}

if (argc > 4) {
char ch;
printf("\n请确认是否输入y下单委买\n");
scanf_s("%c", &ch, 1);
if (ch ==‘\n‘)
scanf_s("%c", &ch, 1);
if (ch==‘y‘) {
struct tm t;
struct timeval tv;
gettimeofday(&tv, NULL);
time_t current = time(NULL);
localtime_s(&t, ¤t);
printf("委买下单 %02d:%02d:%02d.%03d 策略委买 %s %s 100股\n", t.tm_hour, t.tm_min, t.tm_sec, tv.tv_usec / 1000, argv[5], argv[4]);
int buys[] = {23, 27, 23, 23, 50, 0};
order(nClientID, buys[type], 11, argv[4], atof(argv[5]), 100);
}
}

return 0;
}

输出
打开淘股吧APP
0
评论(0)
收藏
展开
热门 最新
提交