-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
168 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class OpenSpotOrder < ApplicationRecord | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<div class="m-3 row"> | ||
<div class="col-10 mx-auto"> | ||
<h3>币安现货委托单</h3> | ||
<div class="mb-3 mt-3"> | ||
<%= form_tag open_spot_orders_path, id: "search_targets", class: "position-relative", method: "GET" do %> | ||
<div class="input-group mb-3 position-filter"> | ||
<%= select_tag(:search, options_for_select(@symbols, @symbol), { prompt: '请选择币种...', class: 'select2-dropdown form-control' }) %> | ||
<span class='ms-3'></span> | ||
<%= select_tag(:trade_type, options_for_select([['买入', 'buy'], ['卖出', 'sell']], @trade_type),{ prompt: '请选择买卖类别...', class: 'select2-dropdown form-control' }) %> | ||
<span class='ms-3'></span> | ||
<button type="submit" class="btn btn-primary mx-3">确定</button> | ||
<%= link_to "Reset", open_spot_orders_path, class: 'btn btn-warning me-3' %> | ||
</div> | ||
<% end %> | ||
</div> | ||
<div class="mt-3"> | ||
<table class="table"> | ||
<thead> | ||
<tr class="table-container-tr"> | ||
<th>订单时间</th> | ||
<th>币种</th> | ||
<th>买卖类别</th> | ||
<th>委托价</th> | ||
<th>委托数量</th> | ||
<th>成交数量</th> | ||
<th>委托金额</th> | ||
<th>订单类型</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% if @open_orders.any? %> | ||
<% @open_orders.each do |order| %> | ||
<tr> | ||
<td><%= order.order_time %></td> | ||
<td><%= order.symbol %></td> | ||
<td class="<%= trade_type_style(order.trade_type) %>"><%= I18n.t("views.trading.#{order.trade_type}") %></td> | ||
<td><%= order.price.round(4) %></td> | ||
<td><%= order.orig_qty.round(4) %></td> | ||
<td><%= order.executed_qty.round(4) %></td> | ||
<td><%= order.amount.round(4) %></td> | ||
<td><%= order.order_type %></td> | ||
</tr> | ||
<% end %> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
<%= paginate @open_orders %> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class CreateOpenSpotOrders < ActiveRecord::Migration[6.1] | ||
def change | ||
create_table :open_spot_orders do |t| | ||
t.string :symbol | ||
t.string :order_id | ||
t.string :trade_type | ||
t.string :status | ||
t.string :order_type | ||
t.decimal :price | ||
t.decimal :stop_price | ||
t.decimal :orig_qty | ||
t.decimal :executed_qty | ||
t.decimal :amount | ||
t.datetime :order_time | ||
|
||
t.timestamps | ||
end | ||
|
||
add_index :open_spot_orders, :order_id | ||
add_index :open_spot_orders, :symbol | ||
add_index :open_spot_orders, :trade_type | ||
add_index :open_spot_orders, :order_time | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FactoryBot.define do | ||
factory :open_spot_order do | ||
symbol { 'BTCUSDT' } | ||
price { 1 } | ||
orig_qty { 1 } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe OpenSpotOrder, type: :model do | ||
let(:open_spot_order) { create(:open_spot_order) } | ||
|
||
it "have a valid factory" do | ||
expect(open_spot_order).to be_valid | ||
end | ||
end |