Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
ts-api-demo
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wmvm
ts-api-demo
Commits
fcd618e0
Project 'zhuangke/ts-api-demo' was moved to 'wmvm/ts-api-demo'. Please update any links and bookmarks that may still have the old path.
Commit
fcd618e0
authored
Sep 04, 2024
by
ml
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
ssh://gitlab.mytoken.org:10022/zhuangke/ts-api-demo
parents
7752480f
c31719d0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
12 deletions
+68
-12
coinType.service.ts
src/functional/mvc/service/coinType.service.ts
+1
-1
spotPair.service.ts
src/functional/mvc/service/spotPair.service.ts
+2
-2
coreSystemUtils.ts
src/utils/coreSystemUtils.ts
+26
-9
ws.test.ts
test/ws.test.ts
+39
-0
No files found.
src/functional/mvc/service/coinType.service.ts
View file @
fcd618e0
...
@@ -129,7 +129,7 @@ export const pushToCoreSystem = async (id: any) => {
...
@@ -129,7 +129,7 @@ export const pushToCoreSystem = async (id: any) => {
if
(
cfg
)
{
if
(
cfg
)
{
let
symbol
=
cfg
.
general_name
;
let
symbol
=
cfg
.
general_name
;
let
optResult
=
await
addCoin2Core
(
symbol
);
let
optResult
=
await
addCoin2Core
(
symbol
,
cfg
.
id
);
if
(
optResult
)
{
if
(
optResult
)
{
await
coinType
.
prototype
.
update
({
main_status
:
1
},
{
await
coinType
.
prototype
.
update
({
main_status
:
1
},
{
where
:
where
where
:
where
...
...
src/functional/mvc/service/spotPair.service.ts
View file @
fcd618e0
...
@@ -75,8 +75,8 @@ export const pushToCoreSystem = async (id: any) => {
...
@@ -75,8 +75,8 @@ export const pushToCoreSystem = async (id: any) => {
let
quote
=
sps
[
1
]
let
quote
=
sps
[
1
]
let
param
=
{
let
param
=
{
"base"
:
base
,
"quote"
:
quote
,
"symbol"
:
symbol
,
"name"
:
symbol
,
"base"
:
base
,
"quote"
:
quote
,
"symbol"
:
symbol
,
"name"
:
symbol
,
"price
-scale"
:
cfg
.
price_scale
,
"quantity-
scale"
:
cfg
.
quantity_scale
,
"price
_scale"
:
cfg
.
price_scale
,
"quantity_
scale"
:
cfg
.
quantity_scale
,
"maker
-fee"
:
cfg
.
maker_fee
,
"taker-
fee"
:
cfg
.
taker_fee
"maker
_fee"
:
cfg
.
maker_fee
,
"taker_
fee"
:
cfg
.
taker_fee
}
}
let
optResult
=
await
addPairToCore
(
param
);
let
optResult
=
await
addPairToCore
(
param
);
if
(
optResult
)
{
if
(
optResult
)
{
...
...
src/utils/coreSystemUtils.ts
View file @
fcd618e0
...
@@ -36,6 +36,8 @@ export const getPairFromCore = async(symbol,market="spot")=> {
...
@@ -36,6 +36,8 @@ export const getPairFromCore = async(symbol,market="spot")=> {
return
data
[
0
]
return
data
[
0
]
}
}
// res:
// [{"name":"BTC","asset":1,"balance":"10","holds":"0"}]
export
const
getUserAccountFromCore
=
async
(
userId
,
withName
=
true
)
=>
{
export
const
getUserAccountFromCore
=
async
(
userId
,
withName
=
true
)
=>
{
const
url
=
`
${
webadmin_endpoint
}
/account/list?user_id=
${
userId
}
`
const
url
=
`
${
webadmin_endpoint
}
/account/list?user_id=
${
userId
}
`
let
{
data
}
=
await
axios
.
get
(
url
);
let
{
data
}
=
await
axios
.
get
(
url
);
...
@@ -65,14 +67,16 @@ export const getUserAccountFromCore = async(userId,withName = true)=> {
...
@@ -65,14 +67,16 @@ export const getUserAccountFromCore = async(userId,withName = true)=> {
return
data
;
return
data
;
}
}
// user_id
// user_id
// status, // 必须 unsettled或者settled
// status, // 必须 unsettled或者settled
// symbol, // 可选,交易对
// symbol, // 可选,交易对
// start_time, // 成交时间
// start_time, // 成交时间
// end_time, // 成交时间
// end_time, // 成交时间
// before, // update_id
// before, // update_id
// after, // update_id
// after, // update_id
// limit, / 数量
// limit, / 数量
// res:
// [{"orderId":"4611689316962271233","clientOrderId":"","createTime":"1725261917795","product":"BTC_USDT","type":1,"side":"buy","quantity":"1","stf":"disabled","price":"9999.0000","visibleQty":"1","timeInForce":"gtc","cancelAfter":0,"postOnly":false,"status":"accepted","executedQty":"0","fillCount":0,"fills":[],"fees":[],"updateTime":"1725261917795"},{"orderId":"4611689316962271234","clientOrderId":"","createTime":"1725261919337","product":"BTC_USDT","type":1,"side":"buy","quantity":"1","stf":"disabled","price":"9998.0000","visibleQty":"1","timeInForce":"gtc","cancelAfter":0,"postOnly":false,"status":"accepted","executedQty":"0","fillCount":0,"fills":[],"fees":[],"updateTime":"1725261919337"}]
export
const
getUserOrdersFromCore
=
async
(
params
)
=>
{
export
const
getUserOrdersFromCore
=
async
(
params
)
=>
{
// let params = new URLSearchParams();
// let params = new URLSearchParams();
const
url
=
`
${
webadmin_endpoint
}
/order/list`
const
url
=
`
${
webadmin_endpoint
}
/order/list`
...
@@ -85,12 +89,25 @@ export const getUserOrdersFromCore = async(params)=> {
...
@@ -85,12 +89,25 @@ export const getUserOrdersFromCore = async(params)=> {
return
data
return
data
}
}
export
const
getUserOrderFromCore
=
async
(
orderId
)
=>
{
// let params = new URLSearchParams();
const
url
=
`
${
webadmin_endpoint
}
/order/list`
let
{
data
}
=
await
axios
.
get
(
url
,{
params
});
if
(
data
.
error
)
{
logger
.
error
(
"getPairFromCore"
,
data
);
return
null
}
// console.log(data)
return
data
}
// getUserOrdersFromCore({user_id:1})
// getUserOrdersFromCore({user_id:1})
export
const
addCoin2Core
=
async
(
symbol
)
=>
{
export
const
addCoin2Core
=
async
(
symbol
,
id
)
=>
{
const
url
=
`
${
webadmin_endpoint
}
/asset/add`
const
url
=
`
${
webadmin_endpoint
}
/asset/add`
let
body
=
{
let
body
=
{
"symbol"
:
symbol
,
"symbol"
:
symbol
,
"id"
:
id
,
}
}
let
{
data
}
=
await
axios
.
post
(
url
,
body
);
let
{
data
}
=
await
axios
.
post
(
url
,
body
);
if
(
data
.
error
)
{
if
(
data
.
error
)
{
...
...
test/ws.test.ts
0 → 100644
View file @
fcd618e0
import
WebSocket
from
'ws'
;
const
client
=
new
WebSocket
(
'ws://127.0.0.1:8443?sid=12312'
,[],{
"headers"
:{
"api-key"
:
111
}});
// 心跳
let
heartbeatInterval
:
any
;
const
heartbeatConfig
=
{
interval
:
30000
,
// 心跳间隔
};
function
heartBeat
(){
console
.
log
(
new
Date
()
+
" send ping..."
)
client
.
ping
()
}
client
.
on
(
'error'
,
console
.
error
);
client
.
on
(
'open'
,
function
open
()
{
console
.
log
(
"success open!"
)
if
(
heartbeatInterval
)
{
clearInterval
(
heartbeatInterval
);
}
heartbeatInterval
=
setInterval
(
heartBeat
,
heartbeatConfig
.
interval
);
// 设置心跳
});
client
.
on
(
'message'
,
function
message
(
data
)
{
console
.
log
(
'received: %s'
,
data
);
});
client
.
on
(
'onclose'
,
function
message
(
data
)
{
if
(
heartbeatInterval
)
{
clearInterval
(
heartbeatInterval
);
// 清除心跳定时器
}
console
.
log
(
'Connection closed'
);
});
client
.
on
(
'pong'
,
function
(){
console
.
log
(
"rec pong"
)
})
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment