@yuants/vendor-aster 0.3.18 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account.js +2 -1
- package/dist/account.js.map +1 -1
- package/dist/api.js +3 -0
- package/dist/api.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/order.js +46 -3
- package/dist/order.js.map +1 -1
- package/dist/pending-orders.js +43 -0
- package/dist/pending-orders.js.map +1 -0
- package/dist/quote.js +35 -0
- package/dist/quote.js.map +1 -0
- package/lib/account.d.ts.map +1 -1
- package/lib/account.js +2 -1
- package/lib/account.js.map +1 -1
- package/lib/api.d.ts +33 -0
- package/lib/api.d.ts.map +1 -1
- package/lib/api.js +4 -1
- package/lib/api.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/order.js +45 -2
- package/lib/order.js.map +1 -1
- package/lib/pending-orders.d.ts +2 -0
- package/lib/pending-orders.d.ts.map +1 -0
- package/lib/pending-orders.js +45 -0
- package/lib/pending-orders.js.map +1 -0
- package/lib/quote.d.ts +2 -0
- package/lib/quote.d.ts.map +1 -0
- package/lib/quote.js +37 -0
- package/lib/quote.js.map +1 -0
- package/package.json +2 -1
- package/temp/package-deps.json +11 -8
package/dist/account.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { provideAccountInfoService } from '@yuants/data-account';
|
|
2
2
|
import { Terminal } from '@yuants/protocol';
|
|
3
|
+
import { encodePath } from '@yuants/utils';
|
|
3
4
|
import { getFApiV4Account } from './api';
|
|
4
5
|
const ADDRESS = process.env.ADDRESS;
|
|
5
6
|
export const ACCOUNT_ID = `ASTER/${ADDRESS}`;
|
|
@@ -11,7 +12,7 @@ provideAccountInfoService(Terminal.fromNodeEnv(), ACCOUNT_ID, async () => {
|
|
|
11
12
|
.filter((p) => +p.positionAmt !== 0)
|
|
12
13
|
.map((p) => ({
|
|
13
14
|
position_id: p.symbol,
|
|
14
|
-
product_id: p.symbol,
|
|
15
|
+
product_id: encodePath('PERPETUAL', p.symbol),
|
|
15
16
|
datasource_id: 'ASTER',
|
|
16
17
|
direction: p.positionSide === 'BOTH' ? (+p.positionAmt > 0 ? 'LONG' : 'SHORT') : p.positionSide,
|
|
17
18
|
volume: Math.abs(+p.positionAmt),
|
package/dist/account.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAEzC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAQ,CAAC;AACrC,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,OAAO,EAAE,CAAC;AAE7C,yBAAyB,CACvB,QAAQ,CAAC,WAAW,EAAE,EACtB,UAAU,EACV,KAAK,IAAI,EAAE;IACT,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAEtD,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,kBAAkB,GAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;IAChE,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAEjC,MAAM,SAAS,GAAG,CAAC,CAAC,SAAS;SAC1B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC;SACnC,GAAG,CACF,CAAC,CAAC,EAAa,EAAE,CAAC,CAAC;QACjB,WAAW,EAAE,CAAC,CAAC,MAAM;QACrB,UAAU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C,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY;QAC/F,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;QAChC,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;QACrC,cAAc,EAAE,CAAC,CAAC,CAAC,UAAU;QAC7B,cAAc,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC;QACtD,eAAe,EAAE,CAAC,CAAC,CAAC,gBAAgB;QACpC,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;KACjC,CAAC,CACH,CAAC;IACJ,OAAO;QACL,KAAK,EAAE;YACL,QAAQ,EAAE,KAAK;YACf,MAAM;YACN,IAAI;SACL;QACD,SAAS;KACV,CAAC;AACJ,CAAC,EACD,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAChC,CAAC","sourcesContent":["import { IPosition, provideAccountInfoService } from '@yuants/data-account';\nimport { Terminal } from '@yuants/protocol';\nimport { encodePath } from '@yuants/utils';\nimport { getFApiV4Account } from './api';\n\nconst ADDRESS = process.env.ADDRESS!;\nexport const ACCOUNT_ID = `ASTER/${ADDRESS}`;\n\nprovideAccountInfoService(\n Terminal.fromNodeEnv(),\n ACCOUNT_ID,\n async () => {\n const [a] = await Promise.all([getFApiV4Account({})]);\n\n const equity = +a.totalWalletBalance + +a.totalUnrealizedProfit;\n const free = +a.availableBalance;\n\n const positions = a.positions\n .filter((p) => +p.positionAmt !== 0)\n .map(\n (p): IPosition => ({\n position_id: p.symbol,\n product_id: encodePath('PERPETUAL', p.symbol),\n datasource_id: 'ASTER',\n direction: p.positionSide === 'BOTH' ? (+p.positionAmt > 0 ? 'LONG' : 'SHORT') : p.positionSide,\n volume: Math.abs(+p.positionAmt),\n free_volume: Math.abs(+p.positionAmt),\n position_price: +p.entryPrice,\n closable_price: Math.abs(+p.notional / +p.positionAmt),\n floating_profit: +p.unrealizedProfit,\n valuation: Math.abs(+p.notional),\n }),\n );\n return {\n money: {\n currency: 'USD',\n equity,\n free,\n },\n positions,\n };\n },\n { auto_refresh_interval: 1000 },\n);\n"]}
|
package/dist/api.js
CHANGED
|
@@ -40,7 +40,10 @@ const createApi = (type, method, endpoint) => (params) => request(type, method,
|
|
|
40
40
|
*/
|
|
41
41
|
export const getFApiV4Account = createApi('USER_DATA', 'GET', '/fapi/v4/account');
|
|
42
42
|
export const getFApiV2Balance = createApi('USER_DATA', 'GET', '/fapi/v2/balance');
|
|
43
|
+
export const getFApiV1TickerPrice = createApi('MARKET_DATA', 'GET', '/fapi/v1/ticker/price');
|
|
43
44
|
export const postFApiV1Order = createApi('TRADE', 'POST', '/fapi/v1/order');
|
|
45
|
+
export const getFApiV1OpenOrders = createApi('USER_DATA', 'GET', '/fapi/v1/openOrders');
|
|
46
|
+
export const deleteFApiV1Order = createApi('TRADE', 'DELETE', '/fapi/v1/order');
|
|
44
47
|
/**
|
|
45
48
|
* 获取交易对信息
|
|
46
49
|
*
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEhD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAQ,CAAC;AACrC,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,UAAW,CAAC;AAE3C,MAAM,QAAQ,GAAG,2BAA2B,CAAC;AAE7C,MAAM,OAAO,GAAG,KAAK,EACnB,IAAoE,EACpE,MAAc,EACd,QAAgB,EAChB,SAAc,EAAE,EACJ,EAAE;IACd,MAAM,UAAU,GAAG,IAAI,KAAK,MAAM,CAAC;IACnC,MAAM,QAAQ,GAAG,IAAI,KAAK,OAAO,IAAI,IAAI,K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,CAAC,CAAC;AAEF,MAAM,SAAS,GACb,CACE,IAAoE,EACpE,MAAc,EACd,QAAgB,EAChB,EAAE,CACJ,CAAC,MAAY,EAAE,EAAE,CACf,OAAO,CAAO,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAElD;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,CAqDvC,WAAW,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC;AAE1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,CAavC,WAAW,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC;AAE1C,MAAM,CAAC,MAAM,eAAe,GAAG,SAAS,CAmBtC,OAAO,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAErC;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,SAAS,CAkB5C,MAAM,EAAE,KAAK,EAAE,uBAAuB,CAAC,CAAC","sourcesContent":["import { opensslEquivalentHMAC } from './utils';\n\nconst API_KEY = process.env.API_KEY!;\nconst SECRET_KEY = process.env.SECRET_KEY!;\n\nconst BASE_URL = 'https://fapi.asterdex.com';\n\nconst request = async <T>(\n type: 'NONE' | 'TRADE' | 'USER_DATA' | 'USER_STREAM' | 'MARKET_DATA',\n method: string,\n endpoint: string,\n params: any = {},\n): Promise<T> => {\n const needApiKey = type !== 'NONE';\n const needSign = type === 'TRADE' || type === 'USER_DATA';\n\n const url = new URL(BASE_URL);\n url.pathname = endpoint;\n for (const [key, value] of Object.entries(params)) {\n if (value === undefined) continue;\n url.searchParams.set(key, `${value}`);\n }\n\n if (needSign) {\n url.searchParams.set('timestamp', `${Date.now()}`);\n const msg = url.search.slice(1); // 去掉开头的 '?'\n const signature = await opensslEquivalentHMAC(msg, SECRET_KEY);\n url.searchParams.set('signature', signature);\n }\n\n console.info(url.toString());\n const res = await fetch(url.toString(), {\n method,\n headers: needApiKey\n ? {\n 'X-MBX-APIKEY': API_KEY,\n }\n : {},\n }).then((response) => response.json());\n if (res.code && res.code !== 0) {\n throw JSON.stringify(res);\n }\n return res;\n};\n\nconst createApi =\n <TReq, TRes>(\n type: 'NONE' | 'TRADE' | 'USER_DATA' | 'USER_STREAM' | 'MARKET_DATA',\n method: string,\n endpoint: string,\n ) =>\n (params: TReq) =>\n request<TRes>(type, method, endpoint, params);\n\n/**\n * 获取账户信息\n *\n * https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api_CN.md#%E8%B4%A6%E6%88%B7%E4%BF%A1%E6%81%AFv4-user_data\n */\nexport const getFApiV4Account = createApi<\n {},\n {\n feeTier: number;\n canTrade: boolean;\n canDeposit: boolean;\n canWithdraw: boolean;\n updateTime: number;\n totalInitialMargin: string;\n totalMaintMargin: string;\n totalWalletBalance: string;\n totalUnrealizedProfit: string;\n totalMarginBalance: string;\n totalPositionInitialMargin: string;\n totalOpenOrderInitialMargin: string;\n totalCrossWalletBalance: string;\n totalCrossUnPnl: string;\n availableBalance: string;\n maxWithdrawAmount: string;\n assets: {\n asset: string;\n walletBalance: string;\n unrealizedProfit: string;\n marginBalance: string;\n maintMargin: string;\n initialMargin: string;\n positionInitialMargin: string;\n openOrderInitialMargin: string;\n maxWithdrawAmount: string;\n crossWalletBalance: string;\n crossUnPnl: string;\n availableBalance: string;\n marginAvailable: boolean;\n updateTime: number;\n }[];\n positions: {\n symbol: string;\n initialMargin: string;\n maintMargin: string;\n unrealizedProfit: string;\n positionInitialMargin: string;\n openOrderInitialMargin: string;\n leverage: string;\n isolated: boolean;\n entryPrice: string;\n maxNotional: string;\n positionSide: 'BOTH' | 'LONG' | 'SHORT';\n positionAmt: string;\n notional: string;\n isolatedWallet: string;\n updateTime: number;\n }[];\n }\n>('USER_DATA', 'GET', '/fapi/v4/account');\n\nexport const getFApiV2Balance = createApi<\n {},\n {\n accountAlias: string; // 账户唯一识别码\n asset: string; // 资产\n balance: string; // 总余额\n crossWalletBalance: string; // 全仓余额\n crossUnPnl: string; // 全仓持仓未实现盈亏\n availableBalance: string; // 下单可用余额\n maxWithdrawAmount: string; // 最大可转出余额\n marginAvailable: boolean; // 是否可用作联合保证金\n updateTime: number;\n }[]\n>('USER_DATA', 'GET', '/fapi/v2/balance');\n\nexport const postFApiV1Order = createApi<\n {\n symbol: string;\n side: 'BUY' | 'SELL';\n positionSide?: 'BOTH' | 'LONG' | 'SHORT';\n type:\n | 'MARKET'\n | 'LIMIT'\n | 'STOP'\n | 'STOP_MARKET'\n | 'TAKE_PROFIT'\n | 'TAKE_PROFIT_MARKET'\n | 'TRAILING_STOP_MARKET';\n reduceOnly?: 'true' | 'false';\n quantity?: number;\n price?: number;\n timeInForce?: 'GTC' | 'IOC' | 'FOK' | 'GTX' | 'HIDDEN';\n },\n {}\n>('TRADE', 'POST', '/fapi/v1/order');\n\n/**\n * 获取交易对信息\n *\n * https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api_CN.md#%E4%BA%A4%E6%98%93%E5%AF%B9%E4%BF%A1%E6%81%AF\n */\nexport const getFApiV1ExchangeInfo = createApi<\n {},\n {\n symbols: {\n symbol: string;\n status: 'TRADING' | 'BREAK' | 'HALT';\n baseAsset: string;\n quoteAsset: string;\n pricePrecision: number;\n quantityPrecision: number;\n baseAssetPrecision: number;\n quotePrecision: number;\n filters: {\n filterType: string;\n [key: string]: any;\n }[];\n }[];\n }\n>('NONE', 'GET', '/fapi/v1/exchangeInfo');\n"]}
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEhD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAQ,CAAC;AACrC,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,UAAW,CAAC;AAE3C,MAAM,QAAQ,GAAG,2BAA2B,CAAC;AAE7C,MAAM,OAAO,GAAG,KAAK,EACnB,IAAoE,EACpE,MAAc,EACd,QAAgB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AI,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE;QAC9B,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;KAC3B;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,SAAS,GACb,CACE,IAAoE,EACpE,MAAc,EACd,QAAgB,EAChB,EAAE,CACJ,CAAC,MAAY,EAAE,EAAE,CACf,OAAO,CAAO,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAElD;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,CAqDvC,WAAW,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC;AAE1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,CAavC,WAAW,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC;AAE1C,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAO3C,aAAa,EAAE,KAAK,EAAE,uBAAuB,CAAC,CAAC;AAEjD,MAAM,CAAC,MAAM,eAAe,GAAG,SAAS,CAmBtC,OAAO,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAErC,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAyB1C,WAAW,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAAC;AAE7C,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAOxC,OAAO,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,SAAS,CAkB5C,MAAM,EAAE,KAAK,EAAE,uBAAuB,CAAC,CAAC","sourcesContent":["import { opensslEquivalentHMAC } from './utils';\n\nconst API_KEY = process.env.API_KEY!;\nconst SECRET_KEY = process.env.SECRET_KEY!;\n\nconst BASE_URL = 'https://fapi.asterdex.com';\n\nconst request = async <T>(\n type: 'NONE' | 'TRADE' | 'USER_DATA' | 'USER_STREAM' | 'MARKET_DATA',\n method: string,\n endpoint: string,\n params: any = {},\n): Promise<T> => {\n const needApiKey = type !== 'NONE';\n const needSign = type === 'TRADE' || type === 'USER_DATA';\n\n const url = new URL(BASE_URL);\n url.pathname = endpoint;\n for (const [key, value] of Object.entries(params)) {\n if (value === undefined) continue;\n url.searchParams.set(key, `${value}`);\n }\n\n if (needSign) {\n url.searchParams.set('timestamp', `${Date.now()}`);\n const msg = url.search.slice(1); // 去掉开头的 '?'\n const signature = await opensslEquivalentHMAC(msg, SECRET_KEY);\n url.searchParams.set('signature', signature);\n }\n\n console.info(url.toString());\n const res = await fetch(url.toString(), {\n method,\n headers: needApiKey\n ? {\n 'X-MBX-APIKEY': API_KEY,\n }\n : {},\n }).then((response) => response.json());\n if (res.code && res.code !== 0) {\n throw JSON.stringify(res);\n }\n return res;\n};\n\nconst createApi =\n <TReq, TRes>(\n type: 'NONE' | 'TRADE' | 'USER_DATA' | 'USER_STREAM' | 'MARKET_DATA',\n method: string,\n endpoint: string,\n ) =>\n (params: TReq) =>\n request<TRes>(type, method, endpoint, params);\n\n/**\n * 获取账户信息\n *\n * https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api_CN.md#%E8%B4%A6%E6%88%B7%E4%BF%A1%E6%81%AFv4-user_data\n */\nexport const getFApiV4Account = createApi<\n {},\n {\n feeTier: number;\n canTrade: boolean;\n canDeposit: boolean;\n canWithdraw: boolean;\n updateTime: number;\n totalInitialMargin: string;\n totalMaintMargin: string;\n totalWalletBalance: string;\n totalUnrealizedProfit: string;\n totalMarginBalance: string;\n totalPositionInitialMargin: string;\n totalOpenOrderInitialMargin: string;\n totalCrossWalletBalance: string;\n totalCrossUnPnl: string;\n availableBalance: string;\n maxWithdrawAmount: string;\n assets: {\n asset: string;\n walletBalance: string;\n unrealizedProfit: string;\n marginBalance: string;\n maintMargin: string;\n initialMargin: string;\n positionInitialMargin: string;\n openOrderInitialMargin: string;\n maxWithdrawAmount: string;\n crossWalletBalance: string;\n crossUnPnl: string;\n availableBalance: string;\n marginAvailable: boolean;\n updateTime: number;\n }[];\n positions: {\n symbol: string;\n initialMargin: string;\n maintMargin: string;\n unrealizedProfit: string;\n positionInitialMargin: string;\n openOrderInitialMargin: string;\n leverage: string;\n isolated: boolean;\n entryPrice: string;\n maxNotional: string;\n positionSide: 'BOTH' | 'LONG' | 'SHORT';\n positionAmt: string;\n notional: string;\n isolatedWallet: string;\n updateTime: number;\n }[];\n }\n>('USER_DATA', 'GET', '/fapi/v4/account');\n\nexport const getFApiV2Balance = createApi<\n {},\n {\n accountAlias: string; // 账户唯一识别码\n asset: string; // 资产\n balance: string; // 总余额\n crossWalletBalance: string; // 全仓余额\n crossUnPnl: string; // 全仓持仓未实现盈亏\n availableBalance: string; // 下单可用余额\n maxWithdrawAmount: string; // 最大可转出余额\n marginAvailable: boolean; // 是否可用作联合保证金\n updateTime: number;\n }[]\n>('USER_DATA', 'GET', '/fapi/v2/balance');\n\nexport const getFApiV1TickerPrice = createApi<\n {},\n {\n symbol: string;\n price: string;\n time?: number;\n }[]\n>('MARKET_DATA', 'GET', '/fapi/v1/ticker/price');\n\nexport const postFApiV1Order = createApi<\n {\n symbol: string;\n side: 'BUY' | 'SELL';\n positionSide?: 'BOTH' | 'LONG' | 'SHORT';\n type:\n | 'MARKET'\n | 'LIMIT'\n | 'STOP'\n | 'STOP_MARKET'\n | 'TAKE_PROFIT'\n | 'TAKE_PROFIT_MARKET'\n | 'TRAILING_STOP_MARKET';\n reduceOnly?: 'true' | 'false';\n quantity?: number;\n price?: number;\n timeInForce?: 'GTC' | 'IOC' | 'FOK' | 'GTX' | 'HIDDEN';\n },\n {}\n>('TRADE', 'POST', '/fapi/v1/order');\n\nexport const getFApiV1OpenOrders = createApi<\n {\n symbol?: string;\n },\n {\n orderId: number;\n clientOrderId: string;\n price: string;\n origQty: string;\n executedQty: string;\n status: string;\n timeInForce: string;\n type: string;\n side: 'BUY' | 'SELL';\n updateTime: number;\n avgPrice: string;\n reduceOnly?: boolean;\n closePosition?: boolean;\n positionSide?: 'BOTH' | 'LONG' | 'SHORT';\n workingType?: string;\n priceProtect?: boolean;\n origType?: string;\n stopPrice?: string;\n symbol: string;\n }[]\n>('USER_DATA', 'GET', '/fapi/v1/openOrders');\n\nexport const deleteFApiV1Order = createApi<\n {\n symbol: string;\n orderId?: string | number;\n origClientOrderId?: string;\n },\n {}\n>('TRADE', 'DELETE', '/fapi/v1/order');\n\n/**\n * 获取交易对信息\n *\n * https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api_CN.md#%E4%BA%A4%E6%98%93%E5%AF%B9%E4%BF%A1%E6%81%AF\n */\nexport const getFApiV1ExchangeInfo = createApi<\n {},\n {\n symbols: {\n symbol: string;\n status: 'TRADING' | 'BREAK' | 'HALT';\n baseAsset: string;\n quoteAsset: string;\n pricePrecision: number;\n quantityPrecision: number;\n baseAssetPrecision: number;\n quotePrecision: number;\n filters: {\n filterType: string;\n [key: string]: any;\n }[];\n }[];\n }\n>('NONE', 'GET', '/fapi/v1/exchangeInfo');\n"]}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,CAAC;AACnB,OAAO,gBAAgB,CAAC;AACxB,OAAO,SAAS,CAAC;AACjB,OAAO,cAAc,CAAC;AACtB,OAAO,WAAW,CAAC,CAAC,iCAAiC","sourcesContent":["import './account';\nimport './account-spot';\nimport './order';\nimport './order-spot';\nimport './product'; // Import the new product service\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,CAAC;AACnB,OAAO,gBAAgB,CAAC;AACxB,OAAO,SAAS,CAAC;AACjB,OAAO,cAAc,CAAC;AACtB,OAAO,WAAW,CAAC,CAAC,iCAAiC;AACrD,OAAO,kBAAkB,CAAC;AAC1B,OAAO,SAAS,CAAC","sourcesContent":["import './account';\nimport './account-spot';\nimport './order';\nimport './order-spot';\nimport './product'; // Import the new product service\nimport './pending-orders';\nimport './quote';\n"]}
|
package/dist/order.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { Terminal } from '@yuants/protocol';
|
|
2
|
+
import { decodePath } from '@yuants/utils';
|
|
2
3
|
import { ACCOUNT_ID } from './account';
|
|
3
|
-
import { postFApiV1Order } from './api';
|
|
4
|
+
import { deleteFApiV1Order, postFApiV1Order } from './api';
|
|
4
5
|
const terminal = Terminal.fromNodeEnv();
|
|
5
6
|
terminal.server.provideService('SubmitOrder', { required: ['account_id'], properties: { account_id: { type: 'string', const: ACCOUNT_ID } } }, async (msg) => {
|
|
7
|
+
var _a, _b, _c, _d, _e;
|
|
6
8
|
const order = msg.req;
|
|
7
|
-
const
|
|
9
|
+
const [, decodedSymbol] = decodePath(order.product_id);
|
|
10
|
+
if (!decodedSymbol) {
|
|
11
|
+
throw new Error(`Invalid product_id: unable to decode symbol from "${order.product_id}"`);
|
|
12
|
+
}
|
|
13
|
+
const symbol = decodedSymbol;
|
|
8
14
|
const side = { OPEN_LONG: 'BUY', OPEN_SHORT: 'SELL', CLOSE_LONG: 'SELL', CLOSE_SHORT: 'BUY' }[order.order_direction];
|
|
9
15
|
if (!side)
|
|
10
16
|
throw new Error(`Unsupported order_direction: ${order.order_direction}`);
|
|
@@ -13,14 +19,51 @@ terminal.server.provideService('SubmitOrder', { required: ['account_id'], proper
|
|
|
13
19
|
throw new Error(`Unsupported order_type: ${order.order_type}`);
|
|
14
20
|
const quantity = order.volume;
|
|
15
21
|
const price = order.price;
|
|
22
|
+
const positionSide = order.order_direction === 'OPEN_LONG' || order.order_direction === 'CLOSE_LONG'
|
|
23
|
+
? 'LONG'
|
|
24
|
+
: order.order_direction === 'OPEN_SHORT' || order.order_direction === 'CLOSE_SHORT'
|
|
25
|
+
? 'SHORT'
|
|
26
|
+
: undefined;
|
|
27
|
+
const reduceOnly = order.order_direction === 'CLOSE_LONG' || order.order_direction === 'CLOSE_SHORT' ? 'true' : undefined;
|
|
16
28
|
const timeInForce = order.order_type === 'MAKER' ? 'GTX' : order.order_type === 'LIMIT' ? 'GTC' : undefined;
|
|
17
|
-
await postFApiV1Order({
|
|
29
|
+
const res = await postFApiV1Order({
|
|
18
30
|
symbol,
|
|
19
31
|
side,
|
|
20
32
|
type,
|
|
21
33
|
quantity,
|
|
22
34
|
price,
|
|
23
35
|
timeInForce,
|
|
36
|
+
positionSide,
|
|
37
|
+
reduceOnly,
|
|
38
|
+
});
|
|
39
|
+
const orderId = (_d = (_b = (_a = res === null || res === void 0 ? void 0 : res.orderId) !== null && _a !== void 0 ? _a : res === null || res === void 0 ? void 0 : res.order_id) !== null && _b !== void 0 ? _b : (_c = res === null || res === void 0 ? void 0 : res.data) === null || _c === void 0 ? void 0 : _c.orderId) !== null && _d !== void 0 ? _d : (_e = res === null || res === void 0 ? void 0 : res.data) === null || _e === void 0 ? void 0 : _e.order_id;
|
|
40
|
+
return {
|
|
41
|
+
res: {
|
|
42
|
+
code: 0,
|
|
43
|
+
message: 'OK',
|
|
44
|
+
data: orderId ? { order_id: `${orderId}` } : undefined,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
terminal.server.provideService('CancelOrder', {
|
|
49
|
+
required: ['account_id', 'order_id', 'product_id'],
|
|
50
|
+
properties: {
|
|
51
|
+
account_id: { type: 'string', const: ACCOUNT_ID },
|
|
52
|
+
order_id: { type: ['string', 'number'] },
|
|
53
|
+
product_id: { type: 'string' },
|
|
54
|
+
},
|
|
55
|
+
}, async (msg) => {
|
|
56
|
+
const order = msg.req;
|
|
57
|
+
const [, decodedSymbol] = decodePath(order.product_id);
|
|
58
|
+
if (!decodedSymbol) {
|
|
59
|
+
throw new Error(`Invalid product_id: unable to decode symbol from "${order.product_id}"`);
|
|
60
|
+
}
|
|
61
|
+
if (!order.order_id) {
|
|
62
|
+
throw new Error('order_id is required for CancelOrder');
|
|
63
|
+
}
|
|
64
|
+
await deleteFApiV1Order({
|
|
65
|
+
symbol: decodedSymbol,
|
|
66
|
+
orderId: order.order_id,
|
|
24
67
|
});
|
|
25
68
|
return { res: { code: 0, message: 'OK' } };
|
|
26
69
|
});
|
package/dist/order.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order.js","sourceRoot":"","sources":["../src/order.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"order.js","sourceRoot":"","sources":["../src/order.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAE3D,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;AAExC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAC5B,aAAa,EACb,EAAE,QAAQ,EAAE,CAAC,YAAY,CAAC,EAAE,UAAU,EAAE,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,EAC/F,KAAK,EAAE,GAAG,EAAE,EAAE;;IACZ,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC;IAEtB,MAAM,CAAC,EAAE,aAAa,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACvD,IAAI,CAAC,aAAa,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,qDAAqD,KAAK,CAAC,UAAU,GAAG,CAAC,CAA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AAK,CAAC,UAAU,GAAG,CAAC,CAAC;KAC3F;IACD,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;KACzD;IAED,MAAM,iBAAiB,CAAC;QACtB,MAAM,EAAE,aAAa;QACrB,OAAO,EAAE,KAAK,CAAC,QAAQ;KACxB,CAAC,CAAC;IAEH,OAAO,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;AAC7C,CAAC,CACF,CAAC","sourcesContent":["import { Terminal } from '@yuants/protocol';\nimport { IOrder } from '@yuants/data-order';\nimport { decodePath } from '@yuants/utils';\nimport { ACCOUNT_ID } from './account';\nimport { deleteFApiV1Order, postFApiV1Order } from './api';\n\nconst terminal = Terminal.fromNodeEnv();\n\nterminal.server.provideService<IOrder, { order_id?: string }>(\n 'SubmitOrder',\n { required: ['account_id'], properties: { account_id: { type: 'string', const: ACCOUNT_ID } } },\n async (msg) => {\n const order = msg.req;\n\n const [, decodedSymbol] = decodePath(order.product_id);\n if (!decodedSymbol) {\n throw new Error(`Invalid product_id: unable to decode symbol from \"${order.product_id}\"`);\n }\n const symbol = decodedSymbol;\n\n const side = ({ OPEN_LONG: 'BUY', OPEN_SHORT: 'SELL', CLOSE_LONG: 'SELL', CLOSE_SHORT: 'BUY' } as const)[\n order.order_direction!\n ];\n if (!side) throw new Error(`Unsupported order_direction: ${order.order_direction}`);\n\n const type = ({ MARKET: 'MARKET', LIMIT: 'LIMIT', MAKER: 'LIMIT' } as const)[order.order_type!];\n if (!type) throw new Error(`Unsupported order_type: ${order.order_type}`);\n\n const quantity = order.volume;\n const price = order.price;\n\n const positionSide =\n order.order_direction === 'OPEN_LONG' || order.order_direction === 'CLOSE_LONG'\n ? 'LONG'\n : order.order_direction === 'OPEN_SHORT' || order.order_direction === 'CLOSE_SHORT'\n ? 'SHORT'\n : undefined;\n\n const reduceOnly =\n order.order_direction === 'CLOSE_LONG' || order.order_direction === 'CLOSE_SHORT' ? 'true' : undefined;\n\n const timeInForce =\n order.order_type === 'MAKER' ? 'GTX' : order.order_type === 'LIMIT' ? 'GTC' : undefined;\n\n const res = await postFApiV1Order({\n symbol,\n side,\n type,\n quantity,\n price,\n timeInForce,\n positionSide,\n reduceOnly,\n });\n\n const orderId =\n (res as any)?.orderId ??\n (res as any)?.order_id ??\n (res as any)?.data?.orderId ??\n (res as any)?.data?.order_id;\n\n return {\n res: {\n code: 0,\n message: 'OK',\n data: orderId ? { order_id: `${orderId}` } : undefined,\n },\n };\n },\n);\n\nterminal.server.provideService<IOrder>(\n 'CancelOrder',\n {\n required: ['account_id', 'order_id', 'product_id'],\n properties: {\n account_id: { type: 'string', const: ACCOUNT_ID },\n order_id: { type: ['string', 'number'] },\n product_id: { type: 'string' },\n },\n },\n async (msg) => {\n const order = msg.req;\n const [, decodedSymbol] = decodePath(order.product_id);\n if (!decodedSymbol) {\n throw new Error(`Invalid product_id: unable to decode symbol from \"${order.product_id}\"`);\n }\n if (!order.order_id) {\n throw new Error('order_id is required for CancelOrder');\n }\n\n await deleteFApiV1Order({\n symbol: decodedSymbol,\n orderId: order.order_id,\n });\n\n return { res: { code: 0, message: 'OK' } };\n },\n);\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { providePendingOrdersService } from '@yuants/data-order';
|
|
2
|
+
import { Terminal } from '@yuants/protocol';
|
|
3
|
+
import { encodePath } from '@yuants/utils';
|
|
4
|
+
import { ACCOUNT_ID } from './account';
|
|
5
|
+
import { getFApiV1OpenOrders } from './api';
|
|
6
|
+
const terminal = Terminal.fromNodeEnv();
|
|
7
|
+
const resolveOrderDirection = (asterOrder) => {
|
|
8
|
+
const reduceOnly = asterOrder.reduceOnly || asterOrder.closePosition;
|
|
9
|
+
if (asterOrder.positionSide === 'LONG') {
|
|
10
|
+
return asterOrder.side === 'BUY' ? 'OPEN_LONG' : 'CLOSE_LONG';
|
|
11
|
+
}
|
|
12
|
+
if (asterOrder.positionSide === 'SHORT') {
|
|
13
|
+
return asterOrder.side === 'BUY' ? 'CLOSE_SHORT' : 'OPEN_SHORT';
|
|
14
|
+
}
|
|
15
|
+
if (reduceOnly) {
|
|
16
|
+
return asterOrder.side === 'BUY' ? 'CLOSE_SHORT' : 'CLOSE_LONG';
|
|
17
|
+
}
|
|
18
|
+
return asterOrder.side === 'BUY' ? 'OPEN_LONG' : 'OPEN_SHORT';
|
|
19
|
+
};
|
|
20
|
+
providePendingOrdersService(terminal, ACCOUNT_ID, async () => {
|
|
21
|
+
const orders = (await getFApiV1OpenOrders({}));
|
|
22
|
+
return orders.map((order) => {
|
|
23
|
+
const volume = Number(order.origQty);
|
|
24
|
+
const tradedVolume = Number(order.executedQty);
|
|
25
|
+
const price = Number(order.price);
|
|
26
|
+
const avgPrice = Number(order.avgPrice);
|
|
27
|
+
const mapped = {
|
|
28
|
+
order_id: `${order.orderId}`,
|
|
29
|
+
account_id: ACCOUNT_ID,
|
|
30
|
+
product_id: encodePath('PERPETUAL', order.symbol),
|
|
31
|
+
order_type: order.type,
|
|
32
|
+
order_direction: resolveOrderDirection(order),
|
|
33
|
+
volume: Number.isFinite(volume) ? volume : 0,
|
|
34
|
+
price: Number.isFinite(price) ? price : undefined,
|
|
35
|
+
submit_at: order.updateTime,
|
|
36
|
+
traded_volume: Number.isFinite(tradedVolume) ? tradedVolume : undefined,
|
|
37
|
+
traded_price: Number.isFinite(avgPrice) && avgPrice > 0 ? avgPrice : undefined,
|
|
38
|
+
order_status: order.status,
|
|
39
|
+
};
|
|
40
|
+
return mapped;
|
|
41
|
+
});
|
|
42
|
+
}, { auto_refresh_interval: 2000 });
|
|
43
|
+
//# sourceMappingURL=pending-orders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pending-orders.js","sourceRoot":"","sources":["../src/pending-orders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,2BAA2B,EAAE,MAAM,oBAA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C,KAAK,CAAC,WAAW,CAAC,CAAC;QAC/C,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAClC,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAExC,MAAM,MAAM,GAAW;YACrB,QAAQ,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE;YAC5B,UAAU,EAAE,UAAU;YACtB,UAAU,EAAE,UAAU,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC;YACjD,UAAU,EAAE,KAAK,CAAC,IAAI;YACtB,eAAe,EAAE,qBAAqB,CAAC,KAAK,CAAC;YAC7C,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC5C,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;YACjD,SAAS,EAAE,KAAK,CAAC,UAAU;YAC3B,aAAa,EAAE,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;YACvE,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;YAC9E,YAAY,EAAE,KAAK,CAAC,MAAM;SAC3B,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,EACD,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAChC,CAAC","sourcesContent":["import { IOrder, providePendingOrdersService } from '@yuants/data-order';\nimport { Terminal } from '@yuants/protocol';\nimport { encodePath } from '@yuants/utils';\nimport { ACCOUNT_ID } from './account';\nimport { getFApiV1OpenOrders } from './api';\n\nconst terminal = Terminal.fromNodeEnv();\n\ntype OrderDirection = 'OPEN_LONG' | 'OPEN_SHORT' | 'CLOSE_LONG' | 'CLOSE_SHORT';\n\ninterface IAsterOpenOrder {\n orderId: number;\n symbol: string;\n side: 'BUY' | 'SELL';\n positionSide?: 'BOTH' | 'LONG' | 'SHORT';\n reduceOnly?: boolean;\n closePosition?: boolean;\n type: string;\n origQty: string;\n executedQty: string;\n price: string;\n avgPrice: string;\n status: string;\n updateTime: number;\n}\n\nconst resolveOrderDirection = (asterOrder: IAsterOpenOrder): OrderDirection => {\n const reduceOnly = asterOrder.reduceOnly || asterOrder.closePosition;\n\n if (asterOrder.positionSide === 'LONG') {\n return asterOrder.side === 'BUY' ? 'OPEN_LONG' : 'CLOSE_LONG';\n }\n if (asterOrder.positionSide === 'SHORT') {\n return asterOrder.side === 'BUY' ? 'CLOSE_SHORT' : 'OPEN_SHORT';\n }\n if (reduceOnly) {\n return asterOrder.side === 'BUY' ? 'CLOSE_SHORT' : 'CLOSE_LONG';\n }\n return asterOrder.side === 'BUY' ? 'OPEN_LONG' : 'OPEN_SHORT';\n};\n\nprovidePendingOrdersService(\n terminal,\n ACCOUNT_ID,\n async () => {\n const orders = (await getFApiV1OpenOrders({})) as IAsterOpenOrder[];\n return orders.map((order) => {\n const volume = Number(order.origQty);\n const tradedVolume = Number(order.executedQty);\n const price = Number(order.price);\n const avgPrice = Number(order.avgPrice);\n\n const mapped: IOrder = {\n order_id: `${order.orderId}`,\n account_id: ACCOUNT_ID,\n product_id: encodePath('PERPETUAL', order.symbol),\n order_type: order.type,\n order_direction: resolveOrderDirection(order),\n volume: Number.isFinite(volume) ? volume : 0,\n price: Number.isFinite(price) ? price : undefined,\n submit_at: order.updateTime,\n traded_volume: Number.isFinite(tradedVolume) ? tradedVolume : undefined,\n traded_price: Number.isFinite(avgPrice) && avgPrice > 0 ? avgPrice : undefined,\n order_status: order.status,\n };\n\n return mapped;\n });\n },\n { auto_refresh_interval: 2000 },\n);\n"]}
|
package/dist/quote.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Terminal } from '@yuants/protocol';
|
|
2
|
+
import { writeToSQL } from '@yuants/sql';
|
|
3
|
+
import { decodePath, encodePath } from '@yuants/utils';
|
|
4
|
+
import { defer, filter, map, mergeMap, repeat, retry, shareReplay } from 'rxjs';
|
|
5
|
+
import { getFApiV1TickerPrice } from './api';
|
|
6
|
+
const terminal = Terminal.fromNodeEnv();
|
|
7
|
+
const quote$ = defer(() => getFApiV1TickerPrice({})).pipe(mergeMap((tickers) => tickers || []), map((ticker) => {
|
|
8
|
+
var _a;
|
|
9
|
+
return ({
|
|
10
|
+
datasource_id: 'ASTER',
|
|
11
|
+
product_id: encodePath('PERPETUAL', ticker.symbol),
|
|
12
|
+
last_price: `${ticker.price}`,
|
|
13
|
+
bid_price: `${ticker.price}`,
|
|
14
|
+
ask_price: `${ticker.price}`,
|
|
15
|
+
updated_at: new Date((_a = ticker.time) !== null && _a !== void 0 ? _a : Date.now()).toISOString(),
|
|
16
|
+
});
|
|
17
|
+
}), repeat({ delay: 1000 }), retry({ delay: 5000 }), shareReplay({ bufferSize: 1, refCount: true }));
|
|
18
|
+
if (process.env.WRITE_QUOTE_TO_SQL === 'true') {
|
|
19
|
+
quote$
|
|
20
|
+
.pipe(writeToSQL({
|
|
21
|
+
terminal,
|
|
22
|
+
tableName: 'quote',
|
|
23
|
+
writeInterval: 1000,
|
|
24
|
+
conflictKeys: ['datasource_id', 'product_id'],
|
|
25
|
+
}))
|
|
26
|
+
.subscribe();
|
|
27
|
+
terminal.channel.publishChannel('quote', { pattern: '^ASTER/' }, (channel_id) => {
|
|
28
|
+
const [datasourceId, productId] = decodePath(channel_id);
|
|
29
|
+
if (!datasourceId || !productId) {
|
|
30
|
+
throw new Error(`Invalid channel_id: ${channel_id}`);
|
|
31
|
+
}
|
|
32
|
+
return quote$.pipe(filter((quote) => quote.product_id === productId));
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=quote.js.map
|
|
@@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EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAC/C,CAAC;AAEF,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,KAAK,MAAM,EAAE;IAC7C,MAAM;SACH,IAAI,CACH,UAAU,CAAC;QACT,QAAQ;QACR,SAAS,EAAE,OAAO;QAClB,aAAa,EAAE,IAAI;QACnB,YAAY,EAAE,CAAC,eAAe,EAAE,YAAY,CAAC;KAC9C,CAAC,CACH;SACA,SAAS,EAAE,CAAC;IAEf,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,EAAE;QAC9E,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;QACzD,IAAI,CAAC,YAAY,IAAI,CAAC,SAAS,EAAE;YAC/B,MAAM,IAAI,KAAK,CAAC,uBAAuB,UAAU,EAAE,CAAC,CAAC;SACtD;QACD,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;CACJ","sourcesContent":["import type { IQuote } from '../../../libraries/data-quote/lib';\nimport { Terminal } from '@yuants/protocol';\nimport { writeToSQL } from '@yuants/sql';\nimport { decodePath, encodePath } from '@yuants/utils';\nimport { defer, filter, map, mergeMap, repeat, retry, shareReplay } from 'rxjs';\nimport { getFApiV1TickerPrice } from './api';\n\nconst terminal = Terminal.fromNodeEnv();\n\nconst quote$ = defer(() => getFApiV1TickerPrice({})).pipe(\n mergeMap((tickers) => tickers || []),\n map(\n (ticker): Partial<IQuote> => ({\n datasource_id: 'ASTER',\n product_id: encodePath('PERPETUAL', ticker.symbol),\n last_price: `${ticker.price}`,\n bid_price: `${ticker.price}`,\n ask_price: `${ticker.price}`,\n updated_at: new Date(ticker.time ?? Date.now()).toISOString(),\n }),\n ),\n repeat({ delay: 1000 }),\n retry({ delay: 5000 }),\n shareReplay({ bufferSize: 1, refCount: true }),\n);\n\nif (process.env.WRITE_QUOTE_TO_SQL === 'true') {\n quote$\n .pipe(\n writeToSQL({\n terminal,\n tableName: 'quote',\n writeInterval: 1000,\n conflictKeys: ['datasource_id', 'product_id'],\n }),\n )\n .subscribe();\n\n terminal.channel.publishChannel('quote', { pattern: '^ASTER/' }, (channel_id) => {\n const [datasourceId, productId] = decodePath(channel_id);\n if (!datasourceId || !productId) {\n throw new Error(`Invalid channel_id: ${channel_id}`);\n }\n return quote$.pipe(filter((quote) => quote.product_id === productId));\n });\n}\n"]}
|
package/lib/account.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,UAAU,QAAqB,CAAC"}
|
package/lib/account.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ACCOUNT_ID = void 0;
|
|
4
4
|
const data_account_1 = require("@yuants/data-account");
|
|
5
5
|
const protocol_1 = require("@yuants/protocol");
|
|
6
|
+
const utils_1 = require("@yuants/utils");
|
|
6
7
|
const api_1 = require("./api");
|
|
7
8
|
const ADDRESS = process.env.ADDRESS;
|
|
8
9
|
exports.ACCOUNT_ID = `ASTER/${ADDRESS}`;
|
|
@@ -14,7 +15,7 @@ exports.ACCOUNT_ID = `ASTER/${ADDRESS}`;
|
|
|
14
15
|
.filter((p) => +p.positionAmt !== 0)
|
|
15
16
|
.map((p) => ({
|
|
16
17
|
position_id: p.symbol,
|
|
17
|
-
product_id: p.symbol,
|
|
18
|
+
product_id: (0, utils_1.encodePath)('PERPETUAL', p.symbol),
|
|
18
19
|
datasource_id: 'ASTER',
|
|
19
20
|
direction: p.positionSide === 'BOTH' ? (+p.positionAmt > 0 ? 'LONG' : 'SHORT') : p.positionSide,
|
|
20
21
|
volume: Math.abs(+p.positionAmt),
|
package/lib/account.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":";;;AAAA,uDAA4E;AAC5E,+CAA4C;AAC5C,+BAAyC;AAEzC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAQ,CAAC;AACxB,QAAA,UAAU,GAAG,SAAS,OAAO,EAAE,CAAC;AAE7C,IAAA,wCAAyB,EACvB,mBAAQ,CAAC,WAAW,EAAE,EACtB,kBAAU,EACV,KAAK,IAAI,EAAE;IACT,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,IAAA,sBAAgB,EAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAEtD,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,kBAAkB,GAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;IAChE,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAEjC,MAAM,SAAS,GAAG,CAAC,CAAC,SAAS;SAC1B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC;SACnC,GAAG,CACF,CAAC,CAAC,EAAa,EAAE,CAAC,CAAC;QACjB,WAAW,EAAE,CAAC,CAAC,MAAM;QACrB,UAAU,EAAE,CAAC,CAAC,MAAM;
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":";;;AAAA,uDAA4E;AAC5E,+CAA4C;AAC5C,yCAA2C;AAC3C,+BAAyC;AAEzC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAQ,CAAC;AACxB,QAAA,UAAU,GAAG,S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BAAgB;QACpC,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;KACjC,CAAC,CACH,CAAC;IACJ,OAAO;QACL,KAAK,EAAE;YACL,QAAQ,EAAE,KAAK;YACf,MAAM;YACN,IAAI;SACL;QACD,SAAS;KACV,CAAC;AACJ,CAAC,EACD,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAChC,CAAC","sourcesContent":["import { IPosition, provideAccountInfoService } from '@yuants/data-account';\nimport { Terminal } from '@yuants/protocol';\nimport { encodePath } from '@yuants/utils';\nimport { getFApiV4Account } from './api';\n\nconst ADDRESS = process.env.ADDRESS!;\nexport const ACCOUNT_ID = `ASTER/${ADDRESS}`;\n\nprovideAccountInfoService(\n Terminal.fromNodeEnv(),\n ACCOUNT_ID,\n async () => {\n const [a] = await Promise.all([getFApiV4Account({})]);\n\n const equity = +a.totalWalletBalance + +a.totalUnrealizedProfit;\n const free = +a.availableBalance;\n\n const positions = a.positions\n .filter((p) => +p.positionAmt !== 0)\n .map(\n (p): IPosition => ({\n position_id: p.symbol,\n product_id: encodePath('PERPETUAL', p.symbol),\n datasource_id: 'ASTER',\n direction: p.positionSide === 'BOTH' ? (+p.positionAmt > 0 ? 'LONG' : 'SHORT') : p.positionSide,\n volume: Math.abs(+p.positionAmt),\n free_volume: Math.abs(+p.positionAmt),\n position_price: +p.entryPrice,\n closable_price: Math.abs(+p.notional / +p.positionAmt),\n floating_profit: +p.unrealizedProfit,\n valuation: Math.abs(+p.notional),\n }),\n );\n return {\n money: {\n currency: 'USD',\n equity,\n free,\n },\n positions,\n };\n },\n { auto_refresh_interval: 1000 },\n);\n"]}
|
package/lib/api.d.ts
CHANGED
|
@@ -65,6 +65,11 @@ export declare const getFApiV2Balance: (params: {}) => Promise<{
|
|
|
65
65
|
marginAvailable: boolean;
|
|
66
66
|
updateTime: number;
|
|
67
67
|
}[]>;
|
|
68
|
+
export declare const getFApiV1TickerPrice: (params: {}) => Promise<{
|
|
69
|
+
symbol: string;
|
|
70
|
+
price: string;
|
|
71
|
+
time?: number | undefined;
|
|
72
|
+
}[]>;
|
|
68
73
|
export declare const postFApiV1Order: (params: {
|
|
69
74
|
symbol: string;
|
|
70
75
|
side: 'BUY' | 'SELL';
|
|
@@ -75,6 +80,34 @@ export declare const postFApiV1Order: (params: {
|
|
|
75
80
|
price?: number | undefined;
|
|
76
81
|
timeInForce?: "GTC" | "IOC" | "FOK" | "GTX" | "HIDDEN" | undefined;
|
|
77
82
|
}) => Promise<{}>;
|
|
83
|
+
export declare const getFApiV1OpenOrders: (params: {
|
|
84
|
+
symbol?: string | undefined;
|
|
85
|
+
}) => Promise<{
|
|
86
|
+
orderId: number;
|
|
87
|
+
clientOrderId: string;
|
|
88
|
+
price: string;
|
|
89
|
+
origQty: string;
|
|
90
|
+
executedQty: string;
|
|
91
|
+
status: string;
|
|
92
|
+
timeInForce: string;
|
|
93
|
+
type: string;
|
|
94
|
+
side: 'BUY' | 'SELL';
|
|
95
|
+
updateTime: number;
|
|
96
|
+
avgPrice: string;
|
|
97
|
+
reduceOnly?: boolean | undefined;
|
|
98
|
+
closePosition?: boolean | undefined;
|
|
99
|
+
positionSide?: "LONG" | "BOTH" | "SHORT" | undefined;
|
|
100
|
+
workingType?: string | undefined;
|
|
101
|
+
priceProtect?: boolean | undefined;
|
|
102
|
+
origType?: string | undefined;
|
|
103
|
+
stopPrice?: string | undefined;
|
|
104
|
+
symbol: string;
|
|
105
|
+
}[]>;
|
|
106
|
+
export declare const deleteFApiV1Order: (params: {
|
|
107
|
+
symbol: string;
|
|
108
|
+
orderId?: string | number | undefined;
|
|
109
|
+
origClientOrderId?: string | undefined;
|
|
110
|
+
}) => Promise<{}>;
|
|
78
111
|
/**
|
|
79
112
|
* 获取交易对信息
|
|
80
113
|
*
|
package/lib/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mapp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IpB,MAAM;gBACN,SAAS,GAAG,OAAO,GAAG,MAAM;mBACzB,MAAM;oBACL,MAAM;wBACF,MAAM;2BACH,MAAM;4BACL,MAAM;wBACV,MAAM;;;wBAER,MAAM;;;EAKe,CAAC"}
|
package/lib/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFApiV1ExchangeInfo = exports.postFApiV1Order = exports.getFApiV2Balance = exports.getFApiV4Account = void 0;
|
|
3
|
+
exports.getFApiV1ExchangeInfo = exports.deleteFApiV1Order = exports.getFApiV1OpenOrders = exports.postFApiV1Order = exports.getFApiV1TickerPrice = exports.getFApiV2Balance = exports.getFApiV4Account = void 0;
|
|
4
4
|
const utils_1 = require("./utils");
|
|
5
5
|
const API_KEY = process.env.API_KEY;
|
|
6
6
|
const SECRET_KEY = process.env.SECRET_KEY;
|
|
@@ -43,7 +43,10 @@ const createApi = (type, method, endpoint) => (params) => request(type, method,
|
|
|
43
43
|
*/
|
|
44
44
|
exports.getFApiV4Account = createApi('USER_DATA', 'GET', '/fapi/v4/account');
|
|
45
45
|
exports.getFApiV2Balance = createApi('USER_DATA', 'GET', '/fapi/v2/balance');
|
|
46
|
+
exports.getFApiV1TickerPrice = createApi('MARKET_DATA', 'GET', '/fapi/v1/ticker/price');
|
|
46
47
|
exports.postFApiV1Order = createApi('TRADE', 'POST', '/fapi/v1/order');
|
|
48
|
+
exports.getFApiV1OpenOrders = createApi('USER_DATA', 'GET', '/fapi/v1/openOrders');
|
|
49
|
+
exports.deleteFApiV1Order = createApi('TRADE', 'DELETE', '/fapi/v1/order');
|
|
47
50
|
/**
|
|
48
51
|
* 获取交易对信息
|
|
49
52
|
*
|
package/lib/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";;;AAAA,mCAAgD;AAEhD,M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AAC,CAAC;KAC3B;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,SAAS,GACb,CACE,IAAoE,EACpE,MAAc,EACd,QAAgB,EAChB,EAAE,CACJ,CAAC,MAAY,EAAE,EAAE,CACf,OAAO,CAAO,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAElD;;;;GAIG;AACU,QAAA,gBAAgB,GAAG,SAAS,CAqDvC,WAAW,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC;AAE7B,QAAA,gBAAgB,GAAG,SAAS,CAavC,WAAW,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC;AAE7B,QAAA,oBAAoB,GAAG,SAAS,CAO3C,aAAa,EAAE,KAAK,EAAE,uBAAuB,CAAC,CAAC;AAEpC,QAAA,eAAe,GAAG,SAAS,CAmBtC,OAAO,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAExB,QAAA,mBAAmB,GAAG,SAAS,CAyB1C,WAAW,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAAC;AAEhC,QAAA,iBAAiB,GAAG,SAAS,CAOxC,OAAO,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC;AAEvC;;;;GAIG;AACU,QAAA,qBAAqB,GAAG,SAAS,CAkB5C,MAAM,EAAE,KAAK,EAAE,uBAAuB,CAAC,CAAC","sourcesContent":["import { opensslEquivalentHMAC } from './utils';\n\nconst API_KEY = process.env.API_KEY!;\nconst SECRET_KEY = process.env.SECRET_KEY!;\n\nconst BASE_URL = 'https://fapi.asterdex.com';\n\nconst request = async <T>(\n type: 'NONE' | 'TRADE' | 'USER_DATA' | 'USER_STREAM' | 'MARKET_DATA',\n method: string,\n endpoint: string,\n params: any = {},\n): Promise<T> => {\n const needApiKey = type !== 'NONE';\n const needSign = type === 'TRADE' || type === 'USER_DATA';\n\n const url = new URL(BASE_URL);\n url.pathname = endpoint;\n for (const [key, value] of Object.entries(params)) {\n if (value === undefined) continue;\n url.searchParams.set(key, `${value}`);\n }\n\n if (needSign) {\n url.searchParams.set('timestamp', `${Date.now()}`);\n const msg = url.search.slice(1); // 去掉开头的 '?'\n const signature = await opensslEquivalentHMAC(msg, SECRET_KEY);\n url.searchParams.set('signature', signature);\n }\n\n console.info(url.toString());\n const res = await fetch(url.toString(), {\n method,\n headers: needApiKey\n ? {\n 'X-MBX-APIKEY': API_KEY,\n }\n : {},\n }).then((response) => response.json());\n if (res.code && res.code !== 0) {\n throw JSON.stringify(res);\n }\n return res;\n};\n\nconst createApi =\n <TReq, TRes>(\n type: 'NONE' | 'TRADE' | 'USER_DATA' | 'USER_STREAM' | 'MARKET_DATA',\n method: string,\n endpoint: string,\n ) =>\n (params: TReq) =>\n request<TRes>(type, method, endpoint, params);\n\n/**\n * 获取账户信息\n *\n * https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api_CN.md#%E8%B4%A6%E6%88%B7%E4%BF%A1%E6%81%AFv4-user_data\n */\nexport const getFApiV4Account = createApi<\n {},\n {\n feeTier: number;\n canTrade: boolean;\n canDeposit: boolean;\n canWithdraw: boolean;\n updateTime: number;\n totalInitialMargin: string;\n totalMaintMargin: string;\n totalWalletBalance: string;\n totalUnrealizedProfit: string;\n totalMarginBalance: string;\n totalPositionInitialMargin: string;\n totalOpenOrderInitialMargin: string;\n totalCrossWalletBalance: string;\n totalCrossUnPnl: string;\n availableBalance: string;\n maxWithdrawAmount: string;\n assets: {\n asset: string;\n walletBalance: string;\n unrealizedProfit: string;\n marginBalance: string;\n maintMargin: string;\n initialMargin: string;\n positionInitialMargin: string;\n openOrderInitialMargin: string;\n maxWithdrawAmount: string;\n crossWalletBalance: string;\n crossUnPnl: string;\n availableBalance: string;\n marginAvailable: boolean;\n updateTime: number;\n }[];\n positions: {\n symbol: string;\n initialMargin: string;\n maintMargin: string;\n unrealizedProfit: string;\n positionInitialMargin: string;\n openOrderInitialMargin: string;\n leverage: string;\n isolated: boolean;\n entryPrice: string;\n maxNotional: string;\n positionSide: 'BOTH' | 'LONG' | 'SHORT';\n positionAmt: string;\n notional: string;\n isolatedWallet: string;\n updateTime: number;\n }[];\n }\n>('USER_DATA', 'GET', '/fapi/v4/account');\n\nexport const getFApiV2Balance = createApi<\n {},\n {\n accountAlias: string; // 账户唯一识别码\n asset: string; // 资产\n balance: string; // 总余额\n crossWalletBalance: string; // 全仓余额\n crossUnPnl: string; // 全仓持仓未实现盈亏\n availableBalance: string; // 下单可用余额\n maxWithdrawAmount: string; // 最大可转出余额\n marginAvailable: boolean; // 是否可用作联合保证金\n updateTime: number;\n }[]\n>('USER_DATA', 'GET', '/fapi/v2/balance');\n\nexport const getFApiV1TickerPrice = createApi<\n {},\n {\n symbol: string;\n price: string;\n time?: number;\n }[]\n>('MARKET_DATA', 'GET', '/fapi/v1/ticker/price');\n\nexport const postFApiV1Order = createApi<\n {\n symbol: string;\n side: 'BUY' | 'SELL';\n positionSide?: 'BOTH' | 'LONG' | 'SHORT';\n type:\n | 'MARKET'\n | 'LIMIT'\n | 'STOP'\n | 'STOP_MARKET'\n | 'TAKE_PROFIT'\n | 'TAKE_PROFIT_MARKET'\n | 'TRAILING_STOP_MARKET';\n reduceOnly?: 'true' | 'false';\n quantity?: number;\n price?: number;\n timeInForce?: 'GTC' | 'IOC' | 'FOK' | 'GTX' | 'HIDDEN';\n },\n {}\n>('TRADE', 'POST', '/fapi/v1/order');\n\nexport const getFApiV1OpenOrders = createApi<\n {\n symbol?: string;\n },\n {\n orderId: number;\n clientOrderId: string;\n price: string;\n origQty: string;\n executedQty: string;\n status: string;\n timeInForce: string;\n type: string;\n side: 'BUY' | 'SELL';\n updateTime: number;\n avgPrice: string;\n reduceOnly?: boolean;\n closePosition?: boolean;\n positionSide?: 'BOTH' | 'LONG' | 'SHORT';\n workingType?: string;\n priceProtect?: boolean;\n origType?: string;\n stopPrice?: string;\n symbol: string;\n }[]\n>('USER_DATA', 'GET', '/fapi/v1/openOrders');\n\nexport const deleteFApiV1Order = createApi<\n {\n symbol: string;\n orderId?: string | number;\n origClientOrderId?: string;\n },\n {}\n>('TRADE', 'DELETE', '/fapi/v1/order');\n\n/**\n * 获取交易对信息\n *\n * https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api_CN.md#%E4%BA%A4%E6%98%93%E5%AF%B9%E4%BF%A1%E6%81%AF\n */\nexport const getFApiV1ExchangeInfo = createApi<\n {},\n {\n symbols: {\n symbol: string;\n status: 'TRADING' | 'BREAK' | 'HALT';\n baseAsset: string;\n quoteAsset: string;\n pricePrecision: number;\n quantityPrecision: number;\n baseAssetPrecision: number;\n quotePrecision: number;\n filters: {\n filterType: string;\n [key: string]: any;\n }[];\n }[];\n }\n>('NONE', 'GET', '/fapi/v1/exchangeInfo');\n"]}
|
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,CAAC;AACnB,OAAO,gBAAgB,CAAC;AACxB,OAAO,SAAS,CAAC;AACjB,OAAO,cAAc,CAAC;AACtB,OAAO,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,CAAC;AACnB,OAAO,gBAAgB,CAAC;AACxB,OAAO,SAAS,CAAC;AACjB,OAAO,cAAc,CAAC;AACtB,OAAO,WAAW,CAAC;AACnB,OAAO,kBAAkB,CAAC;AAC1B,OAAO,SAAS,CAAC"}
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,qBAAmB;AACnB,0BAAwB;AACxB,mBAAiB;AACjB,wBAAsB;AACtB,qBAAmB,CAAC,iCAAiC","sourcesContent":["import './account';\nimport './account-spot';\nimport './order';\nimport './order-spot';\nimport './product'; // Import the new product service\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,qBAAmB;AACnB,0BAAwB;AACxB,mBAAiB;AACjB,wBAAsB;AACtB,qBAAmB,CAAC,iCAAiC;AACrD,4BAA0B;AAC1B,mBAAiB","sourcesContent":["import './account';\nimport './account-spot';\nimport './order';\nimport './order-spot';\nimport './product'; // Import the new product service\nimport './pending-orders';\nimport './quote';\n"]}
|
package/lib/order.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const protocol_1 = require("@yuants/protocol");
|
|
4
|
+
const utils_1 = require("@yuants/utils");
|
|
4
5
|
const account_1 = require("./account");
|
|
5
6
|
const api_1 = require("./api");
|
|
6
7
|
const terminal = protocol_1.Terminal.fromNodeEnv();
|
|
7
8
|
terminal.server.provideService('SubmitOrder', { required: ['account_id'], properties: { account_id: { type: 'string', const: account_1.ACCOUNT_ID } } }, async (msg) => {
|
|
9
|
+
var _a, _b, _c, _d, _e;
|
|
8
10
|
const order = msg.req;
|
|
9
|
-
const
|
|
11
|
+
const [, decodedSymbol] = (0, utils_1.decodePath)(order.product_id);
|
|
12
|
+
if (!decodedSymbol) {
|
|
13
|
+
throw new Error(`Invalid product_id: unable to decode symbol from "${order.product_id}"`);
|
|
14
|
+
}
|
|
15
|
+
const symbol = decodedSymbol;
|
|
10
16
|
const side = { OPEN_LONG: 'BUY', OPEN_SHORT: 'SELL', CLOSE_LONG: 'SELL', CLOSE_SHORT: 'BUY' }[order.order_direction];
|
|
11
17
|
if (!side)
|
|
12
18
|
throw new Error(`Unsupported order_direction: ${order.order_direction}`);
|
|
@@ -15,14 +21,51 @@ terminal.server.provideService('SubmitOrder', { required: ['account_id'], proper
|
|
|
15
21
|
throw new Error(`Unsupported order_type: ${order.order_type}`);
|
|
16
22
|
const quantity = order.volume;
|
|
17
23
|
const price = order.price;
|
|
24
|
+
const positionSide = order.order_direction === 'OPEN_LONG' || order.order_direction === 'CLOSE_LONG'
|
|
25
|
+
? 'LONG'
|
|
26
|
+
: order.order_direction === 'OPEN_SHORT' || order.order_direction === 'CLOSE_SHORT'
|
|
27
|
+
? 'SHORT'
|
|
28
|
+
: undefined;
|
|
29
|
+
const reduceOnly = order.order_direction === 'CLOSE_LONG' || order.order_direction === 'CLOSE_SHORT' ? 'true' : undefined;
|
|
18
30
|
const timeInForce = order.order_type === 'MAKER' ? 'GTX' : order.order_type === 'LIMIT' ? 'GTC' : undefined;
|
|
19
|
-
await (0, api_1.postFApiV1Order)({
|
|
31
|
+
const res = await (0, api_1.postFApiV1Order)({
|
|
20
32
|
symbol,
|
|
21
33
|
side,
|
|
22
34
|
type,
|
|
23
35
|
quantity,
|
|
24
36
|
price,
|
|
25
37
|
timeInForce,
|
|
38
|
+
positionSide,
|
|
39
|
+
reduceOnly,
|
|
40
|
+
});
|
|
41
|
+
const orderId = (_d = (_b = (_a = res === null || res === void 0 ? void 0 : res.orderId) !== null && _a !== void 0 ? _a : res === null || res === void 0 ? void 0 : res.order_id) !== null && _b !== void 0 ? _b : (_c = res === null || res === void 0 ? void 0 : res.data) === null || _c === void 0 ? void 0 : _c.orderId) !== null && _d !== void 0 ? _d : (_e = res === null || res === void 0 ? void 0 : res.data) === null || _e === void 0 ? void 0 : _e.order_id;
|
|
42
|
+
return {
|
|
43
|
+
res: {
|
|
44
|
+
code: 0,
|
|
45
|
+
message: 'OK',
|
|
46
|
+
data: orderId ? { order_id: `${orderId}` } : undefined,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
terminal.server.provideService('CancelOrder', {
|
|
51
|
+
required: ['account_id', 'order_id', 'product_id'],
|
|
52
|
+
properties: {
|
|
53
|
+
account_id: { type: 'string', const: account_1.ACCOUNT_ID },
|
|
54
|
+
order_id: { type: ['string', 'number'] },
|
|
55
|
+
product_id: { type: 'string' },
|
|
56
|
+
},
|
|
57
|
+
}, async (msg) => {
|
|
58
|
+
const order = msg.req;
|
|
59
|
+
const [, decodedSymbol] = (0, utils_1.decodePath)(order.product_id);
|
|
60
|
+
if (!decodedSymbol) {
|
|
61
|
+
throw new Error(`Invalid product_id: unable to decode symbol from "${order.product_id}"`);
|
|
62
|
+
}
|
|
63
|
+
if (!order.order_id) {
|
|
64
|
+
throw new Error('order_id is required for CancelOrder');
|
|
65
|
+
}
|
|
66
|
+
await (0, api_1.deleteFApiV1Order)({
|
|
67
|
+
symbol: decodedSymbol,
|
|
68
|
+
orderId: order.order_id,
|
|
26
69
|
});
|
|
27
70
|
return { res: { code: 0, message: 'OK' } };
|
|
28
71
|
});
|
package/lib/order.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order.js","sourceRoot":"","sources":["../src/order.ts"],"names":[],"mappings":";;AAAA,+CAA4C;AAE5C,uCAAuC;AACvC,+
|
|
1
|
+
{"version":3,"file":"order.js","sourceRoot":"","sources":["../src/order.ts"],"names":[],"mappings":";;AAAA,+CAA4C;AAE5C,yCAA2C;AAC3C,uCAAuC;AACvC,+BAA2D;AAE3D,MAAM,QAAQ,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC;AAExC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAC5B,aAAa,EACb,EAAE,QAAQ,EAAE,CAAC,YAAY,CAAC,EAAE,UAAU,EAAE,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,oBAAU,EAAE,EAAE,EAAE,EAC/F,KAAK,EAAE,GAAG,EAAE,EAAE;;IACZ,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC;IAEtB,MAAM,CAAC,EAAE,aAAa,CAAC,GAAG,IAAA,kBAAU,EAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACvD,IAAI,CAAC,aAAa,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,qDA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C,aAAa,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,qDAAqD,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC;KAC3F;IACD,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;KACzD;IAED,MAAM,IAAA,uBAAiB,EAAC;QACtB,MAAM,EAAE,aAAa;QACrB,OAAO,EAAE,KAAK,CAAC,QAAQ;KACxB,CAAC,CAAC;IAEH,OAAO,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;AAC7C,CAAC,CACF,CAAC","sourcesContent":["import { Terminal } from '@yuants/protocol';\nimport { IOrder } from '@yuants/data-order';\nimport { decodePath } from '@yuants/utils';\nimport { ACCOUNT_ID } from './account';\nimport { deleteFApiV1Order, postFApiV1Order } from './api';\n\nconst terminal = Terminal.fromNodeEnv();\n\nterminal.server.provideService<IOrder, { order_id?: string }>(\n 'SubmitOrder',\n { required: ['account_id'], properties: { account_id: { type: 'string', const: ACCOUNT_ID } } },\n async (msg) => {\n const order = msg.req;\n\n const [, decodedSymbol] = decodePath(order.product_id);\n if (!decodedSymbol) {\n throw new Error(`Invalid product_id: unable to decode symbol from \"${order.product_id}\"`);\n }\n const symbol = decodedSymbol;\n\n const side = ({ OPEN_LONG: 'BUY', OPEN_SHORT: 'SELL', CLOSE_LONG: 'SELL', CLOSE_SHORT: 'BUY' } as const)[\n order.order_direction!\n ];\n if (!side) throw new Error(`Unsupported order_direction: ${order.order_direction}`);\n\n const type = ({ MARKET: 'MARKET', LIMIT: 'LIMIT', MAKER: 'LIMIT' } as const)[order.order_type!];\n if (!type) throw new Error(`Unsupported order_type: ${order.order_type}`);\n\n const quantity = order.volume;\n const price = order.price;\n\n const positionSide =\n order.order_direction === 'OPEN_LONG' || order.order_direction === 'CLOSE_LONG'\n ? 'LONG'\n : order.order_direction === 'OPEN_SHORT' || order.order_direction === 'CLOSE_SHORT'\n ? 'SHORT'\n : undefined;\n\n const reduceOnly =\n order.order_direction === 'CLOSE_LONG' || order.order_direction === 'CLOSE_SHORT' ? 'true' : undefined;\n\n const timeInForce =\n order.order_type === 'MAKER' ? 'GTX' : order.order_type === 'LIMIT' ? 'GTC' : undefined;\n\n const res = await postFApiV1Order({\n symbol,\n side,\n type,\n quantity,\n price,\n timeInForce,\n positionSide,\n reduceOnly,\n });\n\n const orderId =\n (res as any)?.orderId ??\n (res as any)?.order_id ??\n (res as any)?.data?.orderId ??\n (res as any)?.data?.order_id;\n\n return {\n res: {\n code: 0,\n message: 'OK',\n data: orderId ? { order_id: `${orderId}` } : undefined,\n },\n };\n },\n);\n\nterminal.server.provideService<IOrder>(\n 'CancelOrder',\n {\n required: ['account_id', 'order_id', 'product_id'],\n properties: {\n account_id: { type: 'string', const: ACCOUNT_ID },\n order_id: { type: ['string', 'number'] },\n product_id: { type: 'string' },\n },\n },\n async (msg) => {\n const order = msg.req;\n const [, decodedSymbol] = decodePath(order.product_id);\n if (!decodedSymbol) {\n throw new Error(`Invalid product_id: unable to decode symbol from \"${order.product_id}\"`);\n }\n if (!order.order_id) {\n throw new Error('order_id is required for CancelOrder');\n }\n\n await deleteFApiV1Order({\n symbol: decodedSymbol,\n orderId: order.order_id,\n });\n\n return { res: { code: 0, message: 'OK' } };\n },\n);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pending-orders.d.ts","sourceRoot":"","sources":["../src/pending-orders.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const data_order_1 = require("@yuants/data-order");
|
|
4
|
+
const protocol_1 = require("@yuants/protocol");
|
|
5
|
+
const utils_1 = require("@yuants/utils");
|
|
6
|
+
const account_1 = require("./account");
|
|
7
|
+
const api_1 = require("./api");
|
|
8
|
+
const terminal = protocol_1.Terminal.fromNodeEnv();
|
|
9
|
+
const resolveOrderDirection = (asterOrder) => {
|
|
10
|
+
const reduceOnly = asterOrder.reduceOnly || asterOrder.closePosition;
|
|
11
|
+
if (asterOrder.positionSide === 'LONG') {
|
|
12
|
+
return asterOrder.side === 'BUY' ? 'OPEN_LONG' : 'CLOSE_LONG';
|
|
13
|
+
}
|
|
14
|
+
if (asterOrder.positionSide === 'SHORT') {
|
|
15
|
+
return asterOrder.side === 'BUY' ? 'CLOSE_SHORT' : 'OPEN_SHORT';
|
|
16
|
+
}
|
|
17
|
+
if (reduceOnly) {
|
|
18
|
+
return asterOrder.side === 'BUY' ? 'CLOSE_SHORT' : 'CLOSE_LONG';
|
|
19
|
+
}
|
|
20
|
+
return asterOrder.side === 'BUY' ? 'OPEN_LONG' : 'OPEN_SHORT';
|
|
21
|
+
};
|
|
22
|
+
(0, data_order_1.providePendingOrdersService)(terminal, account_1.ACCOUNT_ID, async () => {
|
|
23
|
+
const orders = (await (0, api_1.getFApiV1OpenOrders)({}));
|
|
24
|
+
return orders.map((order) => {
|
|
25
|
+
const volume = Number(order.origQty);
|
|
26
|
+
const tradedVolume = Number(order.executedQty);
|
|
27
|
+
const price = Number(order.price);
|
|
28
|
+
const avgPrice = Number(order.avgPrice);
|
|
29
|
+
const mapped = {
|
|
30
|
+
order_id: `${order.orderId}`,
|
|
31
|
+
account_id: account_1.ACCOUNT_ID,
|
|
32
|
+
product_id: (0, utils_1.encodePath)('PERPETUAL', order.symbol),
|
|
33
|
+
order_type: order.type,
|
|
34
|
+
order_direction: resolveOrderDirection(order),
|
|
35
|
+
volume: Number.isFinite(volume) ? volume : 0,
|
|
36
|
+
price: Number.isFinite(price) ? price : undefined,
|
|
37
|
+
submit_at: order.updateTime,
|
|
38
|
+
traded_volume: Number.isFinite(tradedVolume) ? tradedVolume : undefined,
|
|
39
|
+
traded_price: Number.isFinite(avgPrice) && avgPrice > 0 ? avgPrice : undefined,
|
|
40
|
+
order_status: order.status,
|
|
41
|
+
};
|
|
42
|
+
return mapped;
|
|
43
|
+
});
|
|
44
|
+
}, { auto_refresh_interval: 2000 });
|
|
45
|
+
//# sourceMappingURL=pending-orders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pending-orders.js","sourceRoot":"","sources":["../src/pending-orders.ts"],"names":[],"mappings":";;AAAA,mDAAyE;AACzE,+CAA4C;AAC5C,yCAA2C;AAC3C,uCAAuC;AACvC,+BAA4C;AAE5C,MAAM,QAAQ,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC;AAoBxC,MAAM,qBAAqB,GAAG,CAAC,UAA2B,EAAkB,EAAE;IAC5E,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,IAAI,UAAU,CAAC,aAAa,CAAC;IAErE,IAAI,UAAU,CAAC,YAAY,KAAK,MAAM,EAAE;QACtC,OAAO,UAAU,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC;KAC/D;IACD,IAAI,UAAU,CAAC,YAAY,KAAK,OAAO,EAAE;QACvC,OAAO,UAAU,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC;KACjE;IACD,IAAI,UAAU,EAAE;QACd,OAAO,UAAU,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC;KACjE;IACD,OAAO,UAAU,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC;AAChE,CAAC,CAAC;AAEF,IAAA,wCAA2B,EACzB,QAAQ,EACR,oBAAU,EACV,KAAK,IAAI,EAAE;IACT,MAAM,MAAM,GAAG,CAAC,MAAM,IAAA,yBAAmB,EAAC,EAAE,CAAC,CAAsB,CAAC;IACpE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC1B,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odePath } from '@yuants/utils';\nimport { ACCOUNT_ID } from './account';\nimport { getFApiV1OpenOrders } from './api';\n\nconst terminal = Terminal.fromNodeEnv();\n\ntype OrderDirection = 'OPEN_LONG' | 'OPEN_SHORT' | 'CLOSE_LONG' | 'CLOSE_SHORT';\n\ninterface IAsterOpenOrder {\n orderId: number;\n symbol: string;\n side: 'BUY' | 'SELL';\n positionSide?: 'BOTH' | 'LONG' | 'SHORT';\n reduceOnly?: boolean;\n closePosition?: boolean;\n type: string;\n origQty: string;\n executedQty: string;\n price: string;\n avgPrice: string;\n status: string;\n updateTime: number;\n}\n\nconst resolveOrderDirection = (asterOrder: IAsterOpenOrder): OrderDirection => {\n const reduceOnly = asterOrder.reduceOnly || asterOrder.closePosition;\n\n if (asterOrder.positionSide === 'LONG') {\n return asterOrder.side === 'BUY' ? 'OPEN_LONG' : 'CLOSE_LONG';\n }\n if (asterOrder.positionSide === 'SHORT') {\n return asterOrder.side === 'BUY' ? 'CLOSE_SHORT' : 'OPEN_SHORT';\n }\n if (reduceOnly) {\n return asterOrder.side === 'BUY' ? 'CLOSE_SHORT' : 'CLOSE_LONG';\n }\n return asterOrder.side === 'BUY' ? 'OPEN_LONG' : 'OPEN_SHORT';\n};\n\nprovidePendingOrdersService(\n terminal,\n ACCOUNT_ID,\n async () => {\n const orders = (await getFApiV1OpenOrders({})) as IAsterOpenOrder[];\n return orders.map((order) => {\n const volume = Number(order.origQty);\n const tradedVolume = Number(order.executedQty);\n const price = Number(order.price);\n const avgPrice = Number(order.avgPrice);\n\n const mapped: IOrder = {\n order_id: `${order.orderId}`,\n account_id: ACCOUNT_ID,\n product_id: encodePath('PERPETUAL', order.symbol),\n order_type: order.type,\n order_direction: resolveOrderDirection(order),\n volume: Number.isFinite(volume) ? volume : 0,\n price: Number.isFinite(price) ? price : undefined,\n submit_at: order.updateTime,\n traded_volume: Number.isFinite(tradedVolume) ? tradedVolume : undefined,\n traded_price: Number.isFinite(avgPrice) && avgPrice > 0 ? avgPrice : undefined,\n order_status: order.status,\n };\n\n return mapped;\n });\n },\n { auto_refresh_interval: 2000 },\n);\n"]}
|
package/lib/quote.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../src/quote.ts"],"names":[],"mappings":""}
|
package/lib/quote.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const protocol_1 = require("@yuants/protocol");
|
|
4
|
+
const sql_1 = require("@yuants/sql");
|
|
5
|
+
const utils_1 = require("@yuants/utils");
|
|
6
|
+
const rxjs_1 = require("rxjs");
|
|
7
|
+
const api_1 = require("./api");
|
|
8
|
+
const terminal = protocol_1.Terminal.fromNodeEnv();
|
|
9
|
+
const quote$ = (0, rxjs_1.defer)(() => (0, api_1.getFApiV1TickerPrice)({})).pipe((0, rxjs_1.mergeMap)((tickers) => tickers || []), (0, rxjs_1.map)((ticker) => {
|
|
10
|
+
var _a;
|
|
11
|
+
return ({
|
|
12
|
+
datasource_id: 'ASTER',
|
|
13
|
+
product_id: (0, utils_1.encodePath)('PERPETUAL', ticker.symbol),
|
|
14
|
+
last_price: `${ticker.price}`,
|
|
15
|
+
bid_price: `${ticker.price}`,
|
|
16
|
+
ask_price: `${ticker.price}`,
|
|
17
|
+
updated_at: new Date((_a = ticker.time) !== null && _a !== void 0 ? _a : Date.now()).toISOString(),
|
|
18
|
+
});
|
|
19
|
+
}), (0, rxjs_1.repeat)({ delay: 1000 }), (0, rxjs_1.retry)({ delay: 5000 }), (0, rxjs_1.shareReplay)({ bufferSize: 1, refCount: true }));
|
|
20
|
+
if (process.env.WRITE_QUOTE_TO_SQL === 'true') {
|
|
21
|
+
quote$
|
|
22
|
+
.pipe((0, sql_1.writeToSQL)({
|
|
23
|
+
terminal,
|
|
24
|
+
tableName: 'quote',
|
|
25
|
+
writeInterval: 1000,
|
|
26
|
+
conflictKeys: ['datasource_id', 'product_id'],
|
|
27
|
+
}))
|
|
28
|
+
.subscribe();
|
|
29
|
+
terminal.channel.publishChannel('quote', { pattern: '^ASTER/' }, (channel_id) => {
|
|
30
|
+
const [datasourceId, productId] = (0, utils_1.decodePath)(channel_id);
|
|
31
|
+
if (!datasourceId || !productId) {
|
|
32
|
+
throw new Error(`Invalid channel_id: ${channel_id}`);
|
|
33
|
+
}
|
|
34
|
+
return quote$.pipe((0, rxjs_1.filter)((quote) => quote.product_id === productId));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=quote.js.map
|
package/lib/quote.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quote.js","sourceRoot":"","sources":["../src/quote.ts"],"names":[],"mappings":";;AACA,+CAA4C;AAC5C,qCAAyC;AACzC,yCAAuD;AACvD,+BAAgF;AAChF,+BAA6C;AAE7C,MAAM,QAAQ,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC;AAExC,MAAM,MAAM,GAAG,IAAA,YAAK,EAAC,GAAG,EAAE,CAAC,IAAA,0BAAoB,EAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CACvD,IAAA,eAAQ,EAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,IAAI,EAAE,CAAC,EACpC,IAAA,UAAG,EACD,CAAC,MAAM,EAAmB,EAAE;;IAAC,OAAA,CAAC;QAC5B,aAAa,EAAE,OAAO;QACtB,UAAU,EAAE,IAAA,kBAAU,EAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC;QAClD,UAAU,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE;QAC7B,SAAS,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE;QAC5B,SAAS,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE;QAC5B,UAAU,EAAE,IAAI,IAAI,CAAC,MAAA,MAAM,CAAC,IAAI,mCAAI,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,WAAW,EAAE;KAC9D,CAAC,CAAA;CAAA,CACH,EACD,IAAA,aAAM,EAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EACvB,IAAA,YAAK,EAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EACtB,IAAA,kBAAW,EAAC,EAAE,UAAU,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAC/C,CAAC;AAEF,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,KAAK,MAAM,EAAE;IAC7C,MAAM;SACH,IAAI,CACH,IAAA,gBAAU,EAAC;QACT,QAAQ;QACR,SAAS,EAAE,OAAO;QAClB,aAAa,EAAE,IAAI;QACnB,YAAY,EAAE,CAAC,eAAe,EAAE,YAAY,CAAC;KAC9C,CAAC,CACH;SACA,SAAS,EAAE,CAAC;IAEf,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,EAAE;QAC9E,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,GAAG,IAAA,kBAAU,EAAC,UAAU,CAAC,CAAC;QACzD,IAAI,CAAC,YAAY,IAAI,CAAC,SAAS,EAAE;YAC/B,MAAM,IAAI,KAAK,CAAC,uBAAuB,UAAU,EAAE,CAAC,CAAC;SACtD;QACD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAA,aAAM,EAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;CACJ","sourcesContent":["import type { IQuote } from '../../../libraries/data-quote/lib';\nimport { Terminal } from '@yuants/protocol';\nimport { writeToSQL } from '@yuants/sql';\nimport { decodePath, encodePath } from '@yuants/utils';\nimport { defer, filter, map, mergeMap, repeat, retry, shareReplay } from 'rxjs';\nimport { getFApiV1TickerPrice } from './api';\n\nconst terminal = Terminal.fromNodeEnv();\n\nconst quote$ = defer(() => getFApiV1TickerPrice({})).pipe(\n mergeMap((tickers) => tickers || []),\n map(\n (ticker): Partial<IQuote> => ({\n datasource_id: 'ASTER',\n product_id: encodePath('PERPETUAL', ticker.symbol),\n last_price: `${ticker.price}`,\n bid_price: `${ticker.price}`,\n ask_price: `${ticker.price}`,\n updated_at: new Date(ticker.time ?? Date.now()).toISOString(),\n }),\n ),\n repeat({ delay: 1000 }),\n retry({ delay: 5000 }),\n shareReplay({ bufferSize: 1, refCount: true }),\n);\n\nif (process.env.WRITE_QUOTE_TO_SQL === 'true') {\n quote$\n .pipe(\n writeToSQL({\n terminal,\n tableName: 'quote',\n writeInterval: 1000,\n conflictKeys: ['datasource_id', 'product_id'],\n }),\n )\n .subscribe();\n\n terminal.channel.publishChannel('quote', { pattern: '^ASTER/' }, (channel_id) => {\n const [datasourceId, productId] = decodePath(channel_id);\n if (!datasourceId || !productId) {\n throw new Error(`Invalid channel_id: ${channel_id}`);\n }\n return quote$.pipe(filter((quote) => quote.product_id === productId));\n });\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuants/vendor-aster",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"bin": "lib/cli.js",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"@yuants/data-order": "0.3.8",
|
|
20
20
|
"@yuants/data-interest-rate": "0.1.38",
|
|
21
21
|
"@yuants/transfer": "0.2.29",
|
|
22
|
+
"@yuants/data-quote": "0.2.33",
|
|
22
23
|
"rxjs": "~7.5.6"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
package/temp/package-deps.json
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
{
|
|
2
|
-
"apps/vendor-aster/CHANGELOG.json": "
|
|
3
|
-
"apps/vendor-aster/CHANGELOG.md": "
|
|
2
|
+
"apps/vendor-aster/CHANGELOG.json": "02827ec15e869b41bf0d6a8e7664f290c68041f2",
|
|
3
|
+
"apps/vendor-aster/CHANGELOG.md": "2ed00719240c330b4481a8fb016bdc5a800f9c80",
|
|
4
4
|
"apps/vendor-aster/config/jest.config.json": "4bb17bde3ee911163a3edb36a6eb71491d80b1bd",
|
|
5
5
|
"apps/vendor-aster/config/rig.json": "f6c7b5537dc77a3170ba9f008bae3b6c3ee11956",
|
|
6
6
|
"apps/vendor-aster/config/typescript.json": "854907e8a821f2050f6533368db160c649c25348",
|
|
7
|
-
"apps/vendor-aster/package.json": "
|
|
7
|
+
"apps/vendor-aster/package.json": "5d687cf5eb79edf4ba4e4ff8db2ce9a7705089c7",
|
|
8
8
|
"apps/vendor-aster/src/account-spot.ts": "e5162a9c7f00fde4d1f143c3f85ef04ae8877b56",
|
|
9
|
-
"apps/vendor-aster/src/account.ts": "
|
|
10
|
-
"apps/vendor-aster/src/api.ts": "
|
|
9
|
+
"apps/vendor-aster/src/account.ts": "6163105ce1de2d1b9747b8080936357bbcada559",
|
|
10
|
+
"apps/vendor-aster/src/api.ts": "a6f88637677a023c93e3072ed527beec9aec5803",
|
|
11
11
|
"apps/vendor-aster/src/cli.ts": "9bf6b5559a6c6f33da20e74cc6c5d702c60ec891",
|
|
12
|
-
"apps/vendor-aster/src/index.ts": "
|
|
12
|
+
"apps/vendor-aster/src/index.ts": "3412ffd7a3b3e913bb48ccf972c4baa575e51b97",
|
|
13
13
|
"apps/vendor-aster/src/order-spot.ts": "e17f728347f3c49d4311493a47b1ed72d5a29f37",
|
|
14
|
-
"apps/vendor-aster/src/order.ts": "
|
|
14
|
+
"apps/vendor-aster/src/order.ts": "f4c905309ffabf2122bf7079b4f5faf6c1e3f744",
|
|
15
|
+
"apps/vendor-aster/src/pending-orders.ts": "e047fcb2f9098583856513677f90b2e3d6e26441",
|
|
15
16
|
"apps/vendor-aster/src/product.ts": "665becdfc3aa0f9239d008831b1304a17edb01dc",
|
|
17
|
+
"apps/vendor-aster/src/quote.ts": "51d0d01ca15d0202afa8c6d4be7fc3528113ef62",
|
|
16
18
|
"apps/vendor-aster/src/sapi.ts": "40214de87500f9fb6647c11d3999e0e449a6fa0b",
|
|
17
19
|
"apps/vendor-aster/src/utils.ts": "f732922ea47951ddf0889bba9a70fd8e270cae2f",
|
|
18
20
|
"apps/vendor-aster/tsconfig.json": "81da8f78196974b5d15da0edb6b2d9f48641063c",
|
|
19
|
-
"apps/vendor-aster/.rush/temp/shrinkwrap-deps.json": "
|
|
21
|
+
"apps/vendor-aster/.rush/temp/shrinkwrap-deps.json": "079d5f6c02db17fd629cf5af455cb4544478f976",
|
|
20
22
|
"libraries/protocol/temp/package-deps.json": "b798d038ca8307c5c1da842400ce9b64a81b8bb4",
|
|
21
23
|
"libraries/data-account/temp/package-deps.json": "927914a42877bd5e5eece519e427c0b4743f5e2d",
|
|
22
24
|
"libraries/utils/temp/package-deps.json": "00132af02f003a95edfc2b9e1e9ec298a59fb89c",
|
|
@@ -27,6 +29,7 @@
|
|
|
27
29
|
"libraries/data-order/temp/package-deps.json": "61701a3a0578d8c0bc50dfda8f54349c19cf1521",
|
|
28
30
|
"libraries/data-interest-rate/temp/package-deps.json": "c349130b331ab41396ac04722cb5463f0ce41a1c",
|
|
29
31
|
"libraries/transfer/temp/package-deps.json": "bdb70a9e16eed15573c12f44a97b136d4df0439b",
|
|
32
|
+
"libraries/data-quote/temp/package-deps.json": "aceb6fb51f0cd42c513e9213de9f55f06d2973f3",
|
|
30
33
|
"libraries/extension/temp/package-deps.json": "baf08ab93278543b640b68f31261ffd3705bd9e7",
|
|
31
34
|
"tools/toolkit/temp/package-deps.json": "3bef053db16659f0cdaceea64c8a8580c0131633"
|
|
32
35
|
}
|