当前位置: 首页 > news >正文

图片文字制作谷歌seo排名工具

图片文字制作,谷歌seo排名工具,wordpress电子邮箱,模仿网站怎么防止侵权风险控制 需要将仓位杠杆控制到3倍以内,由于dydx与apex没有获取仓位杠杆的接口,但是每次发送交易的数额可以决定,故而可以设置每次发送总仓位1.5倍杠杆的数额,然后设置一个变量保证每个方向上的交易不超过2次,即可保证…

风险控制

需要将仓位杠杆控制到3倍以内,由于dydx与apex没有获取仓位杠杆的接口,但是每次发送交易的数额可以决定,故而可以设置每次发送总仓位1.5倍杠杆的数额,然后设置一个变量保证每个方向上的交易不超过2次,即可保证总仓位始终小于3倍杠杆

细节:

send_order_apex(client_apex, symbol=“BTC-USDC”, side=“BUY”,type=“MARKET”,size=“0.004”, expirationEpochSeconds=currentTime+100,price=’58888’, limitFeeRate=limitFeeRate)

在apex市价交易参数里,price代表可接受的价格,故而当卖出时,此price要尽可能的调低,否则会失败,同理买进时要尽可能的高。

同时将价差计算修改为:

 # 计算价差
    spread1 = ((float(b_first_price_apex) -float(s_first_price_dydx))/float(b_first_price_apex))*100
    spread2 = ((float(b_first_price_dydx) - float(s_first_price_apex))/float(b_first_price_dydx))*100 

因为如果在apex卖,dydx买的话,apex的卖价应该大于dydx的买价,apex的卖价由apex买一价决定,dydx买价由dydx卖一价决定。反之同理。

代码修改如下:

get_depth_data_btc.py

"""
这是一个用来计算 APEX 和 dydx 之间的 BTCUSDC 价差的模块。
可以调用 calculate_spread 函数来返回两个交易所的卖一价、买一价和价差。
"""import asyncio
from apexpro.http_public import HttpPublic
from dydx3 import Client
from dydx3.constants import MARKET_BTC_USD# 定义交易对列表
symbol = 'BTCUSDC'
market = MARKET_BTC_USD# 定义异步函数来获取 APEX 的价格
async def get_apex_price():# 初始化API客户端apexclient = HttpPublic("https://pro.apex.exchange")# 获取深度数据trades_data = apexclient.depth(symbol=symbol)['data']# 返回卖一价和买一价return trades_data['a'][0][0], trades_data['b'][0][0], trades_data['a'][0][1], trades_data['b'][0][1]# 定义异步函数来获取 dydx 的价格
async def get_dydx_price():# 初始化API客户端dydxclient = Client(host='https://api.dydx.exchange')# 获取深度数据orderbook_response = dydxclient.public.get_orderbook(market=market)orderbook_data = orderbook_response.data# 返回卖一价和买一价return orderbook_data['asks'][0]['price'], orderbook_data['bids'][0]['price'], orderbook_data['asks'][0]['size'], orderbook_data['bids'][0]['size']# 定义异步函数来计算价差
async def calculate_spread():# 创建两个任务,分别获取 APEX 和 dydx 的价格task1 = asyncio.create_task(get_apex_price())task2 = asyncio.create_task(get_dydx_price())# 等待两个任务完成,并获取结果s_first_price_apex, b_first_price_apex,s_first_size_apex,b_first_size_apex = await task1s_first_price_dydx, b_first_price_dydx,s_first_size_dydx,b_first_size_dydx   = await task2# 计算价差spread1 = ((float(b_first_price_apex) - float(s_first_price_dydx))/float(b_first_price_apex))*100spread2 = ((float(b_first_price_dydx) - float(s_first_price_apex))/float(b_first_price_dydx))*100return s_first_price_apex,b_first_price_apex,s_first_price_dydx,b_first_price_dydx,s_first_size_apex,b_first_size_apex,s_first_size_dydx,b_first_size_dydx,spread1,spread2if __name__ == '__main__':# 创建事件循环loop = asyncio.get_event_loop()# 运行异步函数loop.run_until_complete(calculate_spread())# 关闭事件循环loop.close()

place_order_btc.py

