Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shorting stock not developed? #73

Closed
bkunsberg opened this issue Nov 8, 2021 · 10 comments
Closed

Shorting stock not developed? #73

bkunsberg opened this issue Nov 8, 2021 · 10 comments
Assignees

Comments

@bkunsberg
Copy link

bkunsberg commented Nov 8, 2021

Hi,

Thank you for the very useful package!
I'm trying to backtest a strategy that involves shorting a stock/crypto. This means I make a call like:
interface.market_order('MSFT', 'sell', 1)
in a price_event function.

This results in an error message such as:
*** blankly.utils.exceptions.InvalidOrder: Not enough base currency. Available: 0.0. hold: 0. requested: 1.

I'd expect to be able to short on Alpaca, as doing a 'sell' market order (e.g. through their web console) with 0 position is successful.

Note: I've gotten the same results with

alpaca = Alpaca()
s = Strategy(alpaca)

and
coinbase = CoinbasePro()
crypto = Strategy(coinbase)

Is this intentional? Thanks so much!

@EmersonDove EmersonDove self-assigned this Nov 8, 2021
@EmersonDove
Copy link
Member

Yep you are absolutely right. We haven't implemented the shorting for alpaca in the backtesting framework - this is the most significant feature that we're missing in a full alpaca integration.

We are working on this, I will attach this issue to a pull.

@bkunsberg
Copy link
Author

Thanks for the quick reply! Looking forward to the full integration.

@sjhermanek
Copy link

@EmersonDove glad you're working on this! Do you plan to do the same for Crypto (e.g. binance API)?

@EmersonDove
Copy link
Member

@sjhermanek This is a really good question. I suppose I'm not sure of the answer because I'm not really a binance user.

As I understand it, the margin API calls are through different endpoints which would make that integration significantly more complex but I'm not super sure. I think because of this we are going to wait for that more advanced stuff.

EmersonDove added a commit that referenced this issue Nov 24, 2021
@EmersonDove
Copy link
Member

This feature is now active on the dev branch.

@bfan1256
Copy link
Contributor

@bkunsberg , this is now live! Let us know what you think 💭

@bkunsberg
Copy link
Author

bkunsberg commented Jan 16, 2022 via email

@femtotrader
Copy link

femtotrader commented Feb 23, 2023

Shorting on Binance and with KeylessExchange seems to also be impossible. Any idea if it will be possible in a next release ?

@EmersonDove
Copy link
Member

The blankly.Binance() exchange is spot, so shorting is disabled. KeylessExchange is also made to mimic spot so I didn't add an option for shorting but I could see an argument for adding it.

@femtotrader
Copy link

Supporting Binance cross margin will be great also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants