yq-okex-api-service
v1.0.2
Published
1. attention ! just suport the spring-ioc framework.
Downloads
4
Readme
yq-okex-api-service
intruoduce
- attention ! just suport the spring-ioc framework.
install
npm instlal yq-okex-api-service
usage
1.set the configuration file
file path: ${Project}/resource/app-dev.yaml
basic config:
Spring-ioc:
log:
state: on
level: info
YqOkexApiService:
API_KEY: e345345ad8-4b0c-8c49-c1b850bdbf9a
API_SECRET: CFD9E52342340889546456EBCBC7CA2EDE1
API_PASS: 12456e245645612312312312323!~
2. load email module at launch.
const {SpringBoot} = require("spring-ioc")
const {YqOkexApiServiceScaner} = require("./spring_extends")
new SpringBoot({
rootPath:__dirname,
srcList:["./demo"],
moduleList:[YqOkexApiServiceScaner("./spring_extends")]
}).start();
3. call in the spring container!
const {wait} = require('zcutil-cli-input')
//@SpringBoot
class Application {
//@Autowired
yqOkexApiService;
log;
//查询价格
async testSearchPrice(){
const coin = "BTC-USDT"
const log = this.log.method("testSearchPrice")
log.info(`请求价格:${coin}`);
const price = await this.yqOkexApiService.getTicker(coin)
log.info(`${coin}:${price}`)
}
//查询余额
async testBalance(coinName){
const log = this.log.method("testBalance")
log.info(`开始查询${coinName}余额`)
const balance = await this.yqOkexApiService.getBalance(coinName)
log.info(`${coinName}:${balance}`)
}
//测试购买4U usdt
async testBuyBTC(){
const log = this.log.method("testBuyBTC")
log.info(`测试购买3U BTC`)
const result = await this.yqOkexApiService.buy('BTC-USDT',3)
log.info(`服务器返回:${JSON.stringify(result)}`)
}
async testSell(size){
const log = this.log.method("testSell")
log.info(`出售BTC 数量:${size}`)
const result = await this.yqOkexApiService.sell('BTC-USDT',size)
log.info(`服务器返回:${JSON.stringify(result)}`)
}
async main(){
const panic = await this.yqOkexApiService.getMarketSentiment();
this.log.info(`恐慌情绪:${panic}`)
//查询价格
await this.testSearchPrice();
//查询余额
await this.testBalance("BTC");
//测试购买
await this.testBuyBTC();
this.log.info("等待2秒!")
await wait(2)
//重新查询余额
await this.testBalance("BTC");
//测试出售
await this.testSell(0.0001)
this.log.info("等待2秒!")
await wait(2)
//重新查询余额
await this.testBalance("BTC");
}
}
module.exports = { Application }