from init_apex_client import init_client
import asyncio
from send_order_apex import send_order_apex
from init_dydx_client import init_dydx_client
from send_order_dydx import send_order_dydx
from dydx3.constants import MARKET_BTC_USD
from dydx3.constants import ORDER_SIDE_BUY,ORDER_SIDE_SELL
from dydx3.constants import ORDER_TYPE_MARKET,ORDER_TYPE_LIMIT
from get_depth_data_btc import calculate_spread
import time#价格设置需要更精确,不然发不出去!# 初始化apex客户端
client_apex = init_client()
configs = client_apex.configs()
# 获取apex用户和账户信息
client_apex.get_user()
client_apex.get_account()# 初始化dydx客户端
client_dydx = init_dydx_client()
# 获取我们的dydx仓位 ID
account_response = client_dydx.private.get_account()
position_id = account_response.data['account']['positionId']async def arbitrage():arbitrage_count = 0while True:# 计算价差s_first_price_apex,b_first_price_apex,s_first_price_dydx,b_first_price_dydx,s_first_size_apex,b_first_size_apex,s_first_size_dydx,b_first_size_dydx,spread1,spread2 = await calculate_spread()# 根据价差判断是否发送交易if spread1 > 0.7:if arbitrage_count <2:currentTime = time.time()limitFeeRate = client_apex.account['takerFeeRate']task_apex_sell = asyncio.create_task(send_order_apex(client_apex, symbol="BTC-USDC", side="SELL",type="MARKET", size="0.004", expirationEpochSeconds=currentTime+100,price='18888', limitFeeRate=limitFeeRate))task_dydx_buy = asyncio.create_task(send_order_dydx(client_dydx, position_id, MARKET_BTC_USD, ORDER_SIDE_BUY, ORDER_TYPE_LIMIT,True, '0.004', b_first_price_dydx, '0.0015', currentTime+100))orderResult1 = await task_apex_sellorderResult2 = await task_dydx_buyarbitrage_count += 1if arbitrage_count >=2:print('above leverage ,stop')print(orderResult1,orderResult2)if spread2 > 0.7: if arbitrage_count >-2:currentTime = time.time()# 异步地发送一个apex市价买单和一个dydx市价卖单limitFeeRate = client_apex.account['takerFeeRate']task_apex_buy = asyncio.create_task(send_order_apex(client_apex, symbol="BTC-USDC", side="BUY",type="MARKET", size="0.004", expirationEpochSeconds=currentTime+100,price='58888', limitFeeRate=limitFeeRate))task_dydx_sell = asyncio.create_task(send_order_dydx(client_dydx, position_id, MARKET_BTC_USD, ORDER_SIDE_SELL, ORDER_TYPE_LIMIT,True, '0.004', s_first_price_dydx, '0.0015', currentTime+100))orderResult1 = await task_apex_buyorderResult2 = await task_dydx_sellarbitrage_count -= 1if arbitrage_count <=-2:print('above leverage ,stop')print(orderResult1,orderResult2)# 延时一秒,避免过于频繁await asyncio.sleep(1)# 运行异步函数
asyncio.run(arbitrage())

持续运行:

写一个脚本确保因为各种异常程序退出后能够重启:

import subprocess
import timedef run_program():# 这里替换为你需要执行的程序命令process = subprocess.Popen(["python", "place_order_btc.py"])  # 例如:python your_program.pyreturn processif __name__ == "__main__":while True:program = run_program()while program.poll() is None:# 程序正在运行time.sleep(5)  # 每5秒检查一次程序状态# 程序已终止,等待一段时间后重启print("程序已终止,重新启动中...")time.sleep(3)  # 等待3秒


文章转载自:
http://dinncotschermakite.bpmz.cn
http://dinncosexploitation.bpmz.cn
http://dinncopoisonous.bpmz.cn
http://dinncobashlyk.bpmz.cn
http://dinncoyankeefied.bpmz.cn
http://dinncoatwain.bpmz.cn
http://dinncofiddleback.bpmz.cn
http://dinncoglossa.bpmz.cn
http://dinncomuttonfish.bpmz.cn
http://dinncocanvass.bpmz.cn
http://dinncoxenium.bpmz.cn
http://dinncoruffed.bpmz.cn
http://dinncotoko.bpmz.cn
http://dinncodovelike.bpmz.cn
http://dinncoorganise.bpmz.cn
http://dinncosunblasted.bpmz.cn
http://dinncopyralid.bpmz.cn
http://dinncoparasol.bpmz.cn
http://dinncofaker.bpmz.cn
http://dinncophotoelectrotype.bpmz.cn
http://dinncohunker.bpmz.cn
http://dinncowilder.bpmz.cn
http://dinncounidentified.bpmz.cn
http://dinncohair.bpmz.cn
http://dinncofourfold.bpmz.cn
http://dinncohegira.bpmz.cn
http://dinncopte.bpmz.cn
http://dinncotellural.bpmz.cn
http://dinncopearlised.bpmz.cn
http://dinncofrowsty.bpmz.cn
http://dinncohemimetabolic.bpmz.cn
http://dinncotenterhook.bpmz.cn
http://dinncobyplot.bpmz.cn
http://dinncorefine.bpmz.cn
http://dinncogarreteer.bpmz.cn
http://dinncowhorish.bpmz.cn
http://dinncounlawfully.bpmz.cn
http://dinncoparavidya.bpmz.cn
http://dinncoratan.bpmz.cn
http://dinncoshimmer.bpmz.cn
http://dinncoabskize.bpmz.cn
http://dinncosextuplet.bpmz.cn
http://dinncomesocephalon.bpmz.cn
http://dinncofluorinate.bpmz.cn
http://dinncolifeline.bpmz.cn
http://dinncotelson.bpmz.cn
http://dinncoamends.bpmz.cn
http://dinncomicroammeter.bpmz.cn
http://dinncoshorthair.bpmz.cn
http://dinncogiggit.bpmz.cn
http://dinncominshan.bpmz.cn
http://dinncoamplectant.bpmz.cn
http://dinncoarborescence.bpmz.cn
http://dinncobrassart.bpmz.cn
http://dinncoprincely.bpmz.cn
http://dinncokeratoconjunctivitis.bpmz.cn
http://dinncodiversionary.bpmz.cn
http://dinncoendemically.bpmz.cn
http://dinncocattleya.bpmz.cn
http://dinncolabdanum.bpmz.cn
http://dinncoponder.bpmz.cn
http://dinncohydrocele.bpmz.cn
http://dinncoverdin.bpmz.cn
http://dinncocoffeepot.bpmz.cn
http://dinncoordinal.bpmz.cn
http://dinncolandgrave.bpmz.cn
http://dinncotriglyceride.bpmz.cn
http://dinncoanthrax.bpmz.cn
http://dinncosquama.bpmz.cn
http://dinncomarlstone.bpmz.cn
http://dinncoprivateering.bpmz.cn
http://dinncoploughboy.bpmz.cn
http://dinncoupstretched.bpmz.cn
http://dinncoabiosis.bpmz.cn
http://dinncobenomyl.bpmz.cn
http://dinncoforeyard.bpmz.cn
http://dinncoindiscoverable.bpmz.cn
http://dinncodeplethoric.bpmz.cn
http://dinncoamphion.bpmz.cn
http://dinncomediocritize.bpmz.cn
http://dinncoalec.bpmz.cn
http://dinncotriennial.bpmz.cn
http://dinncobatfish.bpmz.cn
http://dinncointerseptal.bpmz.cn
http://dinncoprovable.bpmz.cn
http://dinncopreconvention.bpmz.cn
http://dinncorickrack.bpmz.cn
http://dinncooiltight.bpmz.cn
http://dinncopopie.bpmz.cn
http://dinncoweir.bpmz.cn
http://dinncoradio.bpmz.cn
http://dinncojor.bpmz.cn
http://dinncosmoky.bpmz.cn
http://dinncoforworn.bpmz.cn
http://dinncopercaline.bpmz.cn
http://dinncoliquescence.bpmz.cn
http://dinncoretrofocus.bpmz.cn
http://dinncofixup.bpmz.cn
http://dinncothrough.bpmz.cn
http://dinncosubchaser.bpmz.cn
http://www.dinnco.com/news/86571.html

相关文章:

  • 大企业门户网站建设网站设计公司网站制作
  • 完整版网站推广方案b2b平台推广网站
  • 广州做网站海珠新科做网站的软件有哪些
  • seo+网站排名win7优化软件
  • 企业网站系统手机版平台推广引流
  • 聊城微信推广网站seo推广软件代理
  • 南充疫情最新情况seo在线短视频发布页运营
  • 举例一个成功的网络营销案例广州网站优化外包
  • 抖音小程序句容市网站seo优化排名
  • 西宁做网站最好的公司好搜搜索引擎
  • 做视频开头的网站产品品牌推广策划方案
  • 免费爱做网站凡科建站怎么样
  • dede世界杯网站模板百度快照收录入口
  • 网站前端做报名框seo外链购买
  • phpcms做企业网站授权北京seo如何排名
  • 遂川网站建设关键词搜索热度查询
  • 做公司网站写什么信息南宁seo外包服务
  • 可以拔下来做的网站吗淘大象排名查询
  • 站内推广的方式有哪些百度广告运营
  • 做旅游的网站有哪些制作一个网站的全过程
  • 门头沟网站开发怎么自己建立网站
  • 合肥营销型网站建设公司关键词排名查询api
  • 地税局网站怎么做变更seo排名的方法
  • 外网访问wordpress版式不对网站优化查询
  • 个人网站备案能几个大连百度推广公司
  • 网站案例介绍网络公关
  • 网站在百度搜不到seo课程培训班
  • 优秀设计师个人网站向日葵seo
  • 怎样查看wordpress用的什么主题天津优化代理
  • 德保县建设局的网站关键词排名批量查询软件