0.0
No commit activity in last 3 years
No release in over 3 years
FIghter Base gives you access to level, exchange, and order information to use to build market scripts and play the levels of the Stockfighter game.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.10
~> 10.0
>= 0

Runtime

~> 0.13.7
 Project Readme

FighterBase

Wrapper methods for interacting with the APIs in the Stockfighter.io game.

Installation

Add this line to your application's Gemfile:

gem 'fighter_base'

And then execute:

$ bundle

Or install it yourself as:

$ gem install fighter_base

Usage

The main classes are

Level

level = FighterBase::Level.new(api_key, account, venue_symbol)

Creating a Level instance also creates an Exchange instance of the given venue. You need the Exchange instance to get quotes and place orders.

Exchange

Most interaction will be through this class. Quote for a stock, orderbook for a stock, place an order, cancel an order is done here. Methods return JSON from the APIs parsed into a hash.

ex = level.exchange

quote = ex.get_quote("FAC")

then get information from it as

quote["ask"] or quote["bid_size"]

Order

Class is not implemented yet - still working how to model them in this system.

Orders can be placed and canceled through the Exchange insance

order = ex.place_order(stock: symbol, price: ask, qty: size, direction: "buy", type: "limit")

Note: Exchange#place_order currently returns a hash. In the future it will return a propper Order instance.

Note: Order method uses named argument style method. The rest of the methods will soon switch to that style.

Notes

There are still some parts that I'm not certain about. If you create an order with Order#new, then place it on a venue and it is partially filled. When you look at properties of the order, it won't be updated.

Maybe the order instances should be able to update themselves, because they know the venue they were placed on?

Its probably best to think of the Order instance as a cache, and the real data is kept on the server.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/fighter_base.