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
aaeb4f02
Commit
aaeb4f02
authored
Oct 22, 2024
by
ml
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
ssh://gitlab.mytoken.org:10022/zhuangke/ts-api-demo
# Conflicts: # cron/task/coinAndPairSetting.ts
parents
37363b2d
39c96aff
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
35 deletions
+45
-35
coinAndPairSetting.ts
cron/task/coinAndPairSetting.ts
+30
-25
coreSystemUtils.ts
src/utils/coreSystemUtils.ts
+15
-10
No files found.
cron/task/coinAndPairSetting.ts
View file @
aaeb4f02
...
...
@@ -4,8 +4,8 @@
const
schedule
=
require
(
'node-schedule'
);
let
{
logger
,
datetimeUtils
}
=
require
(
'@madex/ex-js-public'
);
import
{
spotPairs
,
ormDB
,
coinType
}
from
"@madex/ex-ts-dao"
;
import
{
getPairFromCore
,
getCoinFromCore
}
from
'../
../
src/utils/coreSystemUtils'
import
{
spotPairs
,
ormDB
,
coinType
,
contractPairs
}
from
"@madex/ex-ts-dao"
;
import
{
getPairFromCore
,
getCoinFromCore
}
from
'../src/utils/coreSystemUtils'
let
running
=
false
;
...
...
@@ -30,9 +30,11 @@ let job = schedule.scheduleJob('*/15 * * * * ?', async function () {
}
});
const
syncPair
=
async
()
=>
{
let
now
=
new
Date
();
let
res
=
await
spotPairs
.
prototype
.
findAll
({
for
(
const
pairModel
of
[
spotPairs
,
contractPairs
])
{
let
res
=
await
pairModel
.
prototype
.
findAll
({
where
:
{
status
:
1
,
updatedAt
:
{
[
ormDB
.
Op
.
lt
]:
new
Date
(
now
.
getTime
()
-
10
*
1000
)
}
// 10秒之前的
...
...
@@ -44,20 +46,23 @@ const syncPair = async () => {
const
{
symbol
,
id
}
=
pair
;
let
cfg
=
await
getPairFromCore
(
symbol
);
if
(
cfg
)
{
await
spotPairs
.
prototype
.
update
({
await
pairModel
.
prototype
.
update
({
status
:
2
,
product_id
:
cfg
.
id
,
price_scale
:
cfg
[
"price-scale"
],
price_increment
:
cfg
[
"price-increment"
],
quantity_scale
:
cfg
[
"quantity-scale"
],
quantity_increment
:
cfg
[
"quantity-increment"
],
price_scale
:
cfg
[
"priceScale"
],
price_increment
:
cfg
[
"priceIncrement"
],
quantity_scale
:
cfg
[
"quantityScale"
],
quantity_increment
:
cfg
[
"quantityIncrement"
],
taker_fee
:
cfg
[
"takerFee"
],
maker_fee
:
cfg
[
"makerFee"
]
},
{
where
:
{
id
,
status
:
1
}
});
logger
.
info
(
symbol
,
"sync config success"
)
}
}
}
}
...
...
src/utils/coreSystemUtils.ts
View file @
aaeb4f02
...
...
@@ -19,16 +19,21 @@ export const getCoinFromCore = async (symbol) => {
return
data
.
result
[
0
];
}
// {
// "id": 1,
// "symbol": 'BTC_USDT',
// 'price-scale': 4,
// 'price-increment': 1,
// 'quantity-scale': 2,
// 'quantity-increment': '0'
// }
export
const
getPairFromCore
=
async
(
symbol
,
market
=
"spot"
)
=>
{
const
url
=
`
${
webadmin_endpoint
}
/pair/by_symbol?symbol=
${
symbol
}
&market=
${
market
}
`
// {"market":"spot",
// "symbol":"BTC_USDT",
// "takerFee":"0.001",
// "minOrderSize":"0",
// "quantityIncrement":"0.01",
// "makerFee":"0.001",
// "priceIncrement":1,"
// quantityScale":2,
// "priceScale":4,
// "maxOrderSize":"0",
// "maxOrderValue":"0",
// "minOrderValue":"0"}
// 合约的话还有多余对应db字段 predictedFundingRate nextFundingTime ...
export
const
getPairFromCore
=
async
(
symbol
)
=>
{
const
url
=
`
${
webadmin_endpoint
}
/pair/by_symbol?symbol=
${
symbol
}
`
let
{
data
}
=
await
axios
.
get
(
url
);
if
(
data
.
state
!=
0
)
{
logger
.
error
(
"getPairFromCore"
,
data
.
msg
);
...
...
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