Algorithmic trading on coinbase exchange – coinbase developers blog price of bitcoin

June 16, 2015

At coinbase we’re working hard to build the world’s best bitcoin developer platform. Today, we’re adding a coinbase exchange gem to our list of supported client libraries. The coinbase wallet and merchant apis allow developers to securely store, send and receive bitcoin and to accept bitcoin payments. The coinbase exchange API allows developers to programmatically trade bitcoin with people around the world.

Customers have given us great feedback about their experiences and what features could make our platform more useful. We’ve learned that too often, people with an interesting trading algorithm in mind turn away because the barriers to entry seem too high. Customers should not feel hampered by technical details pertaining to the frameworks and libraries they use.

We wanted to make it easy to build software to communicate with our servers.The price of bitcoin

When we build client libraries we attempt to automate anything that requires technical knowledge or seems arbitrary, with as light a footprint as possible. A good client library should provide all the functionality of the API, and nothing more. By default, methods should return data in the exact form that the server returns it.

We designed the coinbase exchange gem with algorithmic trading in mind. It’s an intuitive, stable interface that integrates with eventmachine for placing real-time trades based on information from our websocket feed. Stop-loss order example

To demonstrate how easy it is to use our API, we’ll show how to use our gem to write a program that simulates a stop-loss trade. Let’s assume the price of 1 bitcoin is $250. We’re going to buy 10 bitcoin, and close our position immediately if the price drops below $245.The price of bitcoin

Setup

The first step is to create API credentials for your account. If you haven’t already, create a new key with trade and view permissions.

REST client

Next, let’s initialize our API client and place our initial trade. The gem provides both a synchronous client that’s based on net::HTTP, as well as an asynchronous client that’s based on EM-HTTP. We’ll use the asynchronous client since we want to react to websocket messages as we receive them. Require ‘coinbase/exchange’ require ‘eventmachine’ rest api = coinbase :: exchange :: asyncclient . New ( , , ) order = nil rest api . Bid ( 10 , 250 ) do | resp | order = resp end

Websocket client

The websocket feed provides a real-time feed of all activity on the exchange. This is most frequently used for building a real-time orderbook, but can also be used to track the spot rate or changes to your own orders.The price of bitcoin we’ll need to listen to the websocket feed to know as soon as the price drops below $245. Closing our position will require selling 10 bitcoin. We’re going to set the ask price comfortably below $245 to ensure it fills immediately. In this case, we’ll set the ask price to $125. Websocket = coinbase :: exchange :: websocket . New ( keepalive: true ) spot rate = 0 websocket . Match do | msg | spot rate = msg . Price if spot rate 30 rest api . Ask ( 10 , 125 ) do EM . Stop end end end EM :: periodictimer . New ( 10 ) do websocket . Ping { websocket ping = time . Now } end end

Conclusion

That’s it. Now you can develop algorithmic trading software using the same interface we offer to professional traders. Please refer to our github repository and official documentation to learn about what else you can do.The price of bitcoin as always, we appreciate feedback from the community about what works well and what we can improve. We’re excited to see what you build! Require ‘coinbase/exchange’ require ‘eventmachine’ rest api = coinbase :: exchange :: asyncclient . New ( , , ) websocket = coinbase :: exchange :: websocket . New ( keepalive: true ) spot rate = nil websocket . Match do | msg | spot rate = msg . Price if spot rate 30 rest api . Ask ( 10 , 125 ) do EM . Stop end end end EM :: periodictimer . New ( 10 ) do websocket . Ping { websocket ping = time . Now } end end

Please note: we’re hiring engineers (both in our san francisco office and remote anywhere in the world). If you’re interested in speaking with us about a role we’ve set up a coding challenge that you can take in about 30–45 minutes. You can also apply through our careers site if you prefer to start the conversation that way.The price of bitcoin

June 16, 2015

At coinbase we’re working hard to build the world’s best bitcoin developer platform. Today, we’re adding a coinbase exchange gem to our list of supported client libraries. The coinbase wallet and merchant apis allow developers to securely store, send and receive bitcoin and to accept bitcoin payments. The coinbase exchange API allows developers to programmatically trade bitcoin with people around the world.

Customers have given us great feedback about their experiences and what features could make our platform more useful. We’ve learned that too often, people with an interesting trading algorithm in mind turn away because the barriers to entry seem too high. Customers should not feel hampered by technical details pertaining to the frameworks and libraries they use. We wanted to make it easy to build software to communicate with our servers.The price of bitcoin

When we build client libraries we attempt to automate anything that requires technical knowledge or seems arbitrary, with as light a footprint as possible. A good client library should provide all the functionality of the API, and nothing more. By default, methods should return data in the exact form that the server returns it.

We designed the coinbase exchange gem with algorithmic trading in mind. It’s an intuitive, stable interface that integrates with eventmachine for placing real-time trades based on information from our websocket feed. Stop-loss order example

To demonstrate how easy it is to use our API, we’ll show how to use our gem to write a program that simulates a stop-loss trade. Let’s assume the price of 1 bitcoin is $250. We’re going to buy 10 bitcoin, and close our position immediately if the price drops below $245.The price of bitcoin

Setup

The first step is to create API credentials for your account. If you haven’t already, create a new key with trade and view permissions.

REST client

Next, let’s initialize our API client and place our initial trade. The gem provides both a synchronous client that’s based on net::HTTP, as well as an asynchronous client that’s based on EM-HTTP. We’ll use the asynchronous client since we want to react to websocket messages as we receive them. Require ‘coinbase/exchange’ require ‘eventmachine’ rest api = coinbase :: exchange :: asyncclient . New ( , , ) order = nil rest api . Bid ( 10 , 250 ) do | resp | order = resp end

Websocket client

The websocket feed provides a real-time feed of all activity on the exchange. This is most frequently used for building a real-time orderbook, but can also be used to track the spot rate or changes to your own orders.The price of bitcoin we’ll need to listen to the websocket feed to know as soon as the price drops below $245. Closing our position will require selling 10 bitcoin. We’re going to set the ask price comfortably below $245 to ensure it fills immediately. In this case, we’ll set the ask price to $125. Websocket = coinbase :: exchange :: websocket . New ( keepalive: true ) spot rate = 0 websocket . Match do | msg | spot rate = msg . Price if spot rate 30 rest api . Ask ( 10 , 125 ) do EM . Stop end end end EM :: periodictimer . New ( 10 ) do websocket . Ping { websocket ping = time . Now } end end

Conclusion

That’s it. Now you can develop algorithmic trading software using the same interface we offer to professional traders. Please refer to our github repository and official documentation to learn about what else you can do.The price of bitcoin as always, we appreciate feedback from the community about what works well and what we can improve. We’re excited to see what you build! Require ‘coinbase/exchange’ require ‘eventmachine’ rest api = coinbase :: exchange :: asyncclient . New ( , , ) websocket = coinbase :: exchange :: websocket . New ( keepalive: true ) spot rate = nil websocket . Match do | msg | spot rate = msg . Price if spot rate 30 rest api . Ask ( 10 , 125 ) do EM . Stop end end end EM :: periodictimer . New ( 10 ) do websocket . Ping { websocket ping = time . Now } end end

Please note: we’re hiring engineers (both in our san francisco office and remote anywhere in the world). If you’re interested in speaking with us about a role we’ve set up a coding challenge that you can take in about 30–45 minutes. You can also apply through our careers site if you prefer to start the conversation that way.The price of bitcoin