Python Coinbase Pro API不执行或按市场订单退货

2024-09-28 01:23:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用的是coinbase pro API,在尝试下市场订单时,它不会执行或返回基于文档的任何文本

# Modules

import env
import cbpro

# API Details

APIKey = env.APIKey 
APISecret = env.APISecret
APIPass = env.APIPass 
BTCID = env.BTCID 
client = cbpro.AuthenticatedClient(APIKey, APISecret, APIPass)

def test1():

    client.buy(product_id='BTC-GBP', order_type="market",funds=5.00)

test1()

def test2():

    client.place_market_order(product_id='BTC-GBP',side='buy',funds=5.00)

test2()

我尝试了两种不同的方法,但结果仍然相同。有没有人有这个模块的经验

资料来源:

https://pypi.org/project/cbpro/

https://docs.pro.coinbase.com/#introduction


Tags: importenvclientapidefcbprobuyproduct
2条回答

另一位评论者是正确的。无论出于何种原因(可能是由于每个特殊令牌/硬币中小数点的重要性),可能是由于浮动不精确,这可能会产生问题,或者是由于创建python包装器的惰性;Python中的Coinbase Pro API几乎总是将看起来像整数的内容和浮点数作为字符串

def test1():

    client.buy(product_id='BTC-GBP', order_type="market",funds='5.00')


我认为基金应该是一个字符串,funds='5.00'

相关问题 更多 >

    热门问题